/* 将棋：濃い木の色・金・榧の木目。ガラス調のパネルと五角形の駒 */
:root {
  --bg0: #1a0f07;
  --bg1: #2b190c;
  --bg2: #4a2d17;
  --ink: #f8eedb;
  --ink-dim: #d6c4a8;
  --ink-faint: #a58f70;
  --gold: #e0bd78;
  --gold-hi: #f7e3b0;
  --gold-lo: #a67f36;
  --glass: rgba(255, 255, 255, 0.055);
  --glass-hi: rgba(255, 255, 255, 0.09);
  --line: rgba(255, 255, 255, 0.13);
  --line-gold: rgba(224, 189, 120, 0.45);
  --wood-hi: #8a5a30;
  --wood-lo: #4a2a14;
  --kaya-hi: #f3d493;
  --kaya-lo: #d9a95b;
  --piece-ink: #2a1708;
  --piece-red: #c1272d;
  --radius: 18px;
  --f-serif: "Shippori Mincho", "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", serif;
  --f-sans: "Zen Kaku Gothic New", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
  --f-latin: "Cormorant Garamond", "Times New Roman", serif;
  /* 数字は「1」「0」がはっきり読める書体（Cormorant は古い字形で 1 が I、0 が o に見える） */
  --f-num: "Zen Kaku Gothic New", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  color: var(--ink);
  font-family: var(--f-sans);
  font-size: 16px;
  line-height: 1.7;
  background: var(--bg0);
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  font-variant-numeric: lining-nums tabular-nums;
}
button, select, input { font: inherit; color: inherit; }
a { color: var(--gold); }
h1, h2, h3, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

