/* GRAVITY FOUR の雰囲気に合わせたスタイル: 黒緑の背景 + 走査線 + ネオンの枠 + ドットフォント */
@font-face { font-family: yodaka; src: url("yodaka.woff") format("woff"); font-display: swap; }
/* 盤面用: Noto Sans JP Bold のひらがなサブセット (fonts/OFL.txt) */
@font-face {
  font-family: "Noto Sans JP Hira";
  font-weight: 700;
  font-display: swap;
  src: url("fonts/NotoSansJP-Bold-hira.woff2") format("woff2");
}
:root {
  color-scheme: dark;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  color: #d4f8e9;
  background: #050a0b;
  --line: #237759; --glow: #2ba46e; --dim: #78ad98;
  --blue: #2c66c9; --blue-text: #8db8ff;
  --red: #b8324a; --red-text: #ff8da1;
  --both: #7b3fc2; --both-text: #cfa6ff;
  --gold: #e8e070;
  --kana: "Noto Sans JP Hira", "Yu Gothic", Meiryo, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { min-height: 100vh; margin: 0; background: radial-gradient(ellipse at 50% -25%, #103329 0, #050a0b 56%); }
body::before { content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .14; background: repeating-linear-gradient(0deg, transparent 0 3px, #0f4837 4px); }
button, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid #a8ffe0; outline-offset: 3px; }
h1, h2, p { margin-top: 0; }

.app { position: relative; max-width: 620px; margin: auto; padding: 22px clamp(12px, 3vw, 24px) 42px; }
.brand { margin-bottom: 22px; display: flex; align-items: center; justify-content: center; gap: 16px; }
.brand h1 { margin: 6px 0 3px; font: clamp(26px, 6vw, 40px)/1.1 yodaka, monospace; letter-spacing: .08em; color: #d8fff0; text-shadow: 0 0 22px #2bd98b6b; }
.gem { width: 14px; height: 14px; transform: rotate(45deg); }
.gem.blue { background: var(--blue); box-shadow: 0 0 12px var(--blue); }
.gem.red { background: var(--red); box-shadow: 0 0 12px var(--red); }

.match-bar { display: flex; align-items: center; gap: 8px; font-size: 18px; letter-spacing: .12em; color: var(--dim); }
#com-level { flex: 1; text-align: center; font-size: 22px; letter-spacing: .18em; color: var(--red-text); }
@keyframes blink { 50% { opacity: .25; } }
.btn { padding: 12px 16px; border: 1px solid #28674e; background: #0a1c15; color: #a3ebc8; font-size: 18px; letter-spacing: .1em; }
.btn:hover { border-color: #83ffbd; background: #17402c; }
.btn:disabled { color: #4f7565; border-color: #1c3a2d; cursor: default; }

.scores { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.sc { cursor: pointer; user-select: none; -webkit-user-select: none; display: grid; grid-template-columns: 1fr auto; align-items: baseline; padding: 8px 12px; border: 1px solid; background: linear-gradient(145deg, #12251f, #081511); box-shadow: inset 0 0 0 1px #092c20, 0 8px 28px #0009; }
.sc.p { border-color: var(--blue); }
.sc.c { border-color: var(--red); }
.sc { transition: background .3s, box-shadow .3s; }
.sc.p.active { background: linear-gradient(145deg, #1c3a68, #10254a); animation: glow-p 1.8s ease-in-out infinite; }
.sc.c.active { background: linear-gradient(145deg, #4d2030, #2e121d); animation: glow-c 1.8s ease-in-out infinite; }
@keyframes glow-p { 0%, 100% { box-shadow: inset 0 0 0 1px #16305a, 0 0 8px #2c66c980, 0 0 18px #2c66c944; } 50% { box-shadow: inset 0 0 0 1px #2c66c9, 0 0 16px #5b91f0cc, 0 0 34px #2c66c988; } }
@keyframes glow-c { 0%, 100% { box-shadow: inset 0 0 0 1px #4a1b28, 0 0 8px #b8324a80, 0 0 18px #b8324a44; } 50% { box-shadow: inset 0 0 0 1px #b8324a, 0 0 16px #ff6b86cc, 0 0 34px #b8324a88; } }
.sc .who { font-size: 21px; letter-spacing: .18em; }
.sc .who::after { content: " ▾"; color: var(--dim); }
.sc.open .who::after { content: " ▴"; }
.sc.p .who, .sc.p b { color: var(--blue-text); }
.sc.c .who, .sc.c b { color: var(--red-text); }
.sc b { font: 46px yodaka, monospace; }
.sc small { display: none; white-space: pre-line; grid-column: 1 / -1; margin-top: 4px; font-size: 18px; line-height: 1.5; letter-spacing: .04em; color: #b4d8c8; }
.sc.open small { display: block; }

.entry { position: relative; margin-top: 14px; }
#word { width: 100%; padding: 12px 14px; border: 1px solid var(--glow); background: #06130f; color: #d8fff0; font: 26px/1.2 var(--kana); letter-spacing: .1em; caret-color: #57ffb6; caret-shape: block; box-shadow: 0 0 21px #1baa6c30, inset 0 0 17px #0d402a80; }
#word:focus { outline: none; border-color: #83ffbd; box-shadow: 0 0 24px #2bec9055, inset 0 0 17px #0d402a80; }
#word::placeholder { font: 21px ui-monospace, Consolas, monospace; letter-spacing: .18em; color: #4f7565; }
/* 空のときは点滅するブロックカーソルを出す (入力すると本物のカーソルに切り替わる) */
#word:placeholder-shown { padding-left: 42px; caret-color: transparent; }
.entry:has(#word:placeholder-shown)::after { content: ""; position: absolute; left: 15px; top: 50%; width: 12px; height: 28px; margin-top: -14px; background: #57ffb6; box-shadow: 0 0 8px #57ffb688; animation: blink 1s steps(2, end) infinite; pointer-events: none; }
#message { min-height: 2.8em; margin: 10px 0; font-size: 21px; line-height: 1.4; letter-spacing: .1em; color: #b4f5d9; }
#message.bad { color: var(--red-text); }

.board-frame { padding: 8px; border: 1px solid var(--glow); box-shadow: 0 0 21px #1baa6c47, inset 0 0 17px #0d402a80; }
#board {
  display: grid; grid-template-columns: repeat(var(--n, 11), 1fr); gap: 1px; width: 100%; aspect-ratio: 1;
  background: #0f3a2a; touch-action: none; user-select: none; -webkit-user-select: none;
}
.cell {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  background: #07130f; color: #d8fff0; font: 700 clamp(16px, calc(min(92vw, 580px) / var(--n, 11) * .62), 42px)/1 var(--kana);
}
.cell.filled { background: #1a3a2e; text-shadow: 0 0 8px #2bd98b66; }
.cell.o1 { background: var(--blue); text-shadow: 0 0 8px #8db8ff99; }
.cell.o2 { background: var(--red); text-shadow: 0 0 8px #ff8da199; }
.cell.o3 { background: var(--both); text-shadow: 0 0 8px #cfa6ff99; }
.cell.pv-ok { background: #124a34; outline: 2px dashed #57ffb6; outline-offset: -2px; }
.cell.pv-ng { background: #26302c; color: #7a8b83; outline: 2px dashed #6b7a73; outline-offset: -2px; }

.key { display: inline-block; width: 10px; height: 10px; margin: 0 6px 0 12px; vertical-align: -1px; }
.key:first-child { margin-left: 0; }
.key.p { background: var(--blue); } .key.c { background: var(--red); } .key.b { background: var(--both); }

.credits { margin-top: 34px; padding-top: 12px; border-top: 1px solid #0f3a2a; font-size: 12px; line-height: 1.7; letter-spacing: .08em; color: #5f8a76; }
.credits p { margin: 0 0 4px; }
.credits a { color: #86c9a9; }
.log-title { margin: 22px 0 6px; font: 28px yodaka, monospace; letter-spacing: .12em; color: #b4ffdb; }
#log { margin: 0; padding: 0; list-style: none; max-height: 220px; overflow: auto; font: 21px/1.6 var(--kana); }
#log li { padding: 3px 8px; border-left: 3px solid; background: #081511; margin-bottom: 3px; }
#log li.p { border-color: var(--blue); color: var(--blue-text); }
#log li.c { border-color: var(--red); color: var(--red-text); }

/* TITLE */
.title-view { display: flex; flex-direction: column; align-items: center; padding-top: 8vh; }
.title-view .brand h1 { font-size: clamp(34px, 9vw, 56px); }
.menu-lead { margin: 6px 0 18px; font-size: 16px; letter-spacing: .18em; color: #b4f5d9; text-align: center; }
.menu-lead:empty { display: none; }
.menu-lead.bad { color: var(--red-text); }
.level-list { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.level-choice { display: flex; align-items: center; justify-content: center; min-height: 67px; padding: 16px; border: 1px solid #237759; background: linear-gradient(145deg, #12251f, #081511); color: #d4f8e9; box-shadow: inset 0 0 0 1px #092c20, 0 8px 28px #0009; transition: transform .18s, border-color .18s, box-shadow .18s; }
.level-choice strong { font: clamp(26px, 7vw, 38px) yodaka, monospace; letter-spacing: .1em; color: #b4ffdb; }
.level-choice:hover, .level-choice:focus-visible { transform: translateY(-4px); border-color: #57ffb6; box-shadow: 0 0 22px #19cc793d; }
body:not(.ready) .level-choice { opacity: .4; pointer-events: none; }
.title-view .credits { width: 100%; }

/* LEAVE CONFIRM */
.leave-confirm { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 16px; background: #020707e8; backdrop-filter: blur(6px); }
.leave-card { width: min(360px, 100%); padding: 22px; border: 1px solid #3db57c; background: #071611; box-shadow: 0 0 50px #14a66855; text-align: center; }
.leave-card p { margin: 0 0 18px; font: 28px yodaka, monospace; letter-spacing: .1em; color: #d8ffe8; }
.leave-actions { display: flex; justify-content: center; gap: 12px; }
.leave-actions .btn { min-width: 90px; }

/* HOW TO PLAY */
.help-button { width: 100%; margin: 16px 0 6px; padding: 13px; border: 1px solid var(--glow); background: #0a1c15; color: #b4ffdb; font: 22px yodaka, monospace; letter-spacing: .14em; box-shadow: 0 0 21px #1baa6c30; }
.help-button:hover, .help-button:focus-visible { border-color: #83ffbd; background: #17402c; }
.help-title { margin: 16px 0 4px; font: clamp(30px, 8vw, 42px) yodaka, monospace; letter-spacing: .1em; color: #d8fff0; text-shadow: 0 0 22px #2bd98b6b; }
.help-block { margin-top: 20px; padding-top: 12px; border-top: 1px solid #0f3a2a; font-size: 14px; line-height: 1.8; letter-spacing: .06em; color: #b4d8c8; }
.help-block h3 { margin: 0 0 6px; font: 21px yodaka, monospace; letter-spacing: .12em; color: #b4ffdb; }
.help-block p { margin: 0 0 8px; }
.help-block b { color: #e8fff4; }
.help-block ul { margin: 0 0 8px; padding: 0; list-style: none; }
.help-block li { position: relative; margin-bottom: 4px; padding-left: 14px; }
.help-block li::before { content: ""; position: absolute; left: 0; top: .7em; width: 6px; height: 6px; background: var(--glow); }
.island-table { border-collapse: collapse; margin: 6px 0 10px; font-size: 14px; }
.island-table th, .island-table td { padding: 4px 10px; border: 1px solid #1c4a38; text-align: center; }
.island-table th { color: var(--dim); font-weight: normal; letter-spacing: .12em; text-align: left; }
.island-table td { color: #e8fff4; }

/* SCORE POP-UP */
.pop { position: fixed; z-index: 30; inset: 0; display: grid; place-items: center; padding: 16px; background: #020707b8; }
.pop-card { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.pop-line { display: flex; align-items: baseline; justify-content: center; gap: 14px; font: clamp(24px, 7vw, 44px)/1.1 yodaka, monospace; animation: pop-in .22s ease-out both; }
.pop-line .tag { font-size: .5em; letter-spacing: .16em; color: var(--dim); }
.pop-line .jp { font: 700 clamp(24px, 7vw, 44px)/1.1 var(--kana); }
.pop-total { display: flex; flex-direction: column; align-items: center; margin-top: 8px; animation: total-in .4s cubic-bezier(.2, 1.4, .4, 1) both; }
.pop-total .tag { font: 16px ui-monospace, Consolas, monospace; letter-spacing: .3em; color: var(--dim); }
.pop-total b { font: clamp(84px, 28vw, 170px)/1 yodaka, monospace; }
.pop.p .pop-line b, .pop.p .pop-line .jp, .pop.p .pop-total b { color: var(--blue-text); text-shadow: 0 0 26px #2c66c9cc; }
.pop.c .pop-line b, .pop.c .pop-line .jp, .pop.c .pop-total b { color: var(--red-text); text-shadow: 0 0 26px #b8324acc; }
@keyframes pop-in { from { opacity: 0; transform: scale(1.7); } to { opacity: 1; transform: scale(1); } }
@keyframes total-in { from { opacity: 0; transform: scale(.4); } to { opacity: 1; transform: scale(1); } }

/* HOW TO PLAY: 言語切り替え (右上のボタン) と日本語表示 */
.help-view .match-bar { justify-content: space-between; }
.help-lang { min-width: 108px; }
.help-body[lang="ja"] { --jp: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", Meiryo, "Noto Sans JP", sans-serif; }
.help-body[lang="ja"] .help-title { font-family: yodaka, monospace; font-weight: 400; letter-spacing: .1em; }
.help-body[lang="ja"] .help-lead { margin: 22px 0; font: 16px/1.9 var(--jp); letter-spacing: .03em; }
.help-body[lang="ja"] .help-block { font: 16px/1.9 var(--jp); letter-spacing: .03em; }
.help-body[lang="ja"] .help-block h3 { font: 700 20px var(--jp); letter-spacing: .1em; }
.help-body[lang="ja"] .island-table th, .help-body[lang="ja"] .island-table td { font: 15px var(--jp); }

/* スマホ用: 盤面の下の日本語フリック入力 */
.kana-pad { display: none; }
body.keypad .kana-pad {
  align-self: center; /* キーの幅を抑えたときは、中央に寄せる */
  /* キー3列。キーどうしのすき間は無し。左端のキーの左と右端のキーの右に出る候補のために、左右にキー1つぶんずつ余白を取る。
     下段のキーを下へフリックしたときの候補は、メッセージ欄に重なってよいので、下の余白 (--reserve) は画面の外に出ないぶんだけ */
  display: grid; grid-template-columns: repeat(3, var(--k, 84px)); grid-auto-rows: var(--kh, 48px); gap: 0;
  margin-top: 12px; padding-inline: var(--k, 84px); padding-bottom: var(--reserve, 0px); /* 左右に同じ余白: キー部分が中央に来る */
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.fkey, .akey {
  position: relative; display: flex; align-items: center; justify-content: center; min-height: 0;
  border: 1px solid #28674e; background: linear-gradient(145deg, #12251f, #081511); color: #d8fff0;
  font: 700 26px/1 var(--kana); box-shadow: inset 0 0 0 1px #092c20;
}
.akey { cursor: pointer; }
.akey.small { font-size: 22px; }
.akey.del { font: 22px yodaka, monospace; color: var(--red-text); border-color: var(--red); }
.fkey .fg { display: none; }
.fkey.down { z-index: 50; background: #17402c; border-color: #57ffb6; }
.fkey.down .main { visibility: hidden; }
.fkey.down .fg { display: flex; align-items: center; justify-content: center; position: absolute; width: 100%; height: 100%; box-sizing: border-box; font-style: normal;
  background: #0d2a1f; border: 1px solid #57ffb6; color: #d8fff0; box-shadow: 0 0 14px #19cc7955; }
.fkey.down .fg.c { left: 0; top: 0; background: #17402c; } /* 押したキー自体 */
.fkey.down .fg.l { right: 100%; top: 0; }
.fkey.down .fg.r { left: 100%; top: 0; }
.fkey.down .fg.u { bottom: 100%; left: 0; }
.fkey.down .fg.d { top: 100%; left: 0; }
.fkey.down .fg.sel { background: #57ffb6; color: #04120c; }

/* 新しくできた単語を囲むカプセル (相手の1ターンが終わるまで)。金色の細い線だけ (塗りやグローなし)、自分も相手も同じ色 */
.board-wrap { position: relative; }
#marks { position: absolute; inset: 0; pointer-events: none; }
.pill { position: absolute; box-sizing: border-box; border: 1.5px solid #e8e070; border-radius: 999px; }

/* ============ 対局画面: はみ出さない縦レイアウト ============ */
/* 盤面は「幅」と「残りの高さ」の小さい方に合わせた正方形 (大きさは game.js の fitBoard が決める)。
   幅で決まる場合は、下に余白が空く。 */
body.in-game { overflow: hidden; }
body.in-game .app { max-width: 620px; height: 100vh; height: 100dvh; padding: 8px 8px calc(6px + env(safe-area-inset-bottom)); }
.game-view { display: flex; flex-direction: column; gap: 4px; height: 100%; min-height: 0; --kh: clamp(34px, 5.2dvh, 50px); }
.game-view .match-bar { font-size: clamp(14px, 2.2dvh, 18px); }
.game-view .btn { padding: clamp(6px, 1.3dvh, 12px) 14px; font-size: clamp(14px, 2.2dvh, 18px); }
.game-view #com-level { font-size: clamp(16px, 2.8dvh, 22px); }
.game-view .scores { margin-top: 0; }
.game-view .sc { position: relative; padding: 4px 12px; }
.game-view .sc .who { font-size: clamp(14px, 2.4dvh, 21px); }
.game-view .sc b { font: clamp(28px, 5dvh, 46px)/1.05 yodaka, monospace; }
/* スコアの内訳は、枠の下に重ねて出す (レイアウトを動かさない) */
.game-view .sc small { position: absolute; left: -1px; right: -1px; top: calc(100% + 4px); z-index: 20; margin: 0; padding: 8px 10px; border: 1px solid #237759; background: #081511f2; box-shadow: 0 8px 24px #000c; }
.game-view .entry { margin: 0; }
.game-view #word { padding: 4px 12px; font-size: clamp(18px, 3.2dvh, 24px); }
.game-view #message { flex: none; min-height: 1.3em; margin: 0; font-size: clamp(14px, 2.4dvh, 19px); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 盤面の枠は正方形 (盤面ぴったり) */
.game-view .board-frame { flex: none; align-self: center; width: min(100%, 60dvh); aspect-ratio: 1; padding: 3px; }
.game-view .board-wrap { width: 100%; height: 100%; container-type: inline-size; }
.game-view #board { width: 100%; height: 100%; aspect-ratio: auto; grid-template-rows: repeat(var(--n, 11), 1fr); }
.game-view .cell { aspect-ratio: auto; font-size: calc(100cqw / var(--n, 11) * .6); }
body.keypad .game-view .kana-pad { flex: none; margin-top: 0; }
/* 履歴: 最新の 2 手だけ。行数が変わっても高さが変わらないよう、2 行ぶんの高さを確保する */
.game-view #log { flex: none; overflow: hidden; height: calc(2 * (1.3em + 6px)); font: 700 clamp(13px, 2.2dvh, 17px)/1.3 var(--kana); }
.game-view #log li { margin-bottom: 2px; padding: 2px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game-view #log li:nth-child(n+3) { display: none; }

/* PLAY 画面の英語はすべて yodaka (下のメッセージだけは今のフォントのまま) */
.game-view .btn, .game-view #com-level, .game-view .sc .who, .game-view .sc small { font-family: yodaka, monospace; }
.game-view #word::placeholder { font-family: yodaka, monospace; }
.pop-total .tag { font-family: yodaka, monospace; }

/* 交点: 細い金色のひし形を、2D でゆっくり時計回りに回す (次の手が置かれるまで) */
.gem-mark { position: absolute; pointer-events: none; animation: gem-spin 7s linear infinite; }
.gem-mark i { position: absolute; inset: 0; box-sizing: border-box; border: 1.5px solid #e8e070; transform: rotate(45deg); }
@keyframes gem-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } /* 2D の時計回り */

/* キャラクターの顔 (16x16 のドット絵を体・目・口の順に重ねる) */
.face { position: relative; display: inline-block; flex: none; width: 40px; height: 40px; }
.face img, .face canvas { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }
.hud-face, .game-view .sc .face { width: clamp(30px, 4.8dvh, 42px); height: clamp(30px, 4.8dvh, 42px); }
.game-view .sc.p, .game-view .sc.c { display: grid; grid-template-columns: auto 1fr auto; column-gap: 8px; align-items: center; }
.game-view .sc .face { grid-row: 1; }
.game-view .sc .who { grid-column: 2; }
.game-view .sc b { grid-column: 3; }
.game-view .sc small { grid-column: 1 / -1; }

/* RANK MATCH */
.rank-view .help-title { margin-top: 12px; }
.rank-summary { margin: 6px 0 2px; font: 20px yodaka, monospace; letter-spacing: .06em; color: #b4ffdb; }
.rank-daily { min-height: 1.2em; margin: 0 0 10px; font-size: 13px; letter-spacing: .08em; color: var(--dim); }
.rank-list { margin: 0; padding: 0; list-style: none; }
.rank-list li { margin-bottom: 4px; }
.rank-row { display: grid; grid-template-columns: 2.4em 40px 1fr auto 3.2em; align-items: center; gap: 10px; width: 100%; padding: 4px 10px; border: 1px solid #1c4a38; background: #081511; color: #d4f8e9; text-align: left; font: 18px yodaka, monospace; letter-spacing: .06em; }
button.rank-row { cursor: pointer; }
button.rank-row:hover, button.rank-row:focus-visible { border-color: #57ffb6; background: #17402c; }
.rank-row .rk { color: var(--dim); text-align: right; }
.rank-row .rt { color: #b4d8c8; font-size: 15px; }
.rank-row i { font-style: normal; font-size: 13px; }
.rank-row i.up { color: #7dffb0; }
.rank-row i.down { color: var(--red-text); }
.rank-list li.me .rank-row { border-color: var(--blue); background: #10254a; color: var(--blue-text); }
.game-view .sc .who { white-space: nowrap; }

/* プレイ中のスコア枠 (青 = あなた / 赤 = COM): 枠と内側をもっと明るく */
.game-view .sc.p { border-color: #7db4ff; background: linear-gradient(145deg, #1a3b70, #102850); box-shadow: inset 0 0 0 1px #3d7be0, 0 0 10px #3d7be080; }
.game-view .sc.c { border-color: #ff7b96; background: linear-gradient(145deg, #5a2236, #351322); box-shadow: inset 0 0 0 1px #d8405c, 0 0 10px #e0405a80; }
.game-view .sc.p.active { background: linear-gradient(145deg, #2f63b8, #1c4384); animation: glow-p 1.8s ease-in-out infinite; }
.game-view .sc.c.active { background: linear-gradient(145deg, #8a2e4a, #56192d); animation: glow-c 1.8s ease-in-out infinite; }
@keyframes glow-p { 0%, 100% { box-shadow: inset 0 0 0 1px #5b91f0, 0 0 12px #5b91f0cc, 0 0 24px #3d7be088; } 50% { box-shadow: inset 0 0 0 1px #a8ccff, 0 0 22px #8db8ffff, 0 0 46px #5b91f0cc; } }
@keyframes glow-c { 0%, 100% { box-shadow: inset 0 0 0 1px #ff6b86, 0 0 12px #ff6b86cc, 0 0 24px #e0405a88; } 50% { box-shadow: inset 0 0 0 1px #ffc0cc, 0 0 22px #ff9ab0ff, 0 0 46px #ff6b86cc; } }

/* 勝ったときの演出 (光の筋・紙吹雪・花火・大きな YOU WIN) */
.victory { position: fixed; z-index: 60; inset: 0; display: grid; place-items: center; overflow: hidden; cursor: pointer;
  background: radial-gradient(circle at 50% 45%, #3a3000f2 0, #050a0bf5 72%); animation: vic-flash .9s ease-out; }
.vic-fx { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.conf { position: absolute; top: -24px; border-radius: 2px; animation: conf-fall linear infinite; }
.spark { position: absolute; width: 8px; height: 8px; margin: -4px; border-radius: 50%; box-shadow: 0 0 8px currentColor; animation: spark 1.2s ease-out forwards; }
.vic-card { position: relative; text-align: center; padding: 0 12px; }
.vic-title { font: clamp(60px, 22vw, 140px)/1 yodaka, monospace; letter-spacing: .06em; color: #fff6a8;
  text-shadow: 0 0 12px #e8e070, 0 0 40px #e8b000, 0 5px 0 #a06a00;
  animation: vic-pop .9s cubic-bezier(.2, 1.6, .4, 1) both, vic-glow 1.1s ease-in-out .9s infinite alternate; }
.vic-score { margin-top: 14px; font: clamp(30px, 9vw, 56px) yodaka, monospace; color: #d8fff0; text-shadow: 0 0 16px #57ffb6; }
.vic-rank { min-height: 1.2em; margin-top: 8px; font: clamp(20px, 6vw, 34px) yodaka, monospace; color: #8db8ff; text-shadow: 0 0 14px #3d7be0; }
.vic-tap { margin-top: 30px; font: 16px yodaka, monospace; letter-spacing: .2em; color: var(--dim); animation: blink 1s steps(2, end) infinite; }
@keyframes vic-flash { from { background-color: #fff; } }
@keyframes vic-pop { from { transform: scale(.2) rotate(-14deg); opacity: 0; } to { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes vic-glow { from { transform: scale(1); text-shadow: 0 0 12px #e8e070, 0 0 40px #e8b000, 0 5px 0 #a06a00; } to { transform: scale(1.07); text-shadow: 0 0 22px #fff6a8, 0 0 70px #ffcc00, 0 5px 0 #a06a00; } }
@keyframes conf-fall { from { transform: translate3d(0, -20px, 0) rotate(0); } to { transform: translate3d(var(--x, 0), 110vh, 0) rotate(var(--r, 360deg)); } }
@keyframes spark { from { transform: translate(0, 0) scale(1); opacity: 1; } to { transform: translate(var(--dx), var(--dy)) scale(.2); opacity: 0; } }

/* あなたの顔 (勝利演出) */
.vic-face { display: block; width: clamp(90px, 26vw, 150px); height: clamp(90px, 26vw, 150px); margin: 0 auto 6px; animation: vic-bounce .7s ease-in-out infinite alternate; }
@keyframes vic-bounce { from { transform: translateY(0) rotate(-4deg); } to { transform: translateY(-14px) rotate(4deg); } }

/* ランクマッチ中に抜けるときの確認 (日本語の文) */
.leave-card p.jp { font: 700 20px/1.6 "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", Meiryo, "Noto Sans JP", sans-serif; letter-spacing: .04em; }

/* CHARACTER EDIT */
.edit-preview { display: grid; place-items: center; margin: 8px 0 14px; padding: 12px; background: radial-gradient(circle, #164a2e80, transparent 70%); }
.face.big { width: clamp(150px, 42vw, 220px); height: clamp(150px, 42vw, 220px); }
.edit-name { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; font: 20px yodaka, monospace; letter-spacing: .12em; color: #b9ecd2; }
.edit-name input { flex: 1; min-width: 0; padding: 8px 12px; border: 1px solid var(--glow); background: #06130f; color: #d8fff0; font: 24px yodaka, monospace; letter-spacing: .3em; text-transform: uppercase; }
.edit-section { margin-bottom: 16px; }
.edit-section h3 { margin: 0 0 8px; font: 20px yodaka, monospace; letter-spacing: .1em; color: #c5ecd7; }
.edit-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 7px; }
.edit-option { display: grid; place-items: center; aspect-ratio: 1; min-width: 0; padding: 4px; border: 2px solid #3b6952; background: #101b17; cursor: pointer; }
.edit-option[hidden] { display: none; }
.edit-option canvas, .edit-option img { width: 100%; height: 100%; image-rendering: pixelated; }
.edit-option img { background: #ffb985; }
.edit-option.color { border-color: #c7ffe2; }
.edit-option.selected { border-color: var(--gold); outline: 2px solid var(--gold); outline-offset: 1px; }
.edit-option:hover { border-color: #83ffbd; }

/* 表情の見本 (エディット) */
.edit-expr { display: flex; justify-content: center; gap: 8px; margin: 0 0 16px; }
.edit-expr .btn { font-family: yodaka, monospace; }
.edit-expr .btn.selected { border-color: var(--gold); color: var(--gold); }

#message.ok { color: #57ffb6; }

/* ===== 得点の演出 (盤面の上の層) ===== */
#fx { position: absolute; inset: 0; pointer-events: none; overflow: visible; z-index: 8; }
#fx.busy { pointer-events: auto; cursor: pointer; }
.fx-shake { animation: fx-shake .3s ease-out; }
@keyframes fx-shake { 0% { transform: translate(0, 0); } 20% { transform: translate(-3px, 2px); } 40% { transform: translate(3px, -2px); } 60% { transform: translate(-2px, -1px); } 80% { transform: translate(2px, 1px); } 100% { transform: translate(0, 0); } }

/* 光らせたマス */
.cell.fx-flash { position: relative; z-index: 6; animation: cell-flash .6s ease-out; }
@keyframes cell-flash {
  0% { transform: scale(1); filter: brightness(1); }
  25% { transform: scale(1.45); filter: brightness(2.6) saturate(1.4); box-shadow: 0 0 18px 6px var(--fxc, #fff), 0 0 34px 12px var(--fxc, #ffe27a); }
  100% { transform: scale(1); filter: brightness(1); box-shadow: none; }
}

/* 広がる輪・火花・浮かぶ数字 */
.fx-ring { position: absolute; border: 3px solid; border-radius: 50%; transform: translate(-50%, -50%) scale(.2); opacity: 0; animation: fx-ring .8s ease-out forwards; }
@keyframes fx-ring { 0% { opacity: 1; transform: translate(-50%, -50%) scale(.2); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(2.6); } }
.fx-spark { position: absolute; width: 7px; height: 7px; margin: -3px; border-radius: 50%; box-shadow: 0 0 8px currentColor; animation: spark .9s ease-out forwards; }
.fx-float { position: absolute; transform: translate(-50%, -50%); font-family: yodaka, monospace; white-space: nowrap; text-shadow: 0 0 10px currentColor, 0 2px 0 #000a; animation: fx-float 1.2s ease-out forwards; }
.fx-float.small { font-size: clamp(14px, 4vw, 20px); }
.fx-float.big { font-size: clamp(26px, 8vw, 40px); animation-name: fx-float-big; }
.fx-float.huge { font-size: clamp(40px, 13vw, 72px); animation-name: fx-float-big; }
@keyframes fx-float { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.6); } 15% { opacity: 1; transform: translate(-50%, -80%) scale(1.3); } 100% { opacity: 0; transform: translate(-50%, -260%) scale(1); } }
@keyframes fx-float-big { 0% { opacity: 0; transform: translate(-50%, -40%) scale(.3); } 20% { opacity: 1; transform: translate(-50%, -90%) scale(1.5); } 70% { opacity: 1; transform: translate(-50%, -130%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -220%) scale(1); } }

/* 交点: 大きなひし形がはじける */
.fx-diamond { position: absolute; box-sizing: border-box; border: 3px solid #ffe27a; background: rgba(255, 226, 122, .35); box-shadow: 0 0 16px #ffe27a; transform: translate(-50%, -50%) rotate(45deg) scale(.3); opacity: 0; animation: fx-diamond .8s ease-out forwards; }
@keyframes fx-diamond { 0% { opacity: 1; transform: translate(-50%, -50%) rotate(45deg) scale(.3); } 35% { opacity: 1; transform: translate(-50%, -50%) rotate(225deg) scale(1.3); } 100% { opacity: 0; transform: translate(-50%, -50%) rotate(405deg) scale(2.6); } }

/* 島: 外側の辺に光る線を引いて、全体を光らせる */
.fx-island { position: absolute; box-sizing: border-box; background: color-mix(in srgb, var(--c) 28%, transparent); animation: fx-island 1.5s ease-out forwards; }
.fx-island.t { border-top: 3px solid var(--c); }
.fx-island.b { border-bottom: 3px solid var(--c); }
.fx-island.l { border-left: 3px solid var(--c); }
.fx-island.r { border-right: 3px solid var(--c); }
@keyframes fx-island {
  0% { opacity: 0; filter: brightness(3); box-shadow: 0 0 0 0 var(--c); }
  15% { opacity: 1; filter: brightness(2.4); box-shadow: 0 0 22px 4px var(--c); }
  60% { opacity: 1; filter: brightness(1.4); box-shadow: 0 0 14px 2px var(--c); }
  100% { opacity: 0; filter: brightness(1); box-shadow: none; }
}

/* 数え上げの表示と、最後の合計 */
.fx-tally { position: absolute; border: 1px solid; left: 50% !important; top: 6px !important; transform: translateX(-50%); display: flex; align-items: baseline; gap: 10px; padding: 4px 14px; border: 1px solid #ffe27a; background: #020707d8; white-space: nowrap; font-family: yodaka, monospace; color: #ffe27a; z-index: 30; }
.fx-tally .tag { font-size: 13px; letter-spacing: .14em; color: var(--dim); }
.fx-tally .jp { font: 700 18px var(--kana); color: #d8fff0; }
.fx-tally b { font-size: clamp(26px, 7vw, 38px); }
.fx-tally.bump { animation: tally-bump .22s ease-out; }
@keyframes tally-bump { 0% { transform: translateX(-50%) scale(1.25); } 100% { transform: translateX(-50%) scale(1); } }
.fx-total { position: absolute; transform: translate(-50%, -50%); text-align: center; font-family: yodaka, monospace; text-shadow: 0 0 20px currentColor, 0 4px 0 #000a; animation: total-in .5s cubic-bezier(.2, 1.6, .4, 1) both; z-index: 40; }
.fx-total .tag { display: block; font-size: 16px; letter-spacing: .3em; color: var(--dim); text-shadow: none; }
.fx-total b { display: block; font-size: clamp(110px, 40vw, 240px); line-height: 1; }
.sc b.bump { animation: tally-num .25s ease-out; }
@keyframes tally-num { 0% { transform: scale(1.5); filter: brightness(2); } 100% { transform: scale(1); filter: brightness(1); } }

/* ===== スコア枠: 幅に収める (顔・名前・点数が右にはみ出さない)。名前の右の ▾ は無し ===== */
.sc .who::after, .sc.open .who::after { content: none; }
.scores { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.game-view .sc { min-width: 0; overflow: visible; padding: 4px 8px; column-gap: 6px; grid-template-columns: auto minmax(0, 1fr) auto; }
.game-view .sc .face { width: clamp(28px, 8.5vw, 40px); height: clamp(28px, 8.5vw, 40px); }
.game-view .sc .who { min-width: 0; overflow: hidden; text-overflow: ellipsis; letter-spacing: .05em; font-size: clamp(12px, 3.9vw, 18px); }
.game-view .sc b { white-space: nowrap; font-size: clamp(22px, 7.5vw, 34px); }

/* スコア枠の名前: ふつうの 1.5 倍 (枠に収まらないときは game.js の fitNames が、点数の桁数に合わせて小さくする) */
.game-view .sc .who { font-size: calc(clamp(12px, 3.9vw, 18px) * 1.5); }
.game-view .sc b { text-align: right; }

/* ===== 手番の枠の光: 黄色・金色系のグロー ===== */
/* 光は ::before の不透明度だけを動かす (枠の中の顔や数字を毎フレーム描き直さないので、ちらつかない) */
.game-view .sc.p.active, .game-view .sc.c.active { animation: none; border-color: #ffe27a; box-shadow: none; }
.game-view .sc.p.active { background: linear-gradient(145deg, #2f63b8, #1c4384); }
.game-view .sc.c.active { background: linear-gradient(145deg, #8a2e4a, #56192d); }
.game-view .sc.active::before { content: ""; position: absolute; inset: -2px; pointer-events: none; border: 2px solid #ffe27a;
  box-shadow: 0 0 12px 2px #ffe27a, 0 0 28px 6px rgba(255, 182, 46, .75), inset 0 0 14px rgba(255, 226, 122, .55); animation: gold-glow 1.4s ease-in-out infinite; }
@keyframes gold-glow { 0%, 100% { opacity: .5; } 50% { opacity: 1; } }
/* 顔のドット絵は、整数倍 (16px の 2 倍) の大きさにして、独立した層にする (半端な拡大のちらつきを防ぐ) */
.game-view .sc .face { width: 32px; height: 32px; will-change: transform; transform: translateZ(0); }

/* 最後の合計 (+14 など) を、盤面の中央に出す (アニメーションが位置の指定を上書きしないようにする) */
.fx-total { animation-name: fx-total-in; }
@keyframes fx-total-in { from { opacity: 0; transform: translate(-50%, -50%) scale(.4); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }

/* ===== 手番の枠の光: 黄色すぎないよう、白寄りのグローに。枠の輪郭線は、もとの色 (青 / 赤) のまま ===== */
.game-view .sc.p.active { border-color: #7db4ff; }
.game-view .sc.c.active { border-color: #ff7b96; }
.game-view .sc.active::before { border: none; inset: 0;
  box-shadow: 0 0 10px 2px rgba(255, 255, 255, .85), 0 0 26px 6px rgba(255, 246, 214, .6), inset 0 0 14px rgba(255, 255, 255, .4); }

/* ===== メッセージ欄は日本語: 日本語のフォントを使う ===== */
.game-view #message { font-family: ui-monospace, "Cascadia Code", Consolas, "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", Meiryo, "Noto Sans JP", sans-serif; letter-spacing: .04em; }

/* ===== PC (キーパッドを出さないとき) の WORD 入力欄: 高さと文字を 2 倍 ===== */
body:not(.keypad) .game-view #word { font-size: calc(clamp(18px, 3.2dvh, 24px) * 2); padding: 8px 20px; line-height: 1.25; }
body:not(.keypad) .game-view #word::placeholder { font-size: 36px; }
body:not(.keypad) .game-view #word:placeholder-shown { padding-left: 76px; }
body:not(.keypad) .game-view .entry:has(#word:placeholder-shown)::after { left: 28px; width: 24px; height: 56px; margin-top: -28px; }

/* 手番の枠のグロー: 白と黄色の中間 (淡い金色) */
.game-view .sc.active::before { box-shadow: 0 0 10px 2px rgba(255, 238, 176, .9), 0 0 26px 6px rgba(255, 207, 104, .62), inset 0 0 14px rgba(255, 232, 150, .45); }

/* ===== PC (キーパッドを出さないとき): 上のバーのボタンと文字を大きく / 顔のアイコンは 2 倍 ===== */
@media (min-width: 600px) { /* 幅の広い窓 (PC) だけ。狭い窓では、はみ出さないよう元の大きさのまま */
  body:not(.keypad) .game-view .match-bar { font-size: calc(clamp(14px, 2.2dvh, 18px) * 1.8); }
  body:not(.keypad) .game-view .btn { font-size: calc(clamp(14px, 2.2dvh, 18px) * 1.8); padding: calc(clamp(6px, 1.3dvh, 12px) * 1.8) 28px; }
  body:not(.keypad) .game-view #com-level { font-size: calc(clamp(16px, 2.8dvh, 22px) * 1.8); }
}
body:not(.keypad) .game-view .sc .face { width: 64px; height: 64px; }
.game-view .btn { white-space: nowrap; }
@media (min-width: 600px) { body:not(.keypad) .game-view .btn { padding-left: 22px; padding-right: 22px; } }

/* ===== スコア枠の名前と点数: どちらも、これまでの 1.5 倍 (枠に収まらなければ game.js の fitNames が --ns で小さくする) ===== */
.game-view .sc .who { font-size: calc(clamp(12px, 3.9vw, 18px) * 2.25 * var(--ns, 1)); }
.game-view .sc b { font-size: calc(clamp(22px, 7.5vw, 34px) * 1.5 * var(--ns, 1)); }

/* ===== 1ターンの最後に出る加点 (+27 など): 金色のグロー ===== */
.fx-total { text-shadow: 0 4px 0 #000a; filter: drop-shadow(0 0 28px #e8b000cc) drop-shadow(0 0 64px #e8b000aa) drop-shadow(0 0 110px #e8b00077); } /* グローは金色、文字色は自分の色を明るくしたもの (game.js が指定) */
.fx-total .tag { font-size: 22px; color: #ffe9a8; text-shadow: none; }

/* ===== メッセージ: 1行に収まらないときは、スクロールさせる ===== */
.game-view #message { text-overflow: clip; overflow: hidden; white-space: nowrap; }
.msg-text { display: inline-block; white-space: nowrap; will-change: transform; }

/* ===== 試合が終わったら、WORD 入力欄とフリックのキーは暗くして、入力できなくする ===== */
.game-view.over .entry, .game-view.over .kana-pad { opacity: .3; filter: brightness(.55) saturate(.6); pointer-events: none; transition: opacity .6s, filter .6s; }
.game-view.over .entry::after { display: none; }
#word:disabled { cursor: not-allowed; }
/* PC のキーボード操作: マス選択のカーソル (金色=選択中、緑=位置を決めた) と、入力途中のローマ字 */
.cell.kb-cur { position: relative; z-index: 5; outline: 3px solid #ffe27a; outline-offset: -3px; box-shadow: 0 0 14px #ffe27acc; }
.cell.kb-anchor { position: relative; z-index: 5; outline: 3px solid #57ffb6; outline-offset: -3px; box-shadow: 0 0 16px #57ffb6cc; animation: blink 1s steps(2, end) infinite; }
.roma-buf { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font: 24px yodaka, monospace; letter-spacing: .1em; color: #ffe27a; pointer-events: none; }
/* ランクマッチが終わったら、フリックのキーと入力欄は消して、NEXT MATCH のボタンを出す */
.next-match { display: none; }
.game-view.rank-over .kana-pad, body.keypad .game-view.rank-over .kana-pad, .game-view.rank-over .entry { display: none; }
.game-view.rank-over .next-match { display: block; margin: 12px 0; padding: 18px 8px; font-size: 24px; letter-spacing: .06em; white-space: nowrap; border-color: #57ffb6; background: linear-gradient(180deg, #1f6a4c, #14503a); color: #f2fff9; text-shadow: 0 0 10px #57ffb6aa; box-shadow: 0 0 18px #2bd98b77, inset 0 0 14px #57ffb644; }

/* ===== ランクマッチ: 順位表の部分だけスクロールする ===== */
.rank-view:not([hidden]) { display: flex; flex-direction: column; height: calc(100vh - 64px); height: calc(100dvh - 64px); }
.rank-list { position: relative; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.rank-list { scrollbar-width: none; -ms-overflow-style: none; cursor: grab; touch-action: pan-y; -webkit-overflow-scrolling: touch; }
.rank-list::-webkit-scrollbar { display: none; }
.rank-list.dragging { cursor: grabbing; user-select: none; }

/* ゆらゆら落ちる紙: 落下 + 左右の揺れ + ひらひら裏返る */
.flut { position: absolute; top: -40px; border-radius: 2px; opacity: .92;
  animation-name: flut-fall, flut-sway, flut-flip; animation-timing-function: linear, ease-in-out, ease-in-out; animation-iteration-count: infinite, infinite, infinite; animation-direction: normal, alternate, alternate; }
@keyframes flut-fall { from { translate: 0 -20px; } to { translate: 0 112vh; } }
@keyframes flut-sway { from { margin-left: calc(var(--sway, 40px) * -1); } to { margin-left: var(--sway, 40px); } }
@keyframes flut-flip { from { transform: rotateX(0) rotateZ(-25deg); } to { transform: rotateX(180deg) rotateZ(25deg); } }

/* ===== ボタンの背景を、少し明るく ===== */
.btn, .help-button { background: #153629; }
.btn:hover, .help-button:hover, .help-button:focus-visible { background: #24604a; }
.level-choice { background: linear-gradient(145deg, #1f4535, #12302a); box-shadow: inset 0 0 0 1px #135a3e, 0 8px 28px #0009; }
.fkey, .akey { background: linear-gradient(145deg, #1f4535, #12302a); box-shadow: inset 0 0 0 1px #135a3e; }
.fkey.down { background: #24604a; }
.fkey.down .fg { background: #1a4a38; }
.fkey.down .fg.c { background: #24604a; }
.fkey.down .fg.sel { background: #57ffb6; }
.rank-row { background: #102a21; }
button.rank-row:hover, button.rank-row:focus-visible { background: #24604a; }

/* ===== ボタン: 背景は少し暗く・わずかに黄緑寄りで彩度高め、輪郭は明るく ===== */
.btn, .help-button { background: #123d22; border-color: #4fe08a; }
.btn:hover, .help-button:hover, .help-button:focus-visible { background: #1f6130; border-color: #a6ffc9; }
.level-choice { background: linear-gradient(145deg, #1a4b27, #0f351f); border-color: #4fe08a; box-shadow: inset 0 0 0 1px #2f9a5a, 0 8px 28px #0009; }
.level-choice:hover, .level-choice:focus-visible { border-color: #a6ffc9; }
.fkey, .akey { background: linear-gradient(145deg, #1a4b27, #0f351f); border-color: #4fe08a; box-shadow: inset 0 0 0 1px #2f9a5a; }
.akey.del { border-color: #ff7d8f; }
.fkey.down { background: #1f6130; border-color: #a6ffc9; }
.fkey.down .fg { background: #165028; border-color: #a6ffc9; }
.fkey.down .fg.c { background: #1f6130; }
.fkey.down .fg.sel { background: #57ffb6; }
.rank-row { background: #0e3019; border-color: #3fbf75; }
button.rank-row:hover, button.rank-row:focus-visible { background: #1f6130; border-color: #a6ffc9; }

/* ===== ボタンの背景を、ほんの少し暗く ===== */
.btn, .help-button { background: #0f3520; }
.btn:hover, .help-button:hover, .help-button:focus-visible { background: #1b562b; }
.level-choice, .fkey, .akey { background: linear-gradient(145deg, #164222, #0c2e1b); }
.fkey.down { background: #1b562b; }
.fkey.down .fg { background: #134624; }
.fkey.down .fg.c { background: #1b562b; }
.fkey.down .fg.sel { background: #57ffb6; }
.rank-row { background: #0b2a16; }
button.rank-row:hover, button.rank-row:focus-visible { background: #1b562b; }

/* ===== マウスを乗せたとき: はっきり明るく、まわりに少しグロー ===== */
@media (hover: hover) {
  .btn:hover, .help-button:hover, button.rank-row:hover, .akey:hover { background: #2f8a45; border-color: #d2ffe2; color: #fff; box-shadow: 0 0 14px #4fe08a99, 0 0 30px #2fc16a55, inset 0 0 0 1px #8dffb4; }
  .level-choice:hover { background: linear-gradient(145deg, #2f8a45, #1d6a32); border-color: #d2ffe2; box-shadow: 0 0 16px #4fe08aaa, 0 0 38px #2fc16a66, inset 0 0 0 1px #8dffb4; }
  .akey.del:hover { border-color: #ffb3bf; box-shadow: 0 0 14px #ff7d8f99, 0 0 30px #ff506b55, inset 0 0 0 1px #ffb3bf; }
}

/* ===== ホバーのグローは金色系 ===== */
@media (hover: hover) {
  .btn:hover, .help-button:hover, button.rank-row:hover, .akey:hover, .akey.del:hover { border-color: #ffe9a0; box-shadow: 0 0 14px #ffe27aaa, 0 0 30px #ffb62e66, inset 0 0 0 1px #ffe27a99; }
  .level-choice:hover { border-color: #ffe9a0; box-shadow: 0 0 16px #ffe27acc, 0 0 38px #ffb62e77, inset 0 0 0 1px #ffe27a99; }
}

/* ===== ホバー: 輪郭は明るい緑、グローは金色で控えめ ===== */
@media (hover: hover) {
  .btn:hover, .help-button:hover, button.rank-row:hover, .akey:hover, .akey.del:hover { border-color: #d2ffe2; box-shadow: 0 0 8px #ffe27a77, 0 0 18px #ffb62e33, inset 0 0 0 1px #8dffb4; }
  .level-choice:hover { border-color: #d2ffe2; box-shadow: 0 0 10px #ffe27a77, 0 0 22px #ffb62e33, inset 0 0 0 1px #8dffb4; }
}

/* ===== タイトル両脇のひし形: 交点のひし形 (金色の細い線でゆっくり回る) と同じ。大きさは 1.5 倍 ===== */
.brand .gem { position: relative; width: 21px; height: 21px; background: none; box-shadow: none; transform: none; animation: gem-spin 7s linear infinite; }
.brand .gem::before { content: ""; position: absolute; inset: 0; box-sizing: border-box; border: 2px solid #e8e070; transform: rotate(45deg); }

/* ===== ホバーのグロー: もう少しだけ強く ===== */
@media (hover: hover) {
  .btn:hover, .help-button:hover, button.rank-row:hover, .akey:hover, .akey.del:hover { box-shadow: 0 0 10px #ffe27a99, 0 0 24px #ffb62e55, inset 0 0 0 1px #8dffb4; }
  .level-choice:hover { box-shadow: 0 0 12px #ffe27a99, 0 0 28px #ffb62e55, inset 0 0 0 1px #8dffb4; }
}

/* ===== タイトルのひし形: さらに 1.8 倍、文字から少し離す。字間の余白 (最後の X の右) を打ち消して左右の距離をそろえる ===== */
.brand { gap: 24px; }
.brand h1 { margin-right: -.08em; color: #f2fff9; text-shadow: 0 0 10px #57ffb6aa, 0 0 26px #2bd98b99; } /* タイトルを明るく */
.brand .gem { width: 38px; height: 38px; }

/* ===== タイトルのひし形は 7 割の大きさ (左右は同じ角度で回る) / RANK MATCH ボタンは高く、EASY〜ANY は低く ===== */
.brand .gem { width: 27px; height: 27px; }
.level-choice { min-height: 56px; padding-block: 12px; }
.level-choice[data-level="rank"] { min-height: 82px; padding-block: 20px; }

/* ===== ボタンの高さ: RANK MATCH をさらに高く、EASY〜ANY をさらに低く / タイトルとボタンの間を広げる ===== */
.level-choice { min-height: 50px; padding-block: 10px; }
.level-choice[data-level="rank"] { min-height: 94px; padding-block: 24px; }
.title-view .brand, .brand { margin-bottom: 36px; }

/* ===== MATCH START: 高さ 1.5 倍、両側に回るひし形 ===== */
#rank-start { position: relative; padding-block: calc(13px * 1.5 + 5px); }
#rank-start::before, #rank-start::after { content: ""; position: absolute; top: 50%; width: 22px; height: 22px; margin-top: -11px; box-sizing: border-box; border: 2px solid #e8e070; transform: rotate(45deg); }
#rank-start::before { left: 18px; } #rank-start::after { right: 18px; }
#rank-start::before, #rank-start::after { animation: gem-spin45 7s linear infinite; }
@keyframes gem-spin45 { from { transform: rotate(45deg); } to { transform: rotate(405deg); } }

/* ランクのまとめ: 1行目 RANK / RATING、2行目 WIN / LOSE / DRAW (1行に収まらなければ折り返す) */
.rank-summary span { display: block; }
/* 自分の行を見やすく: 明るい青の背景、白い文字 */
.rank-list li.me .rank-row { border-color: #cfe0ff; background: #2f63c9; color: #fff; box-shadow: 0 0 14px #5b8dff88; }
.rank-list li.me .rank-row .rk, .rank-list li.me .rank-row .rt { color: #e6efff; }

/* MATCH START のひし形: 文字のすぐ脇に置く (ボタンの両端ではなく)。大きさは 1.2 倍 */
#rank-start { display: flex; align-items: center; justify-content: center; gap: 26px; }
#rank-start::before, #rank-start::after { position: static; flex: none; width: 26px; height: 26px; margin: 0; }

/* MATCH START の文字を大きく */
#rank-start { font-size: 30px; }

/* タイトルと MATCH START 脇のひし形: 3 割大きく、少しグローを付ける */
.brand .gem { width: 35px; height: 35px; }
.brand .gem::before { box-shadow: 0 0 8px #e8e070aa, inset 0 0 6px #e8e07066; }
#rank-start::before, #rank-start::after { width: 34px; height: 34px; box-shadow: 0 0 8px #e8e070aa, inset 0 0 6px #e8e07066; }

/* ===== 対戦前の紹介: 左上にあなた、右下に相手 ===== */
.vs-intro { position: fixed; z-index: 70; inset: 0; display: grid; grid-template: 1fr 1fr 1fr / 1fr; padding: 4vmin 5vmin; cursor: pointer; overflow: hidden;
  background: radial-gradient(ellipse at 50% 50%, #12301f 0, #050a0b 75%); }
.vs-intro[hidden] { display: none; }
.vs-intro::before { content: ""; position: absolute; left: -20%; right: -20%; top: 50%; height: 3px; background: linear-gradient(90deg, transparent, #e8e070, transparent); transform: rotate(-24deg); box-shadow: 0 0 18px #e8e070; }
.vs-side { display: flex; flex-direction: column; gap: 6px; max-width: 100%; }
.vs-you { grid-row: 1; align-items: flex-start; text-align: left; }
.vs-com { grid-row: 3; align-items: flex-end; text-align: right; }
.vs-intro .face.big { width: clamp(110px, 34vw, 200px); height: clamp(110px, 34vw, 200px); }
.vs-name { font: clamp(34px, 11vw, 72px)/1.05 yodaka, monospace; letter-spacing: .06em; overflow-wrap: anywhere; }
.vs-you .vs-name { color: #c4dbff; text-shadow: 0 0 18px #3d7be0; }
.vs-com .vs-name { color: #ffc2cd; text-shadow: 0 0 18px #e0476a; }
.vs-info { font: clamp(16px, 4.6vw, 26px) yodaka, monospace; letter-spacing: .08em; color: #d8fff0; }
.vs-mid { grid-row: 2; align-self: center; justify-self: center; text-align: center; position: relative; }
.vs-vs { font: clamp(70px, 24vw, 150px)/1 yodaka, monospace; color: #fff6a8; text-shadow: 0 0 12px #e8e070, 0 0 40px #e8b000, 0 5px 0 #a06a00; }
.vs-rec { margin-top: 6px; font: clamp(18px, 5.4vw, 30px) yodaka, monospace; letter-spacing: .08em; color: #fff; text-shadow: 0 0 10px #000; }
.vs-rec small { display: block; font-size: .62em; letter-spacing: .2em; color: #e8e070; }
.vs-intro.go .vs-you { animation: vs-in-l .55s cubic-bezier(.2, 1.1, .3, 1) both; }
.vs-intro.go .vs-com { animation: vs-in-r .55s cubic-bezier(.2, 1.1, .3, 1) .2s both; }
.vs-intro.go .vs-mid { animation: vs-pop .5s cubic-bezier(.2, 1.6, .4, 1) .45s both; }
@keyframes vs-in-l { from { transform: translate(-60vw, -20vh); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes vs-in-r { from { transform: translate(60vw, 20vh); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes vs-pop { from { transform: scale(.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* 対戦前の紹介: 斜めの線は無し / 上は左から、下は右から横に入る / VS は 6 割の大きさでグロー弱め */
.vs-intro::before { display: none; }
@keyframes vs-in-l { from { transform: translateX(-70vw); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes vs-in-r { from { transform: translateX(70vw); opacity: 0; } to { transform: none; opacity: 1; } }
.vs-vs { font-size: clamp(42px, 14.4vw, 90px); text-shadow: 0 0 6px #e8e070aa, 0 0 18px #e8b00066, 0 3px 0 #a06a00; }

/* 左側のキャラ (YOU) は、対戦前の紹介で左右反転して、相手のほうを向かせる */
#vs-you-face { scale: -1 1; }

/* キャラエディットの選択肢: 髪の色が暗いと見えないので、背景を明るく */
.edit-option { background: #6f9684; border-color: #9fd0b8; }
.edit-option.color { border-color: #e4fff1; }
.edit-option:hover { border-color: #fff; }
.edit-option { background: #384b42; border-color: #6a9c84; }
.edit-option { background: #2a5a42; border-color: #4fbf8a; }

/* ===== 勝った方のスコア枠: 金色の光が脈打ち、まわりでキラキラが光る ===== */
.game-view .sc.winner { border-color: #ffe27a; animation: win-pulse 1.4s ease-in-out infinite; }
@keyframes win-pulse {
  0%, 100% { box-shadow: 0 0 8px 1px rgba(255, 226, 122, .7), 0 0 20px 4px rgba(255, 182, 46, .4); }
  50% { box-shadow: 0 0 16px 4px rgba(255, 238, 176, .95), 0 0 42px 12px rgba(255, 182, 46, .6); }
}
.win-stars { position: absolute; inset: 0; pointer-events: none; }
.win-stars i { position: absolute; width: var(--s); height: var(--s); margin: calc(var(--s) / -2);
  background: #fff6c8; box-shadow: 0 0 8px 2px #ffe27a; clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  opacity: 0; animation: win-star 1.8s ease-in-out var(--d) infinite; }
@keyframes win-star { 0%, 100% { opacity: 0; scale: .2; rotate: 0deg; } 45% { opacity: 1; scale: 1.2; rotate: 90deg; } 70% { opacity: .7; scale: .8; } }

/* ===== ランクマッチ: HISTORY ボタン (右上) と対戦履歴 ===== */
.rank-view .match-bar, .history-view .match-bar { justify-content: space-between; }
.history-list { cursor: default; }
.hist-row { grid-template-columns: 2.4em 40px 1fr auto auto auto; }
.hist-row .hres { font-size: 16px; letter-spacing: .08em; }
.hist-row .hres.win { color: #ffe27a; } .hist-row .hres.lose { color: var(--red-text); } .hist-row .hres.draw { color: #b4d8c8; }
.hist-row .hd { color: var(--dim); font-size: 13px; }

/* ===== 1ターンの最後の合計: 文字は自分の色の濃い色。グローは白寄りで明るく、文字の上にも少し乗せる ===== */
.fx-total { text-shadow: 0 0 6px #fff, 0 0 16px #fffbe6, 0 0 36px #ffeeb0, 0 0 66px rgba(255, 222, 130, .8), 0 4px 0 #0008; }
.fx-total b { position: relative; }
.fx-total b::after { content: ""; position: absolute; inset: -8% -16%; pointer-events: none;
  background: radial-gradient(ellipse at 50% 50%, rgba(255, 255, 255, .3) 0, rgba(255, 250, 220, .12) 48%, transparent 72%); }
.hist-row .rt, .hist-row .hres, .hist-row .hd { white-space: nowrap; } .hist-row .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* 合計のグロー: 半分の強さ */
.fx-total { text-shadow: 0 0 4px rgba(255, 255, 255, .6), 0 0 10px rgba(255, 251, 230, .5), 0 0 22px rgba(255, 238, 176, .45), 0 0 40px rgba(255, 222, 130, .4), 0 4px 0 #0008; }
.fx-total b::after { background: radial-gradient(ellipse at 50% 50%, rgba(255, 255, 255, .15) 0, rgba(255, 250, 220, .06) 48%, transparent 72%); }

/* 合計のグロー: 文字の上に乗せる光は明るく、後ろのにじみはもう少し抑える */
.fx-total { text-shadow: 0 0 3px rgba(255, 255, 255, .45), 0 0 8px rgba(255, 251, 230, .35), 0 0 18px rgba(255, 238, 176, .3), 0 0 32px rgba(255, 222, 130, .25), 0 4px 0 #0008; }
.fx-total b::after { background: radial-gradient(ellipse at 50% 45%, rgba(255, 255, 255, .5) 0, rgba(255, 252, 230, .26) 50%, transparent 74%); }

/* 合計のグロー: ピカッと鋭く。外へ広がるぼんやりしたにじみは狭く */
.fx-total { text-shadow: 0 0 2px #fff, 0 0 6px rgba(255, 255, 255, .85), 0 0 12px rgba(255, 238, 170, .65), 0 0 20px rgba(255, 214, 110, .35), 0 4px 0 #0008; }
.fx-total b::after { inset: -4% -8%; background: radial-gradient(ellipse at 50% 42%, rgba(255, 255, 255, .6) 0, rgba(255, 252, 230, .28) 45%, transparent 70%); }
.fx-total { animation: fx-total-in .5s cubic-bezier(.2, 1.6, .4, 1) both, fx-total-flash .55s ease-out both; }
@keyframes fx-total-flash { 0% { filter: brightness(2.4) saturate(.6); } 100% { filter: none; } }
/* 履歴の行: 狭い画面でも相手の名前が入るよう、文字と間隔を詰める */
.hist-row { grid-template-columns: 1.8em 32px minmax(0, 1fr) auto auto auto; gap: 6px; padding: 4px 6px; font-size: 16px; letter-spacing: .02em; }
.hist-row .hres { font-size: 13px; letter-spacing: .02em; }
.hist-row .rt { font-size: 13px; }
.hist-row .hd { font-size: 11px; }
.hist-row .face { width: 32px; height: 32px; }
.hist-row .hres .you { color: #8db8ff; font-weight: normal; }
.hist-row .hres .win, .hist-row .rt.win { color: #ffe27a; }
.hist-row .hres .lose, .hist-row .rt.lose { color: var(--red-text); }
.hist-row .hres .draw, .hist-row .rt.draw { color: #b4d8c8; }
.hist-row .hres.win { color: #ffe27a; } .hist-row .hres.lose { color: var(--red-text); } .hist-row .hres.draw { color: #b4d8c8; }
#com-level.rank { color: #ffe27a; text-shadow: 0 0 8px rgba(255, 226, 122, .55); }
#com-level { color: #ffe27a; text-shadow: 0 0 8px rgba(255, 226, 122, .55); }

/* ===== スマホ: UI 以外をドラッグしても、文字が選択されたり画面がずれたりしないようにする ===== */
html, body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
input, textarea { -webkit-user-select: text; user-select: text; } /* 入力欄では選べる */
body.in-game, html:has(body.in-game) { overflow: hidden; } /* 対局中は画面そのものを動かさない */
body.in-game { touch-action: manipulation; }
img, canvas { -webkit-user-drag: none; user-drag: none; }

/* ===== 単語の意味 (画面中央のウィンドウ) ===== */
.word-info { position: fixed; z-index: 80; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .6); }
.word-info[hidden] { display: none; }
.wi-card { position: relative; width: min(100%, 480px); max-height: min(80dvh, 560px); overflow-y: auto; padding: 18px 18px 14px; border: 2px solid #4fe08a; background: #0a2417; box-shadow: 0 0 24px #000c, 0 0 18px #2bd98b44; -webkit-user-select: text; user-select: text; }
.wi-close { position: absolute; top: 6px; right: 6px; width: 40px; height: 40px; padding: 0; border: 1px solid #4fe08a; background: #123d22; color: #d8fff0; font: 700 26px/1 var(--kana); }
.wi-close:hover { background: #2f8a45; border-color: #d2ffe2; }
.wi-body { padding-right: 36px; }
.wi-body section + section { margin-top: 14px; padding-top: 12px; border-top: 1px solid #2f6a4a; }
.wi-body h3 { margin: 0 0 6px; font: 28px yodaka, monospace; letter-spacing: .08em; color: #ffe27a; }
.wi-def { font: 16px/1.6 var(--kana); color: #e8fff4; }
.wi-def p { margin: 0 0 4px; }
.wi-def.none { color: #9bbfae; }
.wi-def a, .wi-credit a { color: #8dffb4; }
.wi-def a { display: inline-block; margin-top: 6px; font-size: 14px; }
.wi-credit { margin: 12px 0 0; font-size: 11px; color: #78ad98; }
.wi-note { color: #9bbfae; font-size: 13px; }
