/* 泣き銀 — 夜の対局室。漆黒・金・朱、榧の盤と黄楊の駒。 */

:root {
  --ink: #0b0806;
  --lacquer: #15100c;
  --lacquer-2: #1f1711;
  --line: #4a3a1f;
  --gold: #c9a45c;
  --gold-hi: #f2dc9c;
  --gold-dim: #7d6535;
  --shu: #a3261a;
  --shu-hi: #cf4a35;
  --paper: #efe6d2;
  --paper-dim: #a89c85;
  --sumi: #17100a;

  --mincho: 'Shippori Mincho B1', 'Yu Mincho', 'Hiragino Mincho ProN', 'Noto Serif JP', serif;
  --fude: 'Yuji Syuku', 'Shippori Mincho B1', 'Yu Mincho', 'Hiragino Mincho ProN', serif;

  /* 木目（縦に流れる柾目） */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='512' height='512'%3E%3Cfilter id='g' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.15 0.004' numOctaves='3' seed='11'/%3E%3CfeColorMatrix values='0 0 0 0 0.36 0 0 0 0 0.17 0 0 0 0 0.02 1.15 0 0 0 -0.36'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  /* 和紙のざらつき */
  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 0.92 0 0 0 0 0.8 0.55 0 0 0 -0.2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");

  --grain-dark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='512' height='512'%3E%3Cfilter id='g' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.12 0.004' numOctaves='3' seed='4'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.1 0 0 0 -0.3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");

  --cell: 40px;
  --ch: calc(var(--cell) * 1.09);
  --mg: calc(var(--cell) * 0.36);
}

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

html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100%;
  color: var(--paper);
  font-family: var(--mincho);
  font-weight: 500;
  font-size: 15px;
  line-height: 1.75;
  background:
    radial-gradient(1100px 620px at 50% 12%, rgba(200, 146, 60, 0.16), transparent 62%),
    radial-gradient(900px 600px at 88% 108%, rgba(150, 32, 20, 0.13), transparent 60%),
    radial-gradient(700px 500px at 0% 100%, rgba(120, 90, 40, 0.08), transparent 60%),
    var(--ink);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overflow-x: hidden;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: var(--noise);
  opacity: 0.16;
  pointer-events: none;
  z-index: 0;
}
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.6) 100%);
  pointer-events: none;
  z-index: 0;
}

.view { position: relative; z-index: 1; min-height: 100dvh; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }

/* ---------- 部品 ---------- */