/* ---------------------------------------------------------------- 背景 */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: radial-gradient(120% 90% at 50% 0%, var(--bg2) 0%, var(--bg1) 45%, var(--bg0) 100%); }
.bg-glow { position: absolute; border-radius: 50%; filter: blur(70px); opacity: 0.55; }
.bg-glow.g1 { width: 56vmax; height: 56vmax; left: -18vmax; top: -22vmax; background: radial-gradient(circle, rgba(224, 189, 120, 0.32), transparent 65%); }
.bg-glow.g2 { width: 60vmax; height: 60vmax; right: -24vmax; bottom: -26vmax; background: radial-gradient(circle, rgba(190, 115, 50, 0.45), transparent 65%); }
.bg-grain {
  position: absolute; inset: 0; opacity: 0.16; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 .55 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* ---------------------------------------------------------------- 上の帯 */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  max-width: 1120px; width: 100%; margin: 0 auto; padding: 14px 16px 6px;
}
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand-mark { position: relative; width: 44px; height: 44px; flex: none; border-radius: 12px; background: linear-gradient(145deg, var(--wood-hi), var(--wood-lo)); box-shadow: 0 0 0 1px var(--line-gold), 0 6px 16px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.25); }
.bm-pc { position: absolute; left: 50%; top: 50%; width: 26px; height: 30px; margin: -15px 0 0 -13px; display: grid; place-items: center; clip-path: polygon(50% 0, 90% 18%, 100% 100%, 0 100%, 10% 18%); background: linear-gradient(160deg, #f6dca0, #dcae62); box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5); }
.bm-pc b { font-family: var(--f-serif); font-weight: 800; font-size: 15px; line-height: 1; color: var(--piece-ink); margin-top: 7px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text b { font-family: var(--f-serif); font-size: 22px; letter-spacing: 0.12em; font-weight: 700; }
.brand-text small { font-family: var(--f-latin); font-size: 13px; letter-spacing: 0.28em; color: var(--gold); text-transform: uppercase; }

.top-right { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; min-width: 0; }
.snd { display: flex; gap: 8px; }
.snd-btn {
  appearance: none; display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 6px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line-gold); background: rgba(224, 189, 120, 0.16); color: var(--gold-hi); font-size: 13px; font-weight: 700; line-height: 1;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.snd-btn:hover { background: rgba(224, 189, 120, 0.26); }
.snd-btn:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; }
.snd-btn svg { flex: none; }
.snd-btn .slash { opacity: 0; }
.snd-state { font-family: var(--f-sans); font-size: 12px; padding: 3px 8px; border-radius: 999px; background: var(--gold); color: #2a1c05; }
.snd-btn[aria-pressed="false"] { border-color: var(--line); background: var(--glass); color: var(--ink-faint); }
.snd-btn[aria-pressed="false"] .slash { opacity: 1; }
.snd-btn[aria-pressed="false"] .ic { opacity: 0.6; }
.snd-btn[aria-pressed="false"] .snd-state { background: rgba(255, 255, 255, 0.12); color: var(--ink-faint); }
.btn-logout { white-space: normal; line-height: 1.3; min-width: 0; flex: 0 1 auto; }

.me {
  display: flex; align-items: center; gap: 10px; min-width: 0; max-width: 100%;
  padding: 6px 8px 6px 16px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--line-gold);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.me-label { font-size: 12px; color: var(--ink-faint); white-space: nowrap; }
.me-name { font-family: var(--f-serif); font-weight: 700; font-size: 17px; color: var(--gold-hi); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- 全体の枠 */
.stage { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 10px 16px 28px; }
.foot { display: flex; justify-content: center; gap: 18px; padding: 14px 16px 22px; font-size: 13px; color: var(--ink-faint); flex-wrap: wrap; }
.foot a { color: var(--ink-dim); }

/* ---------------------------------------------------------------- ボタン */
.btn {
  appearance: none; border: 1px solid var(--line); cursor: pointer; text-align: center;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; min-height: 44px; border-radius: 999px; font-weight: 700; letter-spacing: 0.04em;
  background: var(--glass-hi); color: var(--ink);
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease, opacity 0.2s;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:focus-visible, select:focus-visible, .cell:focus-visible, .seg input:focus-visible + span { outline: 2px solid var(--gold-hi); outline-offset: 2px; }
.btn-sm { min-height: 36px; padding: 6px 14px; font-size: 14px; }
.btn-lg { min-height: 52px; padding: 12px 28px; font-size: 17px; }
.btn-block { display: flex; width: 100%; }
.btn-gold {
  color: #2a1c05; border-color: rgba(255, 244, 205, 0.7);
  background: linear-gradient(180deg, var(--gold-hi) 0%, var(--gold) 52%, var(--gold-lo) 100%);
  box-shadow: 0 8px 22px rgba(166, 127, 54, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
.btn-gold:hover:not(:disabled) { box-shadow: 0 10px 28px rgba(224, 189, 120, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.8); }
.btn-primary { border-color: var(--line-gold); background: linear-gradient(180deg, rgba(224, 189, 120, 0.22), rgba(224, 189, 120, 0.1)); color: var(--gold-hi); }
.btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, rgba(224, 189, 120, 0.34), rgba(224, 189, 120, 0.16)); }
.btn-quiet { background: var(--glass); color: var(--ink-dim); }
.btn-quiet:hover:not(:disabled) { background: var(--glass-hi); color: var(--ink); }

/* ---------------------------------------------------------------- パネル・入力 */
.panel {
  position: relative; padding: 20px 20px 22px; border-radius: var(--radius);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.035));
  border: 1px solid var(--line);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.panel h2 { font-family: var(--f-serif); font-size: 21px; letter-spacing: 0.1em; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.panel h2::before { content: ""; width: 5px; height: 20px; border-radius: 3px; background: linear-gradient(var(--gold-hi), var(--gold-lo)); }
.count { font-family: var(--f-num); font-weight: 700; font-size: 17px; color: var(--gold-hi); }
.hint-line { font-size: 14px; color: var(--ink-dim); margin-bottom: 12px; }
.empty { padding: 18px 8px; text-align: center; color: var(--ink-faint); font-size: 14px; }
.fine { margin-top: 10px; font-size: 14px; color: #ffb4a0; }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.field > span { font-size: 12px; letter-spacing: 0.1em; color: var(--ink-faint); }
select {
  appearance: none; -webkit-appearance: none; width: 100%; min-height: 48px; padding: 10px 40px 10px 14px; border-radius: 12px;
  border: 1px solid var(--line); font-size: 16px; font-weight: 500; cursor: pointer; color: var(--ink);
  background-color: rgba(26, 15, 7, 0.72);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'><path d='M1 1.5l6 6 6-6' fill='none' stroke='%23e0bd78' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat; background-position: right 14px center;
}
select option { background: #2b190c; color: var(--ink); }
select:hover { border-color: var(--line-gold); }

/* ---------------------------------------------------------------- ログイン */
.hero { text-align: center; padding: 26px 0 22px; }
.hero-title {
  font-family: var(--f-serif); font-weight: 700; letter-spacing: 0.22em; font-size: clamp(44px, 12vw, 76px); line-height: 1.15;
  background: linear-gradient(180deg, #fff6d9 0%, var(--gold) 55%, var(--gold-lo) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent;
  text-shadow: none; filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.45));
  display: flex; flex-direction: column; align-items: center;
}
.hero-title span { font-size: clamp(14px, 3.6vw, 20px); letter-spacing: 0.5em; margin-top: 6px; font-weight: 500; padding-left: 0.5em; }
.hero-lead { margin-top: 14px; color: var(--ink-dim); font-size: 15px; }
.login-panel { max-width: 540px; margin: 0 auto; padding: 24px 22px 26px; }
.step { display: flex; align-items: center; gap: 10px; font-weight: 700; margin: 4px 0 12px; font-size: 15px; }
.step b { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: linear-gradient(var(--gold-hi), var(--gold-lo)); color: #2a1c05; font-family: var(--f-num); font-size: 15px; }
.select-row { display: flex; gap: 12px; }
.name-preview {
  margin: 16px 0 22px; padding: 14px 12px; text-align: center; border-radius: 14px;
  background: rgba(0, 0, 0, 0.28); border: 1px dashed var(--line-gold);
}
.name-preview > span { display: block; font-size: 12px; color: var(--ink-faint); letter-spacing: 0.12em; }
.name-preview b { display: block; font-family: var(--f-serif); font-size: clamp(26px, 7vw, 34px); letter-spacing: 0.1em; color: var(--gold-hi); line-height: 1.3; overflow-wrap: anywhere; }
.feature-list { margin-top: 22px; display: grid; gap: 8px; }
.feature-list li { font-size: 14px; color: var(--ink-dim); padding: 8px 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.04); display: flex; gap: 10px; align-items: baseline; }
.feature-list b { color: var(--gold); min-width: 4.4em; font-family: var(--f-serif); }

/* ---------------------------------------------------------------- 待合 */
.lobby { display: grid; gap: 18px; padding-top: 10px; }
.lb-players, .lb-center { display: grid; gap: 18px; align-content: start; min-width: 0; }
.lb-board { min-width: 0; }
.lobby-hero { display: none; }
@media (min-width: 900px) {
  .lobby { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); grid-template-areas: "pl bd" "ce bd"; align-items: start; }
  .lb-players { grid-area: pl; }
  .lb-center { grid-area: ce; }
  .lb-board { grid-area: bd; }
}
.player-list { display: grid; align-content: start; gap: 10px; max-height: 420px; overflow-y: auto; padding-right: 2px; }
.player {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 12px; border-radius: 14px; cursor: pointer;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line);
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}
.player:hover:not(.is-busy) { border-color: var(--line-gold); background: rgba(224, 189, 120, 0.08); transform: translateY(-1px); }
.player.is-busy { cursor: default; opacity: 0.75; }
.avatar { flex: none; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-family: var(--f-serif); font-weight: 700; font-size: 19px; color: #2a1c05; background: linear-gradient(145deg, var(--gold-hi), var(--gold-lo)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 3px 8px rgba(0, 0, 0, 0.4); }
.p-info { flex: 1 1 9em; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.p-nm { font-family: var(--f-serif); font-size: 17px; letter-spacing: 0.06em; max-width: 100%; white-space: normal; overflow-wrap: anywhere; line-height: 1.35; }
.chip { white-space: nowrap; font-size: 12px; padding: 1px 10px; border-radius: 999px; border: 1px solid; line-height: 1.6; }
.chip-idle { color: #9fe5bd; border-color: rgba(120, 220, 160, 0.45); background: rgba(60, 170, 110, 0.14); }
.chip-game { color: #ffd59a; border-color: rgba(255, 190, 100, 0.45); background: rgba(230, 150, 40, 0.14); }
.chip-cpu { color: #b9cbff; border-color: rgba(150, 175, 255, 0.45); background: rgba(100, 130, 240, 0.14); }
.p-btn { flex: none; }

.cpu-grid { display: grid; gap: 14px; margin-bottom: 16px; }
.seg { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg legend { padding: 0; width: 100%; font-size: 12px; letter-spacing: 0.1em; color: var(--ink-faint); margin-bottom: 6px; float: left; }
.seg label { position: relative; flex: 1 1 0; min-width: 0; }
.seg input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.seg span {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 8px 10px; text-align: center; white-space: nowrap; border-radius: 12px; font-weight: 700; font-size: 15px;
  background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line); color: var(--ink-dim); transition: all 0.2s;
}
.seg input:checked + span { color: #2a1c05; background: linear-gradient(180deg, var(--gold-hi), var(--gold)); border-color: rgba(255, 244, 205, 0.7); box-shadow: 0 6px 16px rgba(166, 127, 54, 0.3); }
.mk { font-style: normal; font-family: var(--f-serif); font-weight: 800; font-size: 1.15em; line-height: 1; color: var(--gold); flex: none; }
.seg input:checked + span .mk { color: #2a1c05; }

.post-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 8px; }
.post-form .field:first-child { flex: 2 1 200px; }
.post-form .field { flex: 1 1 130px; }
.post-form .btn { flex: 0 0 auto; min-height: 48px; }
.post-list { display: grid; align-content: start; gap: 6px; margin-top: 12px; max-height: 380px; overflow-y: auto; padding-right: 2px; }
.post { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 10px; align-items: baseline; padding: 9px 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.045); border-left: 3px solid var(--gold-lo); }
.post-name { font-family: var(--f-serif); font-weight: 700; color: var(--gold-hi); font-size: 14px; white-space: normal; overflow-wrap: anywhere; }
.post-text { font-size: 15px; min-width: 0; overflow-wrap: break-word; word-break: normal; }
@supports (word-break: auto-phrase) { .post-text { word-break: auto-phrase; } }
.post-time { font-family: var(--f-num); font-size: 13px; color: var(--ink-faint); white-space: nowrap; }
@media (max-width: 420px) {
  .post { grid-template-columns: 1fr auto; }
  .post-text { grid-column: 1 / -1; grid-row: 2; }
}

/* ---------------------------------------------------------------- 対戦 */
.game { display: grid; gap: 14px; justify-items: center; padding-top: 8px; }
.game-top { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pcard {
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 10px; padding: 10px 14px; min-width: 0; border-radius: 14px;
  background: var(--glass); border: 1px solid var(--line); transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
}
.pcard .mk { font-size: 26px; }
.pcard > div { min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.pname { font-family: var(--f-serif); font-size: 15px; line-height: 1.25; overflow-wrap: anywhere; }
.prole { font-size: 11px; line-height: 1.3; color: var(--ink-faint); overflow-wrap: anywhere; }
.pcard.turn { border-color: var(--gold); background: rgba(224, 189, 120, 0.14); box-shadow: 0 0 0 1px rgba(224, 189, 120, 0.4), 0 0 24px rgba(224, 189, 120, 0.25); }
.pcard.mine .prole { color: var(--gold); }

.board-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.board-area { width: 100%; }
/* 盤と駒台を1つの箱にまとめる。箱の幅が決まり、中の文字・駒は箱の幅（cqw）に合わせて大きさが変わる */
.sg-box { width: 100%; margin: 0 auto; container-type: inline-size; display: block; }
.board-frame {
  position: relative; width: 100%; aspect-ratio: 1; padding: 5.2% 5.2% 2.2% 2.2%; border-radius: 20px;
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.12) 0%, transparent 35%, rgba(0, 0, 0, 0.2) 100%),
    repeating-linear-gradient(92deg, #6a4526 0 7px, #5b3a1f 7px 13px, #70492a 13px 21px, #5f3d21 21px 28px);
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 224, 160, 0.25), inset 0 2px 0 rgba(255, 255, 255, 0.28), inset 0 -3px 6px rgba(0, 0, 0, 0.4);
  transition: box-shadow 0.4s;
}
.my-turn .board-frame { box-shadow: 0 24px 50px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 224, 160, 0.4), 0 0 38px rgba(224, 189, 120, 0.3), inset 0 2px 0 rgba(255, 255, 255, 0.28), inset 0 -3px 6px rgba(0, 0, 0, 0.4); }
.lab-files, .lab-ranks { position: absolute; display: grid; text-align: center; color: rgba(255, 232, 190, 0.9); font-family: var(--f-num); font-weight: 700; font-size: 3.1cqw; line-height: 1; pointer-events: none; }
.lab-files { left: 2.2%; right: 5.2%; top: 0; height: 5.2%; grid-template-columns: repeat(9, 1fr); align-items: center; }
.lab-ranks { top: 5.2%; bottom: 2.2%; right: 0; width: 5.2%; grid-template-rows: repeat(9, 1fr); align-items: center; font-family: var(--f-serif); }
.board {
  position: relative; width: 100%; height: 100%; display: grid; grid-template-columns: repeat(9, 1fr); grid-template-rows: repeat(9, 1fr);
  border-radius: 3px;
  background:
    repeating-linear-gradient(88deg, rgba(150, 100, 40, 0.08) 0 3px, transparent 3px 9px, rgba(255, 238, 180, 0.09) 9px 12px, transparent 12px 21px),
    radial-gradient(120% 90% at 30% 15%, rgba(255, 246, 205, 0.55), transparent 60%),
    radial-gradient(90% 90% at 80% 95%, rgba(120, 70, 20, 0.28), transparent 60%),
    linear-gradient(145deg, var(--kaya-hi), var(--kaya-lo));
  box-shadow: 0 0 0 2px rgba(60, 32, 8, 0.95), inset 0 0 0 1px rgba(60, 32, 8, 0.7), 0 4px 12px rgba(0, 0, 0, 0.45);
}
.cell {
  position: relative; appearance: none; border: 0; padding: 0; margin: 0; background: transparent; cursor: default;
  box-shadow: inset 0 0 0 0.6px rgba(70, 38, 10, 0.85);
  -webkit-tap-highlight-color: transparent; min-width: 0; min-height: 0;
}
.my-turn .cell { cursor: pointer; }
.cell.legal:hover { background: rgba(46, 125, 90, 0.2); }
.star { position: absolute; width: 1.7%; height: 1.7%; border-radius: 50%; background: rgba(50, 26, 6, 0.92); transform: translate(-50%, -50%); pointer-events: none; z-index: 1; }
.star.s1 { left: 33.333%; top: 33.333%; }
.star.s2 { left: 66.667%; top: 33.333%; }
.star.s3 { left: 33.333%; top: 66.667%; }
.star.s4 { left: 66.667%; top: 66.667%; }

/* 駒：五角形（頂点が相手の側）。相手の駒は逆向き。成り駒は赤字 */
.pc { position: absolute; inset: 5% 8%; pointer-events: none; filter: drop-shadow(0 2px 1.5px rgba(40, 20, 4, 0.55)); z-index: 2; }
.pc.opp { transform: rotate(180deg); }
.pc-body { position: absolute; inset: 0; clip-path: polygon(50% 0, 89% 17%, 100% 100%, 0 100%, 11% 17%); background: linear-gradient(160deg, #b98446, #7c4d22); }
.pc-face {
  position: absolute; inset: 4.5%; clip-path: polygon(50% 0, 89% 17%, 100% 100%, 0 100%, 11% 17%);
  background: repeating-linear-gradient(95deg, rgba(150, 100, 40, 0.1) 0 2px, transparent 2px 7px), linear-gradient(160deg, #fbe5ae 0%, #f0cd88 55%, #e4b86c 100%);
  display: grid; place-items: center; padding-top: 16%;
}
.pc-ch { font-family: var(--f-serif); font-weight: 800; font-size: 5.6cqw; line-height: 1; color: var(--piece-ink); font-style: normal; }
.pc.pro .pc-ch { color: var(--piece-red); }
.pc.drop { animation: pdrop 0.38s cubic-bezier(0.25, 0.8, 0.3, 1.15); }
.pc.opp.drop { animation-name: pdrop-opp; }
@keyframes pdrop { 0% { translate: 0 -26%; scale: 1.3; opacity: 0.5; } 60% { translate: 0 2%; scale: 0.97; opacity: 1; } 100% { translate: 0 0; scale: 1; } }
@keyframes pdrop-opp { 0% { translate: 0 26%; scale: 1.3; opacity: 0.5; } 60% { translate: 0 -2%; scale: 0.97; opacity: 1; } 100% { translate: 0 0; scale: 1; } }

.mark-hint { position: absolute; left: 50%; top: 50%; width: 26%; height: 26%; margin: -13% 0 0 -13%; border-radius: 50%; pointer-events: none; opacity: 0; transform: scale(0.5); transition: opacity 0.25s, transform 0.25s; background: radial-gradient(circle, rgba(70, 160, 115, 0.95), rgba(40, 115, 80, 0.55) 70%); box-shadow: 0 0 8px rgba(40, 125, 85, 0.7); z-index: 3; }
.cell.legal .mark-hint { opacity: 0.9; transform: scale(1); animation: breathe 2.2s ease-in-out infinite; }
.cell.legal.cap .mark-hint { width: 84%; height: 84%; margin: -42% 0 0 -42%; background: transparent; border: 3px solid rgba(205, 45, 35, 0.85); box-shadow: 0 0 8px rgba(205, 45, 35, 0.6); animation: none; }
@keyframes breathe { 0%, 100% { transform: scale(0.88); opacity: 0.7; } 50% { transform: scale(1.08); opacity: 1; } }
.mark-last { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: rgba(255, 140, 50, 0.4); box-shadow: inset 0 0 0 2px rgba(235, 105, 30, 0.9); z-index: 0; }
.cell.last .mark-last { opacity: 1; }
.cell.last-from .mark-last { opacity: 1; background: rgba(255, 140, 50, 0.16); box-shadow: inset 0 0 0 1px rgba(235, 105, 30, 0.5); }
.cell.sel { background: rgba(255, 238, 140, 0.6); box-shadow: inset 0 0 0 2px rgba(190, 130, 20, 0.95); }
.cell.incheck::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle, rgba(225, 40, 30, 0.7), rgba(225, 40, 30, 0.15) 75%); animation: chk 1s ease-in-out infinite; pointer-events: none; z-index: 1; }
@keyframes chk { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
.cell.promo-to { box-shadow: inset 0 0 0 2px rgba(190, 130, 20, 0.95); }

.check-flash {
  position: absolute; left: 50%; top: 50%; z-index: 8; transform: translate(-50%, -50%) scale(0.7); padding: 0.1em 0.55em; border-radius: 14px; pointer-events: none; opacity: 0;
  font-family: var(--f-serif); font-weight: 800; font-size: 13cqw; letter-spacing: 0.1em; color: #fff; background: rgba(190, 30, 25, 0.9);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}
.check-flash.on { animation: cflash 1.3s ease; }
@keyframes cflash { 0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); } 70% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1); } }

.promo-back { position: absolute; inset: 0; z-index: 5; background: rgba(20, 10, 2, 0.32); cursor: pointer; }
.promo-pop { position: absolute; z-index: 6; width: 22.222%; height: 11.111%; display: flex; border-radius: 10px; background: rgba(40, 22, 10, 0.96); border: 2px solid var(--gold); box-shadow: 0 8px 22px rgba(0, 0, 0, 0.6); overflow: hidden; }
.promo-btn { position: relative; flex: 1 1 0; min-width: 0; appearance: none; border: 0; padding: 0; background: transparent; cursor: pointer; }
.promo-btn + .promo-btn { border-left: 1px solid var(--line-gold); }
.promo-btn:hover, .promo-btn:focus-visible { background: rgba(224, 189, 120, 0.3); outline: none; }

/* 駒台（持ち駒）。相手の台は盤の上、自分の台は盤の下 */
.hand { display: flex; align-items: center; justify-content: flex-start; gap: 1%; min-height: 15cqw; margin: 1.4% 0; padding: 0.8% 2%; border-radius: 12px; background: rgba(30, 16, 8, 0.55); border: 1px solid var(--line-gold); box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.4); overflow: hidden; }
.hand-opp { justify-content: flex-end; }
.hslot { position: relative; flex: 0 1 11.4cqw; min-width: 0; width: 11.4cqw; height: 13.4cqw; appearance: none; border: 0; border-radius: 8px; padding: 0; background: transparent; cursor: default; -webkit-tap-highlight-color: transparent; }
.hslot .pc { inset: 4% 7%; }
.hslot:not(:disabled) { cursor: pointer; }
.hslot:not(:disabled):hover { background: rgba(224, 189, 120, 0.18); }
.hslot.sel { background: rgba(255, 238, 140, 0.35); box-shadow: inset 0 0 0 2px rgba(255, 220, 120, 0.9); }
.hslot:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 1px; }
.hslot.multi { margin-right: 3cqw; }
.hand-opp .hslot.multi { margin-right: 0; margin-left: 3cqw; }
/* 枚数は駒の字に重ねず、駒の右下の外側に小さな丸で置く（相手の台は左上） */
.hn { position: absolute; right: -3cqw; bottom: -1cqw; z-index: 3; display: grid; place-items: center; width: 1.7em; height: 1.7em; box-sizing: border-box; font-family: var(--f-num); font-weight: 800; font-size: max(3.2cqw, 10px); line-height: 1; padding: 0; border-radius: 50%; background: rgba(20, 10, 2, 0.92); border: 1px solid var(--line-gold); color: var(--gold-hi); }
.hand-opp .hn { right: auto; left: -3cqw; bottom: auto; top: -1cqw; }
.hand-none { font-size: 3cqw; color: var(--ink-faint); padding: 0 2%; }

.turn-line { min-height: 1.7em; font-family: var(--f-serif); font-size: 18px; letter-spacing: 0.06em; text-align: center; color: var(--ink-dim); margin-top: 6px; }
.turn-line.mine { color: var(--gold-hi); }
.turn-line.warn { color: #ffb08a; }
.sub-line { min-height: 1.5em; font-size: 14px; color: #ffcf9a; text-align: center; }
.game-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.game-side { display: contents; }
.game-record { display: none; }
.record-list {
  display: grid; gap: 4px; margin: 0; padding: 0 4px 0 0; list-style: none; overflow-y: auto;
  align-content: start; grid-auto-rows: max-content;
  scrollbar-width: thin; scrollbar-color: rgba(224, 189, 120, 0.45) rgba(255, 255, 255, 0.05);
}
.record-list::-webkit-scrollbar, .player-list::-webkit-scrollbar, .post-list::-webkit-scrollbar { width: 10px; }
.record-list::-webkit-scrollbar-track, .player-list::-webkit-scrollbar-track, .post-list::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.05); border-radius: 999px; }
.record-list::-webkit-scrollbar-thumb, .player-list::-webkit-scrollbar-thumb, .post-list::-webkit-scrollbar-thumb { background: rgba(224, 189, 120, 0.45); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
.record-list::-webkit-scrollbar-thumb:hover, .player-list::-webkit-scrollbar-thumb:hover, .post-list::-webkit-scrollbar-thumb:hover { background: rgba(247, 227, 176, 0.7); background-clip: padding-box; }
.player-list, .post-list { scrollbar-width: thin; scrollbar-color: rgba(224, 189, 120, 0.45) rgba(255, 255, 255, 0.05); }
.rec { display: grid; grid-template-columns: 4.6em 1fr; gap: 10px; align-items: center; padding: 6px 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.045); font-size: 15px; }
.rec-no { font-family: var(--f-num); font-size: 13px; color: var(--ink-faint); }
.rec-pos { font-family: var(--f-serif); font-weight: 700; color: var(--gold-hi); letter-spacing: 0.04em; }

/* ---------------------------------------------------------------- 小窓・通知 */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(12, 6, 2, 0.62); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: fade 0.25s ease; }
.modal-card {
  position: relative; width: min(100%, 420px); padding: 34px 24px 24px; text-align: center; border-radius: 24px;
  background: linear-gradient(165deg, rgba(84, 52, 26, 0.97), rgba(34, 19, 9, 0.98));
  border: 1px solid var(--line-gold);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.65), 0 0 60px rgba(224, 189, 120, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  animation: rise 0.4s cubic-bezier(0.2, 0.8, 0.25, 1.1);
}
.modal-stones { position: absolute; left: 50%; top: -30px; width: 108px; height: 60px; margin-left: -54px; }
.ms-pc { position: absolute; top: 0; width: 52px; height: 60px; display: grid; place-items: center; clip-path: polygon(50% 0, 90% 18%, 100% 100%, 0 100%, 10% 18%); background: linear-gradient(160deg, #fbe5ae, #e0b369); filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.6)); }
.ms-pc:first-child { left: 0; }
.ms-pc:last-child { right: 0; }
.ms-pc b { font-family: var(--f-serif); font-weight: 800; font-size: 26px; line-height: 1; color: var(--piece-ink); margin-top: 14px; }
.modal-kicker { font-family: var(--f-latin); font-size: 14px; letter-spacing: 0.3em; color: var(--gold); margin-top: 18px; }
.modal-card h2 { font-family: var(--f-serif); font-size: clamp(22px, 6vw, 27px); letter-spacing: 0.06em; line-height: 1.5; margin: 8px 0 14px; overflow-wrap: anywhere; }
.modal-card h2 b { color: var(--gold-hi); }
.timer { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); overflow: hidden; margin: 6px 6px 0; }
.timer i { display: block; height: 100%; width: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--gold-lo), var(--gold-hi)); transition: width 0.25s linear; }
.modal-sub { font-size: 14px; color: var(--ink-dim); margin: 8px 0 18px; min-height: 1.2em; }
.modal-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.modal-actions .btn { flex: 1 1 0; min-width: 0; white-space: nowrap; padding-left: 12px; padding-right: 12px; }
.result-card .result-score { font-family: var(--f-num); font-size: 34px; font-weight: 700; color: var(--ink); letter-spacing: 0.04em; margin-bottom: 4px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(20px) scale(0.96); } to { opacity: 1; transform: none; } }

.sending {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 40; width: min(calc(100% - 24px), 560px);
  display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; border-radius: 999px; font-size: 14px;
  background: rgba(36, 20, 10, 0.93); border: 1px solid var(--line-gold); box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.sending > span:nth-child(2) { flex: 1; min-width: 0; overflow-wrap: anywhere; line-height: 1.4; }
.sending b { color: var(--gold-hi); }
.spin { flex: none; width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(224, 189, 120, 0.3); border-top-color: var(--gold-hi); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toasts { position: fixed; top: 72px; left: 50%; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; width: min(calc(100% - 24px), 480px); pointer-events: none; }
.toast {
  padding: 11px 16px; border-radius: 14px; font-size: 14px; text-align: center; line-height: 1.5; overflow-wrap: anywhere;
  background: rgba(36, 20, 10, 0.96); border: 1px solid var(--line); box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
  opacity: 0; transform: translateY(-10px); transition: opacity 0.35s, transform 0.35s;
}
.toast.in { opacity: 1; transform: none; }
.toast-ok { border-color: rgba(120, 220, 160, 0.55); }
.toast-warn { border-color: rgba(255, 190, 100, 0.6); }

/* ---------------------------------------------------------------- 狭い画面 */
@media (max-width: 480px) {
  .topbar { padding: 10px 12px 4px; }
  .stage { padding: 6px 12px 22px; }
  .brand-text b { font-size: 19px; }
  .brand-mark { width: 38px; height: 38px; }
  .me-label { display: none; }
  .me { padding-left: 12px; }
  .me-name { max-width: 9em; font-size: 15px; }
  .panel { padding: 16px 14px 18px; }
  .select-row { flex-direction: column; }
  .player { flex-wrap: wrap; }
  .p-btn { width: 100%; }
  .pcard { padding: 8px 10px; gap: 8px; }
  .pname { font-size: 14px; }
  .prole { font-size: 10.5px; }
  .seg span { padding: 8px 6px; gap: 6px; font-size: 14px; }
  .modal-card { padding: 34px 16px 20px; }
  .modal-actions .btn-lg { font-size: 16px; padding-left: 8px; padding-right: 8px; }
  .snd-label { display: none; }
  .snd-btn { padding: 6px 10px; }
  .toasts { top: 62px; }
}
/* 1099px 以下の対局：窓の高さ(100svh)の縦の割り付け。上の帯・名前の札・案内の文・ボタンは中身の高さ、盤の場所は残りの全部。
   盤はその場所の幅と高さの小さい方の正方形（高さの見積もりの定数は使わない）。盤の幅は上限 620px */
@media (max-width: 1099px) {
  body[data-view="game"] { height: 100svh; }
  body[data-view="game"] .stage { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; padding-top: 4px; padding-bottom: 4px; }
  body[data-view="game"] .foot { padding: 2px 16px 6px; gap: 14px; font-size: 12px; line-height: 1.4; }
  #view-game { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; }
  .game {
    flex: 1 1 0; min-height: 0; width: 100%; max-width: 620px; margin: 0 auto; padding-top: 2px; gap: 8px;
    grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; justify-items: stretch;
  }
  .game-top, .game-actions { width: 100%; }
  .board-wrap { width: 100%; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto auto; gap: 0; justify-items: stretch; }
  .board-area { align-self: stretch; width: 100%; container-type: size; min-width: 0; min-height: 0; display: grid; place-items: center; }
  .sg-box { width: min(100cqw, 100cqh / 1.36, 620px); margin: auto; }
  .turn-line { min-height: 0; margin-top: 4px; font-size: clamp(15px, 4.4vw, 18px); line-height: 1.5; letter-spacing: 0.03em; }
  .sub-line { min-height: 1.4em; font-size: 13px; line-height: 1.4; }
  .game-actions { flex-wrap: nowrap; gap: 8px; }
  .game-actions .btn { flex: 1 1 0; min-width: 0; max-width: 300px; white-space: nowrap; min-height: 40px; padding: 8px 10px; font-size: clamp(13px, 3.6vw, 15px); letter-spacing: 0; }
}

/* ---------------------------------------------------------------- 広い画面（横幅いっぱいを使う） */
@media (min-width: 1100px) {
  .topbar { max-width: none; padding: 16px clamp(24px, 3vw, 64px) 8px; }
  .stage { max-width: none; padding: 12px clamp(24px, 3vw, 64px) 24px; }

  /* 待合：1100〜1499px は2段組み（左に見出し・CPU 戦・掲示板、右に「いま遊べる人」を縦いっぱい）。1500px 以上で3段組み */
  .lobby {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "ce pl" "bd pl"; gap: clamp(18px, 2vw, 40px); max-width: 2200px; margin: 0 auto; padding-top: 14px;
  }
  .lb-center { container-type: inline-size; }
  .lobby-hero { display: block; text-align: center; padding: clamp(10px, 4svh, 56px) 0 clamp(4px, 2svh, 24px); }
  .lobby-kicker { font-family: var(--f-latin); font-size: 15px; letter-spacing: 0.4em; text-transform: uppercase; color: var(--gold); }
  .lobby-title {
    margin-top: 8px; font-family: var(--f-serif); font-weight: 700; letter-spacing: 0.14em; line-height: 1.3; font-size: clamp(30px, 3.4vw, 68px); white-space: nowrap;
    background: linear-gradient(180deg, #fff6d9 0%, var(--gold) 55%, var(--gold-lo) 100%);
    -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent; filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.45));
  }
  @supports (font-size: 1cqi) { .lobby-title { font-size: clamp(28px, 7.4cqi, 68px); letter-spacing: 0.1em; } }
  .lobby-lead { margin-top: 12px; color: var(--ink-dim); font-size: clamp(15px, 1.1vw, 18px); }
  .lb-players { align-self: stretch; }
  .lb-players > .panel { height: 100%; }
  .player-list { max-height: calc(100svh - 250px); min-height: 240px; }
  .post-list { max-height: calc(100svh - 620px); min-height: 160px; }

  /* 掲示板：「投稿する」は選ぶ欄と同じ行に置く */
  .post-form { flex-wrap: nowrap; }
  .post-form .field:first-child { flex: 1 1 0; min-width: 0; }
  .post-form .field { flex: 0 0 8.2em; }
  .post-form .btn { padding-left: 18px; padding-right: 18px; white-space: nowrap; }
  .post-form select { padding-left: 12px; padding-right: 34px; background-position: right 12px center; }

  /* 対局：左に二人の名前と石の数・中央に大きな盤・右にボタンと記録 */
  .game {
    --side: clamp(220px, 20vw, 440px);
    --bs: clamp(360px, min((100svh - 250px) / 1.36, 100vw - 2 * var(--side) - 170px), 960px);
    grid-template-columns: var(--side) var(--bs) var(--side); justify-content: center; justify-items: stretch; align-items: start;
    gap: clamp(20px, 2.4vw, 48px); padding-top: 4px;
  }
  .game-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
  .game .game-top, .game .game-actions { width: 100%; }
  .game .board-wrap { width: var(--bs); }
  .game .game-top { grid-template-columns: 1fr; gap: 14px; }
  .game .pcard { padding: 16px 18px; gap: 14px; border-radius: 16px; }
  .game .pcard .mk { font-size: 34px; }
  .game .pname { font-size: clamp(17px, 1.3vw, 22px); }
  .game .prole { font-size: 13px; }
  .game .game-actions { flex-direction: column; align-items: stretch; flex-wrap: nowrap; }
  .game .game-actions .btn { width: 100%; }
  .game-record { display: block; }
  .record-list { max-height: calc(var(--bs) * 1.36 - 190px); min-height: 80px; }
}
@media (min-width: 1500px) {
  .lobby {
    grid-template-columns: minmax(320px, 1fr) minmax(400px, 1.1fr) minmax(420px, 1.3fr);
    grid-template-areas: "pl ce bd";
  }
  .player-list { max-height: calc(100svh - 330px); }
  .post-list { max-height: calc(100svh - 440px); }
}

/* 名前は言葉の切れ目（「気まぐれな｜角の番人」）で折る。前半・後半をそれぞれ折り返さない塊にして、語の途中では折れない */
.nm-f, .nm-b, .ph { white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}

/* ---------------------------------------------------------------- 文書ページ（プライバシーポリシー） */
.doc { max-width: 760px; margin: 12px auto 0; padding: 26px 24px 30px; }
.doc h1 { font-family: var(--f-serif); font-size: clamp(24px, 6vw, 30px); letter-spacing: 0.1em; color: var(--gold-hi); margin: 10px 0 2px; }
.doc h2 { font-family: var(--f-serif); font-size: 17px; margin: 26px 0 6px; padding-left: 10px; border-left: 4px solid var(--gold); letter-spacing: 0.06em; display: block; }
.doc h2::before { display: none; }
.doc p, .doc li { font-size: 15px; color: var(--ink-dim); overflow-wrap: anywhere; }
.doc ul { list-style: disc; padding-left: 1.3em; display: grid; gap: 6px; }
.doc b, .doc strong { color: var(--ink); }
.doc-date { font-size: 13px !important; color: var(--ink-faint) !important; margin-bottom: 12px; }
.doc-back { display: inline-block; font-size: 14px; text-decoration: none; }