.panel {
  background: linear-gradient(180deg, var(--lacquer-2), var(--lacquer) 70%, #0f0b08);
  border: 1px solid var(--line);
  border-radius: 3px;
  box-shadow:
    0 0 0 1px #000,
    inset 0 0 0 1px rgba(201, 164, 92, 0.1),
    inset 0 1px 0 rgba(255, 230, 170, 0.08),
    0 30px 80px rgba(0, 0, 0, 0.6);
}
.panel-title {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--fude);
  font-weight: 400;
  font-size: 22px;
  letter-spacing: 0.3em;
  color: var(--gold-hi);
  margin-bottom: 16px;
}
.panel-title span { padding-left: 0.3em; }
.panel-title::before, .panel-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--gold-dim));
}
.panel-title::after { transform: scaleX(-1); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 22px;
  border: 1px solid var(--line);
  border-radius: 2px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-indent: 0.16em;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.12s, filter 0.15s, background 0.15s, border-color 0.15s, box-shadow 0.15s;
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; filter: grayscale(0.6); }
.btn:focus-visible, .fuda:focus-visible, .cell:focus-visible, .link:focus-visible {
  outline: 2px solid var(--gold-hi);
  outline-offset: 2px;
}
.btn-primary {
  color: #fdebc8;
  background: linear-gradient(180deg, #b23120, #86190e 60%, #6e130a);
  border-color: #d76552 #5a0f08 #4a0b05 #c04a39;
  box-shadow: 0 2px 0 #3d0904, 0 10px 26px rgba(170, 36, 18, 0.35), inset 0 1px 0 rgba(255, 200, 170, 0.25);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.45);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.12); }
.btn-ghost {
  color: var(--gold);
  background: rgba(201, 164, 92, 0.05);
  border-color: #5c4a28;
}
.btn-ghost:hover:not(:disabled) { background: rgba(201, 164, 92, 0.14); border-color: var(--gold-dim); color: var(--gold-hi); }
.btn-danger {
  color: #f3c9bd;
  background: rgba(163, 38, 26, 0.16);
  border-color: #7a2418;
}
.btn-danger:hover:not(:disabled) { background: rgba(163, 38, 26, 0.34); }
.btn-s { padding: 6px 12px; font-size: 13px; letter-spacing: 0.1em; text-indent: 0.1em; }
.btn-wide { width: 100%; padding: 14px; font-size: 17px; }

.link {
  background: none;
  border: 0;
  padding: 4px 2px;
  color: var(--paper-dim);
  letter-spacing: 0.12em;
  border-bottom: 1px solid transparent;
}
.link:hover { color: var(--gold-hi); border-bottom-color: var(--gold-dim); }

.hanko {
  display: inline-grid;
  place-items: center;
  width: 2.1em;
  height: 2.1em;
  font-family: var(--fude);
  font-size: 21px;
  line-height: 1;
  letter-spacing: -0.02em;
  text-align: center;
  color: #f7e4d2;
  background: radial-gradient(circle at 30% 25%, #c23a28, #9a2014 70%);
  border-radius: 5px;
  transform: rotate(-4deg);
  box-shadow: inset 0 0 0 2px rgba(247, 228, 210, 0.75), inset 0 0 0 3px #9a2014, 0 6px 16px rgba(160, 30, 15, 0.45);
}
.hanko-s { font-size: 13px; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(247, 228, 210, 0.75), 0 3px 8px rgba(160, 30, 15, 0.4); }

.rank-chip {
  display: inline-block;
  padding: 0 0.5em;
  font-size: 0.82em;
  line-height: 1.6;
  color: var(--gold-hi);
  border: 1px solid var(--gold-dim);
  border-radius: 2px;
  white-space: nowrap;
  vertical-align: 0.08em;
}

/* ---------- 入場 ---------- */

#view-entry {
  display: grid;
  grid-template-rows: 1fr auto;
  padding: 32px 20px 20px;
  overflow: hidden;
}
.entry-frame {
  position: fixed;
  inset: 12px;
  border: 1px solid rgba(125, 101, 53, 0.55);
  outline: 1px solid rgba(125, 101, 53, 0.22);
  outline-offset: -6px;
  pointer-events: none;
}
.entry-ghost {
  position: fixed;
  right: -6vw;
  bottom: -12vh;
  width: min(70vw, 620px);
  fill: rgba(201, 164, 92, 0.035);
  stroke: rgba(201, 164, 92, 0.16);
  stroke-width: 0.35;
  transform: rotate(9deg);
  pointer-events: none;
}
.entry-wrap {
  align-self: center;
  justify-self: center;
  display: grid;
  grid-template-columns: auto minmax(0, 400px);
  grid-template-areas: 'kanban panel' 'kanban motto';
  column-gap: clamp(28px, 7vw, 96px);
  align-items: center;
}
.kanban {
  grid-area: kanban;
  display: flex;
  flex-direction: row-reverse;
  align-items: flex-start;
  gap: 14px;
  animation: rise 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
/* 題字は毛筆の画像（墨の濃淡をマスクにして金を流す）。影はマスクの外側の要素に掛ける */
.ink {
  display: block;
  aspect-ratio: 749 / 1100;
  background: linear-gradient(160deg, #fbeab4 0%, #d9b469 38%, #9c7833 62%, #e8cc88 100%);
  -webkit-mask: url(/img/title-v.webp) center / contain no-repeat;
  mask: url(/img/title-v.webp) center / contain no-repeat;
}
.kanban-title {
  line-height: 0;
  filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.55)) drop-shadow(0 0 34px rgba(220, 170, 80, 0.22));
}
.kanban-title .ink { height: clamp(250px, 52vh, 540px); }
.kanban-sub {
  writing-mode: vertical-rl;
  font-size: 14px;
  letter-spacing: 0.7em;
  color: var(--paper-dim);
  padding-top: 0.6em;
  border-right: 1px solid var(--gold-dim);
  padding-right: 10px;
}
.kanban .hanko { align-self: flex-end; margin-bottom: 0.5em; }

.entry-panel {
  grid-area: panel;
  padding: 24px 26px 20px;
  animation: rise 0.9s 0.15s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.entry-lead { color: var(--paper-dim); font-size: 14px; margin-bottom: 14px; }
.entry-panel .field { margin-bottom: 13px; }
.entry-motto {
  grid-area: motto;
  margin-top: 18px;
  text-align: right;
  font-family: var(--fude);
  letter-spacing: 0.5em;
  color: var(--gold-dim);
  animation: rise 0.9s 0.3s both;
}

.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font-size: 13px; letter-spacing: 0.22em; color: var(--gold); margin-bottom: 6px; }
.field-label small { color: var(--paper-dim); letter-spacing: 0.05em; }
.field input, .field select {
  width: 100%;
  padding: 11px 12px;
  font-size: 17px;
  color: var(--paper);
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid #33281a;
  border-bottom-color: var(--gold-dim);
  border-radius: 2px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--gold) 50%), linear-gradient(135deg, var(--gold) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 12px) 55%; background-size: 6px 6px; background-repeat: no-repeat; }
.field select option { background: #1a130d; color: var(--paper); }
.field input:focus, .field select:focus { border-color: var(--gold); box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6), 0 0 0 3px rgba(201, 164, 92, 0.16); }
.field input::placeholder { color: #6b6152; }
.turnstile-box { min-height: 65px; }
.g-box { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 8px; }
.g-box:not(:has(> :not([hidden]):not(:empty))) { display: none; }
.pk-box { display: flex; flex-direction: column; gap: 12px; }
.entry-panel > .pk-tabs { margin: 0 0 20px; }
.pk-tabs { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.pk-tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 6px; border: 0; background: transparent; color: var(--paper-dim);
  font: inherit; font-size: 15px; cursor: pointer;
}
.pk-tab + .pk-tab { border-left: 1px solid var(--line); }
.pk-tab small { font-size: 12px; opacity: 0.85; }
.pk-tab[aria-selected="true"] { background: rgba(201, 164, 92, 0.16); color: var(--gold-hi, var(--gold)); font-weight: 700; box-shadow: inset 0 -3px 0 var(--gold); }
.pk-pane { display: flex; flex-direction: column; gap: 8px; }
.pk-pane[hidden] { display: none; }
.pk-btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; }
.pk-icon { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pk-desc { font-size: 12px; line-height: 1.6; color: var(--paper-dim); }
.pk-hint { margin-top: 8px; font-size: 13px; line-height: 1.6; color: var(--gold); }
.pk-hint:empty { display: none; }
.step {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin-right: 6px;
  font-size: 12px;
  font-family: system-ui, sans-serif;
  font-weight: 700;
  letter-spacing: 0;
  color: #f6e3d6;
  background: var(--shu);
  border-radius: 50%;
  vertical-align: 1px;
}
.g-btn { color-scheme: light; max-width: 100%; overflow: hidden; }
.g-btn:empty { display: none; }
.g-note { margin-top: 6px; font-size: 12px; line-height: 1.6; color: var(--paper-dim); }
.g-done {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid #33281a;
  border-bottom-color: var(--gold-dim);
  border-radius: 2px;
}
.g-seal {
  flex: none;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  font-family: var(--fude);
  font-size: 15px;
  color: #f6e3d6;
  background: var(--shu);
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}
.g-who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; color: var(--paper); }
.g-done .link { flex: none; font-size: 13px; }
.form-error { color: #f0a090; font-size: 14px; margin-bottom: 12px; }

.foot {
  justify-self: center;
  padding-top: 22px;
  font-size: 13px;
  color: var(--paper-dim);
}
.foot-sep { margin: 0 6px; color: var(--gold-dim); }
.foot { text-align: center; }
.foot-origin span { display: inline-block; }
.foot-origin { margin-top: 4px; line-height: 1.6; font-size: 12px; letter-spacing: 0.14em; color: var(--paper-dim); opacity: 0.85; }

/* ---------- 上部バー ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px clamp(12px, 3vw, 32px);
  border-bottom: 1px solid rgba(125, 101, 53, 0.4);
  background: linear-gradient(180deg, rgba(20, 15, 10, 0.92), rgba(12, 9, 6, 0.75));
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 8px; flex: none; }
.brand-title { line-height: 0; filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.5)); }
.brand-title .ink,
.ink-h {
  aspect-ratio: 1046 / 360;
  -webkit-mask-image: url(/img/title-h.webp);
  mask-image: url(/img/title-h.webp);
}
.brand-title .ink { height: 36px; background: linear-gradient(170deg, #fbeab4, #c59d52 60%, #e8cc88); }
.topbar-right { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.me-badge { display: flex; align-items: center; gap: 8px; margin-right: 6px; padding: 4px 6px; font: inherit; font-weight: 700; letter-spacing: 0.08em; color: inherit; background: none; border: 1px solid transparent; border-radius: 6px; cursor: pointer; max-width: 22em; }
.me-badge > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-badge:hover { border-color: var(--line); }
.dlg-small { font-size: 13px; color: var(--paper-dim); margin: 0 0 12px; }

/* ---------- ロビー ---------- */

.lobby-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 28px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 26px clamp(12px, 3vw, 32px) 60px;
}
.sec-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 14px; border-bottom: 1px solid rgba(125, 101, 53, 0.5); padding-bottom: 6px; }
.sec-title { font-family: var(--fude); font-weight: 400; font-size: 24px; letter-spacing: 0.3em; color: var(--gold-hi); white-space: nowrap; }
.sec-note { font-size: 13px; color: var(--paper-dim); letter-spacing: 0.1em; }
.sec-hint { font-size: 13px; color: var(--paper-dim); margin: 8px 0 14px; }

/* 名札の絞り込み */
.lobby-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 4px; }
.lobby-filter input[type="search"], .lobby-filter select {
  min-width: 0; padding: 8px 10px; font-size: 14px; color: var(--paper);
  background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line); border-radius: 6px;
}
.lobby-filter input[type="search"] { flex: 1 1 140px; }
/* 選んだ項目の長さで幅が変わらないように固定 */
.lobby-filter select { flex: 0 0 13.5em; width: 13.5em; }
.lobby-filter select option { background: #1a130d; color: var(--paper); }
.lobby-filter input:focus, .lobby-filter select:focus { outline: none; border-color: var(--gold); }
.flt-check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--paper-dim); cursor: pointer; white-space: nowrap; }
.flt-check input { accent-color: var(--gold); width: 16px; height: 16px; }
.flt-status { display: flex; align-items: center; justify-content: flex-end; gap: 14px; height: 28px; margin: 0 0 8px; overflow: hidden; }
.flt-count { font-size: 13px; color: var(--gold); white-space: nowrap; }
.flt-status .flt-clear { font-size: 13px; letter-spacing: 0.05em; padding: 4px 0; line-height: 1.2; }

/* 名札掛け */
.fuda-wall {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 22px 12px;
  padding: 24px 18px 26px;
  min-height: 250px;
  background: var(--grain-dark), linear-gradient(180deg, #3a2614, #2a1a0d);
  background-size: 512px 512px, auto;
  border: 1px solid #3a2c17;
  border-radius: 3px;
  box-shadow: inset 0 3px 24px rgba(0, 0, 0, 0.75), inset 0 0 0 1px rgba(0, 0, 0, 0.6), 0 20px 50px rgba(0, 0, 0, 0.5);
}
.fuda {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 220px;
  max-width: 78px;
  width: 100%;
  justify-self: center;
  padding: 20px 2px 8px;
  color: var(--sumi);
  background: var(--grain), linear-gradient(100deg, #f0d9a8, #dcbb7c 60%, #cba65f);
  background-size: 512px 512px, auto;
  border: 0;
  border-radius: 3px 3px 2px 2px;
  box-shadow: inset 0 0 0 1px rgba(255, 244, 210, 0.45), inset 0 -3px 0 rgba(110, 76, 22, 0.35), 0 2px 0 #7d5c26, 0 12px 18px rgba(0, 0, 0, 0.6);
  transform-origin: 50% 6px;
  transition: transform 0.25s cubic-bezier(0.3, 1.6, 0.5, 1), filter 0.3s, box-shadow 0.25s;
  animation: hang 0.7s cubic-bezier(0.3, 1.4, 0.5, 1) both;
}
.fuda::before {
  content: '';
  position: absolute;
  top: 6px;
  left: 50%;
  width: 7px;
  height: 7px;
  margin-left: -3.5px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #77623f, #1b130b 70%);
  box-shadow: 0 1px 1px rgba(255, 240, 200, 0.5);
}
.fuda:hover:not(.me) { transform: rotate(-2.2deg) translateY(-2px); box-shadow: inset 0 0 0 1px rgba(255, 244, 210, 0.45), 0 2px 0 #7d5c26, 0 18px 26px rgba(0, 0, 0, 0.7), 0 0 26px rgba(240, 200, 110, 0.25); }
.fuda-rank { font-size: 12px; font-weight: 800; letter-spacing: 0.05em; color: #8f1d12; line-height: 1.3; }
.fuda-name {
  flex: 1;
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-family: var(--fude);
  font-size: 21px;
  line-height: 1.08;
  margin: 5px 0;
  overflow: hidden;
  white-space: nowrap;
}
.fuda-name.len-m { font-size: 16.5px; }
.fuda-name.len-l { font-size: 12px; line-height: 1.02; }
/* 一列に入りきらない名前は、縦書き二行（二列）にする */
.fuda-name.len-2 { font-size: 12px; line-height: 1.15; white-space: normal; word-break: break-all; min-height: 0; }
.fuda-state { font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; color: #5a4420; white-space: nowrap; line-height: 1.4; }
.fuda-state::before { content: ''; display: inline-block; width: 6px; height: 6px; margin-right: 3px; border-radius: 50%; background: #3f8f3a; box-shadow: 0 0 6px #6fd36a; vertical-align: 1px; }
.fuda.away { filter: brightness(0.5) saturate(0.55); }
.fuda.away .fuda-state::before { background: #6b6152; box-shadow: none; }
.fuda.busy .fuda-state::before { background: var(--shu); box-shadow: 0 0 6px var(--shu-hi); }
/* 対局中の人（ロビーの接続はないが、対局一覧から掛ける。押すと観戦） */
.fuda.playing { filter: brightness(0.62) saturate(0.6); animation: none; }
.fuda.playing:hover { filter: brightness(0.8) saturate(0.75); }
.fuda.playing .fuda-state::before { background: #c9a14a; box-shadow: 0 0 5px rgba(240, 200, 110, 0.6); }
.fuda.me { cursor: default; box-shadow: inset 0 0 0 1px rgba(255, 244, 210, 0.45), 0 0 0 2px var(--gold), 0 2px 0 #7d5c26, 0 12px 18px rgba(0, 0, 0, 0.6), 0 0 28px rgba(240, 200, 110, 0.3); }
.fuda.me .fuda-state { color: #8f1d12; }
.fuda.me .fuda-state::before { display: none; }

.lobby-empty { color: var(--paper-dim); text-align: center; padding: 26px 10px; font-size: 14px; }

.game-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.game-row {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 10px;
  padding: 10px 12px;
  text-align: left;
  background: linear-gradient(180deg, rgba(31, 23, 17, 0.9), rgba(18, 13, 9, 0.9));
  border: 1px solid #3a2c17;
  border-left: 3px solid var(--gold-dim);
  border-radius: 2px;
  transition: border-color 0.15s, background 0.15s;
}
.game-row:hover { border-color: var(--gold-dim); border-left-color: var(--gold-hi); background: rgba(40, 30, 20, 0.95); }
.gr-players { display: grid; gap: 1px; min-width: 0; }
.gr-players span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gr-players i { font-style: normal; font-size: 12px; color: var(--gold); margin-left: 4px; }
.gr-side { text-align: right; font-size: 12px; color: var(--paper-dim); line-height: 1.5; }
.gr-watch { color: var(--gold-hi); letter-spacing: 0.2em; font-weight: 700; }

.donate-card { margin-top: 28px; padding: 18px; font-size: 13.5px; color: var(--paper-dim); }
.donate-card-title { font-family: var(--fude); font-size: 17px; letter-spacing: 0.12em; color: var(--gold-hi); margin-bottom: 4px; }
.donate-card .btn { margin-top: 12px; }

.rest-veil {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  text-align: center;
  background: rgba(6, 4, 3, 0.86);
  backdrop-filter: blur(4px);
  cursor: pointer;
  color: var(--paper-dim);
}
.rest-title { font-family: var(--fude); font-size: 64px; letter-spacing: 0.3em; text-indent: 0.3em; color: var(--gold-hi); line-height: 1.4; }

/* ---------- 対局 ---------- */

.topbar-game { padding-top: 6px; padding-bottom: 6px; }
.game-meta { display: flex; align-items: baseline; gap: 12px; font-size: 13px; color: var(--paper-dim); min-width: 0; white-space: nowrap; }
.game-tc { font-family: var(--fude); font-size: 17px; color: var(--gold-hi); letter-spacing: 0.2em; }

.game-body {
  display: grid;
  grid-template-columns: auto 300px;
  justify-content: center;
  align-items: start;
  gap: 30px;
  padding: 12px 12px 12px;
}
.game-main { display: flex; flex-direction: column; align-items: center; gap: 10px; }

.pbar { width: calc(var(--cell) * 9 + var(--mg) * 2); display: grid; gap: 6px; }
.pbar-head { display: flex; align-items: center; gap: 8px; min-height: 34px; }
.pbar-mark { width: 17px; height: 19px; flex: none; }
.pbar-mark path { fill: none; stroke: var(--paper-dim); stroke-width: 9; stroke-linejoin: round; }
.pbar-mark.sente path { fill: var(--paper-dim); }
.pbar-name { font-weight: 700; font-size: 16px; letter-spacing: 0.06em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pbar-you { font-size: 11px; color: var(--gold-dim); letter-spacing: 0.1em; white-space: nowrap; }
.pbar-disc { font-size: 12px; font-weight: 700; color: #f0a090; white-space: nowrap; animation: blink 1s steps(2) infinite; }
.pbar.active .pbar-mark { filter: drop-shadow(0 0 6px rgba(240, 200, 110, 0.9)); }
.pbar.active .pbar-mark path { stroke: var(--gold-hi); }
.pbar.active .pbar-mark.sente path { fill: var(--gold-hi); }

.clock {
  margin-left: auto;
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 1px 12px 2px;
  font-size: 23px;
  line-height: 1.3;
  font-weight: 700;
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: 0.06em;
  color: #8d8371;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid #33281a;
  border-radius: 2px;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.7);
  white-space: nowrap;
  transition: color 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.clock small { font-size: 11px; letter-spacing: 0.15em; font-weight: 700; }
.pbar.active .clock { color: var(--gold-hi); border-color: var(--gold-dim); box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.7), 0 0 18px rgba(240, 200, 110, 0.2); }
.pbar.active .clock.byo { color: #ffb9a4; border-color: #8a2a1c; box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.7), 0 0 18px rgba(207, 74, 53, 0.3); }
.pbar.active .clock.low { color: #fff; background: #8e1c10; border-color: var(--shu-hi); animation: pulse 1s infinite; }

.komadai {
  display: flex;
  align-items: center;
  gap: 1px;
  min-height: calc(var(--cell) * 0.9 + 8px);
  padding: 4px 8px;
  background: var(--grain), linear-gradient(180deg, #7d5126, #5d3916);
  background-size: 512px 512px, auto;
  border-radius: 3px;
  box-shadow: inset 0 1px 0 rgba(255, 220, 170, 0.28), inset 0 0 0 1px rgba(0, 0, 0, 0.45), 0 3px 0 #38210d, 0 10px 20px rgba(0, 0, 0, 0.5);
}
.hand-piece {
  position: relative;
  width: calc(var(--cell) * 0.8);
  height: calc(var(--cell) * 0.88);
  padding: 0;
  background: none;
  border: 0;
  margin-right: 6px;
  transition: transform 0.12s;
}
.hand-piece:disabled { cursor: default; }
.hand-piece .koma { width: 100%; height: 100%; display: block; }
.hand-piece.sel { transform: translateY(-12%) scale(1.1); filter: drop-shadow(0 0 8px rgba(255, 230, 140, 0.9)); }
.hand-count {
  position: absolute;
  right: -7px;
  bottom: -1px;
  min-width: 17px;
  padding: 0 3px;
  font-size: 11px;
  font-weight: 800;
  line-height: 16px;
  text-align: center;
  color: var(--gold-hi);
  background: var(--sumi);
  border: 1px solid var(--gold-dim);
  border-radius: 9px;
}

/* 盤 */
.board-stage { position: relative; padding-bottom: calc(var(--cell) * 0.16); }
.board-frame {
  position: relative;
  padding: var(--mg);
  background: var(--grain), linear-gradient(135deg, #ecc478 0%, #dcab55 50%, #cb983f 100%);
  background-size: 512px 512px, auto;
  border-radius: 3px;
  box-shadow:
    inset 0 1px 0 rgba(255, 244, 205, 0.6),
    inset 1px 0 0 rgba(255, 244, 205, 0.25),
    inset 0 -2px 0 rgba(96, 56, 4, 0.35),
    0 calc(var(--cell) * 0.13) 0 #94672a,
    0 calc(var(--cell) * 0.16) 0 #523610,
    0 34px 60px rgba(0, 0, 0, 0.7),
    0 0 140px rgba(226, 166, 66, 0.14);
}
.board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(9, var(--cell));
  grid-auto-rows: var(--ch);
  border: 1.5px solid #24140a;
  box-shadow: 0 0 0 0.5px rgba(255, 240, 200, 0.25);
}
.files, .ranks {
  position: absolute;
  display: flex;
  font-size: calc(var(--cell) * 0.25);
  font-weight: 800;
  line-height: 1;
  color: rgba(40, 20, 2, 0.92);
  pointer-events: none;
}
.files { top: 0; left: var(--mg); right: var(--mg); height: var(--mg); align-items: center; }
.files span { width: var(--cell); text-align: center; }
.ranks { top: var(--mg); bottom: var(--mg); right: 0; width: var(--mg); flex-direction: column; align-items: center; }
.ranks span { height: var(--ch); display: grid; place-items: center; }
.star { position: absolute; width: 5px; height: 5px; margin: -2.5px 0 0 -2.5px; border-radius: 50%; background: #24140a; pointer-events: none; }

.cell {
  position: relative;
  display: grid;
  place-items: center;
  padding: 0;
  background: none;
  border: 0;
  border-right: 1px solid rgba(36, 20, 10, 0.88);
  border-bottom: 1px solid rgba(36, 20, 10, 0.88);
  cursor: default;
}
.cell:nth-child(9n) { border-right: 0; }
.cell:nth-child(n + 73) { border-bottom: 0; }
.cell.can { cursor: pointer; }
.cell.from { background: rgba(120, 40, 10, 0.13); }
.cell.last { background: rgba(150, 44, 12, 0.3); box-shadow: inset 0 0 0 1px rgba(120, 30, 5, 0.35); }
.cell.sel { background: rgba(255, 240, 170, 0.6); }
.cell.check { background: radial-gradient(circle, rgba(215, 40, 20, 0.75), rgba(215, 40, 20, 0.12) 72%); }
.cell.target::after {
  content: '';
  position: absolute;
  width: 26%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(40, 22, 6, 0.42);
  box-shadow: 0 0 0 1px rgba(255, 240, 200, 0.25);
  pointer-events: none;
}
.cell.target.occupied::after {
  width: 84%;
  background: none;
  border: 3px solid rgba(160, 30, 15, 0.7);
  box-shadow: none;
}
.pc { width: 97%; height: 99%; display: grid; place-items: center; transition: transform 0.12s; pointer-events: none; }
.pc .koma { width: 100%; height: 100%; display: block; overflow: visible; }
.koma.opp { transform: rotate(180deg); }
.cell.sel .pc { transform: translateY(-7%) scale(1.07); filter: drop-shadow(0 6px 5px rgba(0, 0, 0, 0.45)); }
.cell.placed .pc { animation: place 0.2s cubic-bezier(0.3, 0, 0.3, 1); }

.k-shadow { fill: rgba(30, 14, 0, 0.42); }
.k-side { fill: url(#komaSide); }
.k-face { fill: url(#komaGrad); stroke: #7a5a22; stroke-width: 0.9; stroke-linejoin: round; }
.k-grain { fill: url(#komaGrain); }
.k-hi { fill: none; stroke: rgba(255, 250, 225, 0.8); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.kt { font-family: var(--fude); text-anchor: middle; fill: #17100a; }
.kt.pro { fill: #a51d12; }

/* 対局開始・王手などの一瞬の表示 */
.banner {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  pointer-events: none;
  text-align: center;
  animation: banner 1.9s ease both;
}
.banner-main {
  font-family: var(--fude);
  font-size: calc(var(--cell) * 1.7);
  line-height: 1.2;
  letter-spacing: 0.2em;
  text-indent: 0.2em;
  color: #fff3d0;
  text-shadow: 0 0 2px #000, 0 4px 0 rgba(0, 0, 0, 0.7), 0 0 40px rgba(0, 0, 0, 0.9), 0 0 80px rgba(0, 0, 0, 0.9);
}
.banner-sub { font-size: calc(var(--cell) * 0.42); font-weight: 700; letter-spacing: 0.3em; color: #fff3d0; text-shadow: 0 0 12px #000, 0 0 30px #000; }
.banner.small .banner-main { font-size: calc(var(--cell) * 1.2); color: #ffd2c4; }

.result {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at center, rgba(8, 5, 3, 0.9) 30%, rgba(8, 5, 3, 0.62));
  backdrop-filter: blur(2px);
  border-radius: 3px;
  text-align: center;
  animation: fadein 0.6s both;
}
.result-title {
  font-family: var(--fude);
  font-size: calc(var(--cell) * 2.1);
  line-height: 1.25;
  letter-spacing: 0.18em;
  text-indent: 0.18em;
  background: linear-gradient(170deg, #fff1c4, #d2a856 55%, #f0d896);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.6));
  animation: stamp 0.55s 0.15s cubic-bezier(0.2, 1.5, 0.4, 1) both;
}
.result.lose .result-title { background: linear-gradient(170deg, #cfc6b4, #8d8371); -webkit-background-clip: text; background-clip: text; }
.result-sub { margin: 4px 0 20px; letter-spacing: 0.2em; color: var(--paper); }
.result-btns { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; padding: 0 12px; }

/* 棋譜・操作 */
.side {
  display: flex;
  flex-direction: column;
  height: calc(var(--ch) * 9 + var(--mg) * 2 + (var(--cell) * 0.9 + 60px) * 2 + 24px);
  padding: 16px 14px 14px;
}
.side-title { order: 1; font-family: var(--fude); font-weight: 400; font-size: 19px; letter-spacing: 0.4em; color: var(--gold-hi); text-align: center; border-bottom: 1px solid rgba(125, 101, 53, 0.5); padding-bottom: 6px; }
.moves {
  order: 2;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  list-style: none;
  margin: 6px 0 12px;
  padding: 0;
  font-variant-numeric: tabular-nums;
  scrollbar-width: thin;
  scrollbar-color: var(--gold-dim) transparent;
}
.moves li { display: grid; grid-template-columns: 4.6em 1fr; padding: 1px 8px; cursor: pointer; border-radius: 2px; line-height: 1.7; }
.moves li:hover { background: rgba(201, 164, 92, 0.1); }
.moves li.cur { background: rgba(201, 164, 92, 0.22); color: var(--gold-hi); }
.moves li b { font-weight: 500; color: var(--paper-dim); font-size: 12px; align-self: center; }
.moves li.end { cursor: default; color: var(--gold); justify-content: center; grid-template-columns: auto; letter-spacing: 0.2em; padding-top: 6px; }
.side-actions { order: 3; display: grid; gap: 10px; }
.nav { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.acts { display: flex; flex-wrap: wrap; gap: 6px; }
.acts .btn { flex: 1; }

/* ---------- ダイアログ ---------- */

.dlg {
  width: min(92vw, 420px);
  max-height: 88dvh;
  padding: 26px 24px 22px;
  color: var(--paper);
  overflow-y: auto;
}
.dlg[open] { animation: rise 0.28s cubic-bezier(0.2, 0.8, 0.2, 1); }
.dlg::backdrop { background: rgba(5, 3, 2, 0.74); backdrop-filter: blur(3px); }
.dlg-wide { width: min(94vw, 560px); }
.dlg-target { text-align: center; font-size: 16px; margin-bottom: 14px; }
.dlg-target b { font-size: 20px; letter-spacing: 0.06em; }
.dlg-text { margin-bottom: 10px; }
.dlg-note { color: var(--gold); font-size: 14px; text-align: center; margin: 10px 0 0; }
.dlg-btns { display: flex; justify-content: center; gap: 12px; margin-top: 20px; }
.dlg-btns .btn { flex: 1; max-width: 190px; }

.tc-cards { display: grid; gap: 8px; }
.tc-card {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: baseline;
  gap: 14px;
  padding: 12px 16px;
  text-align: left;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid #3a2c17;
  border-radius: 2px;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.tc-card b { font-family: var(--fude); font-weight: 400; font-size: 21px; letter-spacing: 0.18em; color: var(--paper); min-width: 4em; }
.tc-card span { color: var(--paper-dim); font-size: 13px; }
.tc-card:hover { border-color: var(--gold-dim); }
.tc-card[aria-checked='true'] { border-color: var(--gold); background: rgba(201, 164, 92, 0.12); box-shadow: 0 0 22px rgba(240, 200, 110, 0.15), inset 3px 0 0 var(--gold); }
.tc-card[aria-checked='true'] b { color: var(--gold-hi); }

.inc-tc { text-align: center; font-family: var(--fude); font-size: 22px; letter-spacing: 0.14em; color: var(--gold-hi); }
.inc-tc small { display: block; font-family: var(--mincho); font-size: 13px; letter-spacing: 0.05em; color: var(--paper-dim); }
.countdown { text-align: center; margin-top: 8px; }
.countdown span {
  display: inline-grid;
  place-items: center;
  width: 58px;
  height: 58px;
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--gold-hi);
  border: 1px solid var(--gold-dim);
  border-radius: 50%;
  box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.6), 0 0 18px rgba(240, 200, 110, 0.12);
}

.dlg-promote { padding: 14px; background: rgba(12, 8, 5, 0.94); border: 1px solid var(--gold-dim); border-radius: 4px; width: fit-content; max-width: 92vw; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.8); }
.promote-row { display: flex; gap: 12px; }
.promote-btn { display: grid; justify-items: center; gap: 6px; padding: 12px 18px 10px; background: rgba(201, 164, 92, 0.06); border: 1px solid #5c4a28; border-radius: 3px; color: var(--paper); font-weight: 700; letter-spacing: 0.14em; }
.promote-btn:hover { border-color: var(--gold); background: rgba(201, 164, 92, 0.16); }
.promote-piece { width: 68px; height: 75px; }
.promote-piece .koma { width: 100%; height: 100%; }

.guide h3 { font-family: var(--fude); font-weight: 400; font-size: 17px; letter-spacing: 0.2em; color: var(--gold-hi); margin: 16px 0 6px; }
.guide h3:first-child { margin-top: 0; }
.guide p, .guide li { font-size: 14px; color: #d8cfbb; }
.guide ul { margin: 0; padding-left: 1.3em; }
.guide-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.guide-table th { text-align: left; font-family: var(--fude); font-weight: 400; font-size: 17px; letter-spacing: 0.15em; color: var(--paper); padding: 6px 14px 6px 0; white-space: nowrap; }
.guide-table td { color: #d8cfbb; }
.guide-table tr + tr { border-top: 1px solid rgba(125, 101, 53, 0.3); }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(28px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  max-width: 90vw;
  padding: 10px 22px;
  color: var(--paper);
  background: rgba(20, 14, 9, 0.96);
  border: 1px solid var(--gold-dim);
  border-radius: 2px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.7);
  letter-spacing: 0.08em;
  text-align: center;
  animation: rise 0.25s both;
}
.netbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 70;
  padding: 4px;
  font-size: 13px;
  text-align: center;
  letter-spacing: 0.2em;
  color: #fff;
  background: #8e1c10;
}

/* ---------- 動き ---------- */

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes hang { 0% { opacity: 0; transform: translateY(-14px) rotate(5deg); } 60% { opacity: 1; transform: rotate(-2deg); } 100% { transform: none; } }
@keyframes place { from { transform: scale(1.25) translateY(-12%); filter: drop-shadow(0 12px 8px rgba(0, 0, 0, 0.5)); } to { transform: none; filter: none; } }
@keyframes banner { 0% { opacity: 0; transform: scale(1.25); } 14% { opacity: 1; transform: none; } 75% { opacity: 1; } 100% { opacity: 0; } }
@keyframes stamp { from { opacity: 0; transform: scale(1.8); } to { opacity: 1; transform: none; } }
@keyframes pulse { 50% { filter: brightness(1.5); } }
@keyframes blink { 50% { opacity: 0.45; } }

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

/* ---------- 画面幅 ---------- */

@media (max-width: 899px) {
  .lobby-body { grid-template-columns: 1fr; gap: 30px; padding-top: 18px; }
  .game-body { grid-template-columns: 1fr; gap: 10px; padding: 6px 0 30px; justify-items: center; }
  .game-main { gap: 6px; }
  .side { width: calc(var(--cell) * 9 + var(--mg) * 2); height: auto; padding: 10px; }
  .side-actions { order: 0; grid-template-columns: auto 1fr; align-items: center; }
  .nav { grid-template-columns: repeat(4, 38px); gap: 4px; }
  .nav .btn { padding: 6px 0; }
  .acts { justify-content: flex-end; }
  .acts .btn { flex: 0 1 auto; padding: 6px 9px; letter-spacing: 0.04em; text-indent: 0; }
  .side-title { margin-top: 14px; }
  .moves { max-height: 46vh; }
  .pbar-head { min-height: 30px; }
  .clock { font-size: 20px; padding: 0 10px 1px; }
  .komadai { padding: 3px 6px; }
  .topbar-game .btn-s { padding: 5px 8px; font-size: 12px; }
  .game-meta { gap: 8px; }
}

@media (max-width: 640px) {
  body { font-size: 14px; }
  #view-entry { padding: 22px 18px 16px; }
  .entry-wrap { grid-template-columns: 1fr; grid-template-areas: 'kanban' 'panel' 'motto'; width: 100%; max-width: 420px; row-gap: 20px; }
  .kanban { flex-direction: row; align-items: center; justify-content: center; gap: 12px; }
  .kanban-title .ink {
    height: 68px;
    aspect-ratio: 1046 / 360;
    -webkit-mask-image: url(/img/title-h.webp);
    mask-image: url(/img/title-h.webp);
  }
  .kanban-sub { display: none; }
  .kanban .hanko { align-self: center; margin: 0; font-size: 17px; }
  .entry-panel { padding: 22px 18px 20px; }
  .entry-motto { text-align: center; margin-top: 0; }
  .brand-title .ink { height: 28px; }
  .topbar { padding-left: 10px; padding-right: 8px; gap: 6px; }
  .topbar-right { flex-wrap: nowrap; gap: 4px; }
  .topbar .btn-s { padding: 5px 8px; font-size: 12px; letter-spacing: 0.04em; text-indent: 0; }
  .me-badge { display: none; }
  .fuda-wall { grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 20px 8px; padding: 22px 10px 24px; }
  .fuda { height: 210px; }
  .fuda-name { font-size: 19px; }
  .fuda-name.len-m { font-size: 15.5px; }
  .fuda-name.len-l { font-size: 11.5px; }
  .game-ply { display: none; }
}
.link-btn { background: none; border: 0; padding: 4px 8px; color: inherit; opacity: 0.75; text-decoration: underline; font: inherit; cursor: pointer; }
#dlg-inapp .dlg-btns .btn { text-decoration: none; text-align: center; }
