:root {
  --bg: #f4f1e8;
  --paper: #fffaf0;
  --paper-soft: #f8f0dd;
  --paper-2: #ede6d6;
  --ink: #151515;
  --muted: #6f6a5f;
  --line: #d8cdb8;
  --soft: #e8ddc9;
  --panel: rgba(255, 250, 240, 0.9);
  --wood-light: #e8c47b;
  --wood-mid: #d8a85b;
  --wood-dark: #b8833e;
  --grid: rgba(70, 45, 20, 0.58);
  --accent: #0d6848;
  --accent-hover: #09543a;
  --danger: #b6402a;
  --danger-dark: #7d291d;
  --gold: #d7a83e;
  --silver: #b9b5aa;
  --bronze: #b97838;
  --shadow: 0 18px 42px rgba(53, 38, 18, 0.12);
  --shadow-strong: 0 28px 70px rgba(54, 38, 18, 0.24);
  color-scheme: light;
  font-family:
    "Noto Sans", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  position: relative;
  overflow-x: hidden;
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(rgba(247, 242, 231, 0.18), rgba(247, 242, 231, 0.18)),
    url("./assets/japanese-bg.png") center top / cover fixed,
    linear-gradient(135deg, #f7f2e7 0%, #ebe8df 100%);
  color: var(--ink);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.28;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.52), transparent 36%),
    linear-gradient(180deg, rgba(255, 250, 240, 0.1), rgba(255, 250, 240, 0.36));
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.34;
  background-image:
    linear-gradient(rgba(90, 72, 44, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(90, 72, 44, 0.02) 1px, transparent 1px);
  background-size: 26px 26px, 32px 32px;
  mix-blend-mode: multiply;
}

body.visual-nihon-garden {
  --bg: #f6f1df;
  --paper: #fffaf0;
  --paper-soft: #f8efd7;
  --ink: #1d1a14;
  --muted: #675f4c;
  --line: rgba(148, 112, 61, 0.28);
  --panel: rgba(255, 250, 236, 0.88);
  --accent: #0d6848;
  --accent-hover: #09543a;
  --shadow: 0 18px 42px rgba(63, 47, 21, 0.14);
  --shadow-strong: 0 30px 80px rgba(72, 51, 18, 0.28);
}

body.visual-cyber-dojo {
  --bg: #050a0d;
  --paper: #101a21;
  --paper-soft: #142630;
  --paper-2: #1b303b;
  --ink: #edfefa;
  --muted: #9ebbb9;
  --line: rgba(83, 255, 228, 0.22);
  --panel: rgba(9, 18, 23, 0.82);
  --accent: #33f0d2;
  --accent-hover: #7fffea;
  --danger: #ff5470;
  --danger-dark: #ff8aa0;
  --gold: #e5ff7a;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.42);
  --shadow-strong: 0 30px 90px rgba(0, 0, 0, 0.58);
  color-scheme: dark;
}

body.visual-cosmic-silence {
  --bg: #060712;
  --paper: #13182c;
  --paper-soft: #1a213b;
  --paper-2: #242c4a;
  --ink: #f2f3ff;
  --muted: #adb3d4;
  --line: rgba(187, 197, 255, 0.22);
  --panel: rgba(14, 18, 36, 0.84);
  --accent: #b9a7ff;
  --accent-hover: #d0c4ff;
  --danger: #ff7d9c;
  --danger-dark: #ffadbf;
  --gold: #ffd979;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.38);
  --shadow-strong: 0 30px 90px rgba(0, 0, 0, 0.56);
  color-scheme: dark;
}

body.visual-cyber-dojo,
body.visual-cosmic-silence {
  background:
    radial-gradient(circle at 12% 18%, rgba(68, 238, 217, 0.14), transparent 26%),
    radial-gradient(circle at 84% 12%, rgba(161, 132, 255, 0.16), transparent 30%),
    linear-gradient(135deg, var(--bg), #080b14 100%);
}

body.visual-cosmic-silence::before {
  opacity: 0.42;
  background:
    radial-gradient(circle at 68% 24%, rgba(156, 128, 255, 0.22), transparent 20%),
    radial-gradient(circle at 28% 62%, rgba(70, 124, 255, 0.14), transparent 28%);
}

body.visual-cyber-dojo::after,
body.visual-cosmic-silence::after {
  opacity: 0.28;
  mix-blend-mode: screen;
}

button,
input,
select {
  font: inherit;
}

.app {
  position: relative;
  z-index: 1;
  width: min(1500px, calc(100vw - 48px));
  margin: 0 auto;
  padding: 32px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 0 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.brand > div:last-child {
  display: grid;
  align-content: center;
}

.logo-stamp {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--danger), var(--danger-dark));
  color: var(--paper);
  font-size: 30px;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(125, 41, 29, 0.25);
}

.topbar h1 {
  margin: 0;
  color: #1a1f1c;
  font-family: "Zen Kaku Gothic New", "Noto Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 60px;
  line-height: 1;
  letter-spacing: 0;
}

.topbar p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.status-line.hidden,
.status-line:empty {
  display: none;
}

.status-line.is-error {
  display: inline-block;
  margin-top: 8px;
  border: 1px solid rgba(182, 64, 42, 0.28);
  border-radius: 999px;
  background: rgba(255, 250, 240, 0.76);
  color: var(--danger-dark);
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 800;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-badge {
  color: #4c473e;
  font-size: 13px;
  font-weight: 850;
  white-space: nowrap;
}

.command-button,
.match-list button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 250, 240, 0.84);
  color: var(--ink);
  padding: 0 18px;
  font-weight: 850;
  cursor: pointer;
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    background 150ms ease,
    border-color 150ms ease;
}

.command-button:hover,
.match-list button:hover {
  transform: translateY(-1px);
  border-color: rgba(13, 104, 72, 0.38);
  background: var(--paper);
  box-shadow: 0 8px 20px rgba(20, 15, 10, 0.08);
}

.command-button:disabled,
.match-list button:disabled {
  cursor: default;
  opacity: 0.56;
  transform: none;
  box-shadow: none;
}

.command-button.wide {
  width: 100%;
  margin-top: 12px;
}

#createGameForm .command-button,
#pauseGameBtn,
.chat-form .command-button {
  border-color: var(--accent);
  background: linear-gradient(180deg, #0d7450, var(--accent));
  color: #fff;
}

#createGameForm .command-button:hover,
#pauseGameBtn:hover,
.chat-form .command-button:hover {
  background: var(--accent-hover);
}

#leaveGameBtn {
  background: rgba(255, 250, 240, 0.72);
  color: var(--ink);
  border-color: #bfae91;
}

.auth-layout,
.lobby-layout,
.game-layout {
  display: grid;
  align-items: start;
  gap: 26px;
}

.auth-layout {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.fame-panel {
  grid-column: 1 / -1;
}

.lobby-layout {
  grid-template-columns: minmax(360px, 440px) minmax(320px, 1fr);
}

.game-layout {
  grid-template-columns: minmax(620px, 1fr) 360px;
}

.auth-panel,
.create-panel,
.list-panel,
.side-panel section {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.38), transparent),
    var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.auth-panel h2,
.create-panel h2,
.list-panel h2 {
  margin: 0 0 16px;
  color: var(--ink);
  font-size: 22px;
  line-height: 1.1;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.panel-heading span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
}

.auth-panel,
.create-panel {
  display: grid;
  gap: 14px;
}

.setting-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.mode-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
}

.rules-link {
  min-height: 44px;
  border: 1px solid rgba(13, 104, 72, 0.28);
  border-radius: 10px;
  background: rgba(13, 104, 72, 0.08);
  color: var(--accent);
  padding: 0 14px;
  font-weight: 900;
  white-space: nowrap;
  cursor: pointer;
  transition:
    transform 150ms ease,
    border-color 150ms ease,
    background 150ms ease;
}

.rules-link:hover {
  transform: translateY(-1px);
  border-color: rgba(13, 104, 72, 0.48);
  background: rgba(13, 104, 72, 0.13);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

input,
select {
  min-height: 44px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 250, 240, 0.86);
  color: var(--ink);
  padding: 0 13px;
  font-size: 15px;
  outline: none;
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease,
    background 150ms ease;
}

body.visual-cyber-dojo input,
body.visual-cyber-dojo select,
body.visual-cosmic-silence input,
body.visual-cosmic-silence select {
  background: rgba(8, 14, 22, 0.72);
  color: var(--ink);
}

input:focus,
select:focus {
  border-color: rgba(13, 104, 72, 0.62);
  background: var(--paper);
  box-shadow: 0 0 0 4px rgba(13, 104, 72, 0.1);
}

.match-list,
.fame-list {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.match-list li,
.fame-list li {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-top: 1px solid rgba(216, 205, 184, 0.78);
  padding: 12px 0;
}

.match-list li:hover,
.fame-list li:hover {
  background: rgba(13, 104, 72, 0.035);
}

.match-list span,
.fame-list li > span:not(.fame-rank) {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.match-list button {
  min-height: 36px;
  background: var(--ink);
  color: #fff;
  padding: 0 13px;
}

.fame-list li {
  justify-content: stretch;
}

.fame-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: #efe5d0;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  line-height: 25px;
  margin-top: 0;
  padding: 0;
  text-align: center;
  font-variant-numeric: tabular-nums;
  box-shadow:
    inset 0 0 0 1px rgba(82, 55, 18, 0.24),
    inset 0 0 0 3px rgba(255, 255, 255, 0.24),
    inset 0 1px 2px rgba(255, 255, 255, 0.78),
    inset 0 -2px 4px rgba(81, 52, 14, 0.16),
    0 4px 9px rgba(54, 38, 18, 0.1);
}

.fame-rank.gold {
  background: radial-gradient(circle at 35% 28%, #ffe28b, var(--gold));
}

.fame-rank.silver {
  background: radial-gradient(circle at 35% 28%, #f5f2ea, var(--silver));
}

.fame-rank.bronze {
  background: radial-gradient(circle at 35% 28%, #e9a766, var(--bronze));
}

.fame-player {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 900;
}

.fame-list .current-user {
  margin-inline: -10px;
  padding-inline: 10px;
  border-radius: 10px;
  background: rgba(13, 104, 72, 0.08);
}

.empty-row {
  color: var(--muted);
  font-size: 13px;
}

.board-area {
  display: grid;
  min-width: 0;
  gap: 16px;
}

.score-strip {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(80px, 180px) auto minmax(120px, 1fr);
  align-items: center;
  gap: 18px;
  margin: 0;
}

.player-score {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  border-left: 0;
  padding: 0;
}

.player-score.terra {
  justify-content: end;
}

.player-score::before {
  content: "";
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--score-stone, radial-gradient(circle at 35% 28%, #5b5b5b 0%, #161616 48%, #000 100%));
  box-shadow:
    inset -4px -6px 10px rgba(0, 0, 0, 0.45),
    inset 3px 3px 8px rgba(255, 255, 255, 0.12),
    0 7px 14px rgba(0, 0, 0, 0.22);
}

.player-score.terra::before {
  order: 2;
  background: var(--score-stone, radial-gradient(circle at 35% 28%, #fff 0%, #eeeeee 48%, #b9b5aa 100%));
  box-shadow:
    inset -4px -6px 10px rgba(0, 0, 0, 0.13),
    inset 4px 4px 10px rgba(255, 255, 255, 0.8),
    0 7px 14px rgba(0, 0, 0, 0.18);
}

.player-name {
  min-width: 0;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 250, 240, 0.62);
  color: #151515;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0.02em;
  padding: 3px 8px;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.72);
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.player-score strong {
  color: var(--ink);
  font-size: 32px;
  line-height: 1;
}

.score-track {
  position: relative;
  height: 2px;
  overflow: visible;
  background: rgba(111, 106, 95, 0.36);
}

.score-track::after {
  content: "Realtime";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(13, 104, 72, 0.36);
  border-radius: 999px;
  background: var(--paper);
  color: var(--accent);
  padding: 7px 18px;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 8px 20px rgba(13, 104, 72, 0.08);
}

.score-strip.realtime-mode .score-track::after {
  display: none;
}

.score-strip.nards-mode .score-track::after {
  content: "Nards";
}

.score-fill {
  position: absolute;
  top: -3px;
  bottom: auto;
  width: 0%;
  height: 8px;
  border-radius: 999px;
  opacity: 0.65;
  transition: width 180ms linear;
}

.score-fill.jade {
  left: 0;
  background: var(--accent);
}

.score-fill.terra {
  right: 0;
  left: auto;
  background: var(--danger);
}

.hud-meters {
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 12px;
}

.meter-block {
  display: grid;
  justify-items: center;
  gap: 5px;
}

.meter-caption {
  color: var(--muted);
  font-size: 10px;
  font-weight: 950;
  letter-spacing: 0.06em;
  line-height: 1;
  text-transform: uppercase;
}

.meter-subvalue {
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  line-height: 1;
}

.cooldown-meter,
.pass-meter {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  color: var(--ink);
  font-size: 14px;
  font-weight: 950;
  line-height: 1;
  box-shadow:
    inset 0 0 0 1px rgba(82, 55, 18, 0.16),
    0 8px 18px rgba(54, 38, 18, 0.12);
}

.cooldown-meter {
  background:
    radial-gradient(circle at center, var(--paper) 0 54%, transparent 55%),
    conic-gradient(var(--accent) var(--cooldown-progress), rgba(216, 205, 184, 0.9) 0);
}

.cooldown-meter.opponent {
  background:
    radial-gradient(circle at center, var(--paper) 0 54%, transparent 55%),
    conic-gradient(var(--danger) var(--cooldown-progress), rgba(216, 205, 184, 0.9) 0);
}

.pass-meter {
  border: 1px solid rgba(216, 205, 184, 0.9);
  background: rgba(255, 250, 240, 0.82);
  color: var(--muted);
  font-size: 13px;
}

.pass-meter.is-low {
  border-color: rgba(182, 64, 42, 0.42);
  background: rgba(255, 235, 218, 0.92);
  color: var(--danger-dark);
}

.canvas-wrap {
  position: relative;
  overflow: hidden;
  width: min(100%, calc(100vh - 210px), 880px);
  min-width: 560px;
  margin: 0 auto;
  padding: clamp(18px, 2.4vw, 34px);
  border: 1px solid rgba(90, 55, 20, 0.28);
  border-radius: 9px;
  background:
    radial-gradient(circle at 25% 20%, rgba(255, 255, 255, 0.22), transparent 28%),
    linear-gradient(135deg, var(--wood-light), var(--wood-mid) 55%, var(--wood-dark));
  box-shadow:
    var(--shadow-strong),
    inset 0 0 0 1px rgba(90, 55, 20, 0.28),
    inset 0 8px 18px rgba(255, 255, 255, 0.18);
}

.game-layout.visual-nihon-garden .canvas-wrap {
  border-color: rgba(104, 69, 30, 0.34);
  background:
    radial-gradient(circle at 18% 16%, rgba(255, 255, 255, 0.34), transparent 30%),
    linear-gradient(135deg, #e9c779, #d2a052 55%, #9d6630);
}

.game-layout.visual-cyber-dojo .canvas-wrap {
  border-color: rgba(70, 255, 226, 0.36);
  background:
    linear-gradient(135deg, rgba(64, 250, 223, 0.16), transparent 22%),
    repeating-linear-gradient(135deg, rgba(80, 255, 226, 0.1) 0 1px, transparent 1px 16px),
    linear-gradient(135deg, #101820, #0b141b 55%, #03070a);
  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.54),
    0 0 38px rgba(51, 240, 210, 0.18),
    inset 0 0 0 1px rgba(73, 255, 230, 0.22);
}

.game-layout.visual-cosmic-silence .canvas-wrap {
  border-color: rgba(188, 198, 255, 0.3);
  background:
    radial-gradient(circle at 76% 18%, rgba(180, 154, 255, 0.28), transparent 25%),
    radial-gradient(circle at 24% 72%, rgba(82, 132, 255, 0.18), transparent 28%),
    linear-gradient(135deg, #151a31, #0c1022 55%, #05060d);
  box-shadow:
    0 24px 78px rgba(0, 0, 0, 0.56),
    0 0 42px rgba(149, 126, 255, 0.18),
    inset 0 0 0 1px rgba(202, 210, 255, 0.18);
}

#gameCanvas {
  display: block;
  width: 100%;
  border-radius: 3px;
  aspect-ratio: 1;
  touch-action: manipulation;
  cursor: crosshair;
}

.winner {
  position: absolute;
  left: 50%;
  top: 30px;
  transform: translateX(-50%);
  min-width: min(540px, calc(100% - 40px));
  padding: 16px 22px;
  border-radius: 12px;
  background: rgba(21, 21, 21, 0.94);
  color: #fff;
  text-align: center;
  font-size: 18px;
  font-weight: 900;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.18);
}

.side-panel {
  display: grid;
  gap: 14px;
}

.section-title {
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.resource-row,
.stone-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.resource-row span,
.hint-line {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.resource-row strong {
  color: var(--ink);
  font-size: 36px;
  font-weight: 950;
  line-height: 1;
}

.stone-bowl {
  position: relative;
  height: 118px;
  margin: 12px 0 8px;
  overflow: hidden;
  border-radius: 8px;
  background:
    radial-gradient(ellipse at 50% 82%, rgba(49, 34, 22, 0.2) 0%, transparent 54%),
    linear-gradient(180deg, rgba(255, 250, 240, 0.3), rgba(225, 214, 193, 0.28));
  box-shadow: inset 0 0 0 1px rgba(139, 104, 64, 0.16);
}

.game-layout.visual-cyber-dojo .stone-bowl {
  background:
    radial-gradient(ellipse at 50% 82%, rgba(57, 255, 226, 0.16) 0%, transparent 54%),
    linear-gradient(180deg, rgba(18, 40, 48, 0.78), rgba(7, 13, 18, 0.9));
  box-shadow:
    inset 0 0 0 1px rgba(73, 255, 230, 0.22),
    0 0 24px rgba(51, 240, 210, 0.12);
}

.game-layout.visual-cosmic-silence .stone-bowl {
  background:
    radial-gradient(ellipse at 50% 82%, rgba(188, 198, 255, 0.18) 0%, transparent 54%),
    radial-gradient(circle at 24% 24%, rgba(148, 122, 255, 0.2), transparent 36%),
    linear-gradient(180deg, rgba(28, 34, 64, 0.82), rgba(7, 8, 19, 0.92));
  box-shadow:
    inset 0 0 0 1px rgba(201, 210, 255, 0.2),
    0 0 24px rgba(161, 132, 255, 0.14);
}

.stone-bowl.hidden {
  display: none;
}

.stone-bowl::before {
  content: "";
  position: absolute;
  right: 8%;
  bottom: 16px;
  left: 8%;
  height: 54px;
  border-radius: 0 0 46% 46% / 0 0 100% 100%;
  background:
    linear-gradient(180deg, rgba(167, 116, 68, 0.18), rgba(80, 49, 27, 0.34)),
    linear-gradient(90deg, rgba(255, 250, 240, 0.44), rgba(163, 104, 52, 0.42), rgba(79, 48, 25, 0.5));
  box-shadow:
    inset 0 -11px 18px rgba(54, 32, 17, 0.28),
    inset 14px 0 16px rgba(255, 250, 240, 0.2),
    0 12px 18px rgba(55, 39, 19, 0.13);
}

.game-layout.visual-cyber-dojo .stone-bowl::before {
  background:
    linear-gradient(180deg, rgba(63, 255, 226, 0.18), rgba(11, 21, 27, 0.72)),
    linear-gradient(90deg, rgba(172, 255, 244, 0.18), rgba(20, 58, 66, 0.6), rgba(0, 0, 0, 0.7));
}

.game-layout.visual-cosmic-silence .stone-bowl::before {
  background:
    linear-gradient(180deg, rgba(210, 202, 255, 0.16), rgba(33, 29, 72, 0.62)),
    linear-gradient(90deg, rgba(255, 255, 255, 0.14), rgba(80, 76, 142, 0.52), rgba(8, 9, 22, 0.72));
}

.stone-bowl-rim {
  position: absolute;
  right: 7%;
  bottom: 54px;
  left: 7%;
  height: 24px;
  border: 2px solid rgba(93, 58, 31, 0.52);
  border-radius: 50%;
  background:
    radial-gradient(ellipse at 50% 48%, rgba(43, 27, 17, 0.08) 0%, rgba(43, 27, 17, 0.22) 64%, transparent 66%),
    linear-gradient(180deg, rgba(255, 250, 240, 0.58), rgba(166, 107, 57, 0.52));
  box-shadow:
    inset 0 3px 8px rgba(255, 250, 240, 0.42),
    inset 0 -5px 10px rgba(67, 40, 21, 0.24),
    0 5px 8px rgba(52, 35, 16, 0.12);
  pointer-events: none;
}

.game-layout.visual-cyber-dojo .stone-bowl-rim {
  border-color: rgba(70, 255, 226, 0.46);
  background:
    radial-gradient(ellipse at 50% 48%, rgba(57, 255, 226, 0.1) 0%, rgba(57, 255, 226, 0.18) 64%, transparent 66%),
    linear-gradient(180deg, rgba(141, 255, 241, 0.26), rgba(17, 43, 52, 0.7));
}

.game-layout.visual-cosmic-silence .stone-bowl-rim {
  border-color: rgba(199, 207, 255, 0.38);
  background:
    radial-gradient(ellipse at 50% 48%, rgba(207, 212, 255, 0.1) 0%, rgba(157, 132, 255, 0.18) 64%, transparent 66%),
    linear-gradient(180deg, rgba(224, 224, 255, 0.22), rgba(45, 40, 93, 0.72));
}

.stone-bowl-pile {
  position: absolute;
  z-index: 2;
  right: 12%;
  bottom: 34px;
  left: 12%;
  height: 74px;
}

.bowl-stone,
.stone-bowl-growing span {
  position: absolute;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 28%, rgba(255, 255, 255, 0.66), rgba(204, 205, 198, 0.48) 18%, transparent 25%),
    radial-gradient(circle at 34% 28%, #5b5f5d 0%, #242928 52%, #090b0b 100%);
  box-shadow:
    inset -4px -5px 8px rgba(0, 0, 0, 0.48),
    inset 2px 2px 5px rgba(255, 255, 255, 0.12),
    0 4px 8px rgba(20, 14, 9, 0.2);
}

.game-layout.visual-cyber-dojo .bowl-stone,
.game-layout.visual-cyber-dojo .stone-bowl-growing span {
  background:
    radial-gradient(circle at 35% 28%, rgba(185, 255, 246, 0.72), rgba(84, 255, 226, 0.3) 18%, transparent 25%),
    radial-gradient(circle at 34% 28%, #66717a 0%, #11181d 52%, #020405 100%);
  box-shadow:
    inset -4px -5px 8px rgba(0, 0, 0, 0.58),
    inset 2px 2px 5px rgba(120, 255, 235, 0.18),
    0 0 10px rgba(80, 255, 226, 0.16);
}

.game-layout.visual-cosmic-silence .bowl-stone,
.game-layout.visual-cosmic-silence .stone-bowl-growing span {
  background:
    radial-gradient(circle at 35% 28%, rgba(255, 255, 255, 0.78), rgba(200, 214, 255, 0.42) 18%, transparent 25%),
    radial-gradient(circle at 34% 28%, #53608d 0%, #13172a 52%, #03040b 100%);
  box-shadow:
    inset -4px -5px 8px rgba(0, 0, 0, 0.56),
    inset 2px 2px 5px rgba(221, 226, 255, 0.16),
    0 0 10px rgba(161, 132, 255, 0.18);
}

.bowl-stone {
  left: var(--x);
  top: var(--y);
  transform: translate(-50%, -50%) rotate(var(--r)) scale(var(--s));
}

.bowl-overflow-count {
  position: absolute;
  right: 4px;
  bottom: 9px;
  min-width: 25px;
  border-radius: 999px;
  background: rgba(255, 250, 240, 0.88);
  color: var(--ink);
  font-size: 11px;
  font-weight: 950;
  line-height: 20px;
  text-align: center;
  box-shadow: 0 4px 10px rgba(20, 14, 9, 0.14);
}

.stone-bowl-growing {
  position: absolute;
  z-index: 3;
  top: 16px;
  left: 50%;
  width: 28px;
  height: 28px;
  transform: translateX(-50%) scale(calc(0.22 + var(--growth) * 0.82));
  opacity: calc(0.28 + var(--growth) * 0.72);
  transition: transform 120ms linear, opacity 120ms linear;
}

.stone-bowl-growing span {
  inset: 0;
  width: 28px;
  height: 28px;
}

.stone-bowl-growing span::before,
.stone-bowl-growing span::after {
  content: "";
  position: absolute;
  inset: 6px 11px;
  border-radius: 999px;
  background: rgba(255, 250, 240, 0);
  transform: rotate(24deg) scaleY(0);
  transition: background 120ms linear, transform 120ms linear;
}

.stone-bowl-growing span::after {
  inset: 7px 13px 5px 10px;
  transform: rotate(-44deg) scaleY(0);
}

.stone-bowl-growing.is-cracking span::before,
.stone-bowl-growing.is-cracking span::after {
  background: rgba(255, 250, 240, 0.8);
  transform: rotate(24deg) scaleY(1);
}

.stone-bowl-growing.is-cracking span::after {
  transform: rotate(-44deg) scaleY(1);
}

.stone-bowl-growing.is-vanishing {
  opacity: 0.18;
  transform: translateX(-50%) translateY(12px) scale(0.58);
}

.stone-bowl-burst {
  position: absolute;
  z-index: 1;
  top: 25px;
  left: 50%;
  width: 54px;
  height: 28px;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(199, 151, 88, 0.45), transparent 64%);
  opacity: 0;
  transform: translateX(-50%) scale(0.3);
  transition: opacity 120ms linear, transform 120ms linear;
}

.stone-bowl.is-full .stone-bowl-burst {
  opacity: calc(var(--growth) * 0.45);
  transform: translateX(-50%) scale(calc(0.5 + var(--growth) * 0.9));
}

.cooldown-bar {
  height: 9px;
  margin: 14px 0 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #ded4c2;
}

#cooldownFill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 120ms linear;
}

.nards-cards {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  border-top: 1px solid rgba(216, 205, 184, 0.78);
  padding-top: 14px;
}

.nards-open-card,
.nards-hand {
  display: grid;
  gap: 8px;
}

.nards-hand {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.nards-card {
  display: grid;
  gap: 4px;
  min-height: 58px;
  border: 1px solid rgba(139, 104, 64, 0.34);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 250, 240, 0.96), rgba(239, 229, 208, 0.88));
  color: var(--ink);
  padding: 9px 10px;
  text-align: left;
  box-shadow: 0 7px 16px rgba(54, 38, 18, 0.08);
}

button.nards-card {
  cursor: pointer;
}

button.nards-card:hover:not(:disabled) {
  border-color: rgba(13, 104, 72, 0.46);
  background: var(--paper);
}

.nards-card:disabled {
  cursor: default;
  opacity: 0.58;
}

.nards-card span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.nards-card strong {
  color: var(--ink);
  font-size: 18px;
  line-height: 1.05;
}

.nards-card.active {
  border-color: rgba(21, 21, 21, 0.42);
  background:
    linear-gradient(135deg, rgba(21, 21, 21, 0.92), rgba(61, 56, 47, 0.92));
  color: #fffaf0;
}

.nards-card.active span,
.nards-card.active strong {
  color: #fffaf0;
}

.nards-card.opponent {
  background:
    linear-gradient(135deg, rgba(241, 241, 234, 0.9), rgba(210, 209, 198, 0.84));
}

.nards-card.placeholder,
.nards-hand-empty {
  min-height: auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.nards-hand-empty {
  grid-column: 1 / -1;
}

.stone-row {
  padding: 12px 0;
  border-top: 1px solid rgba(216, 205, 184, 0.78);
}

.stone-row:first-of-type {
  border-top: 0;
}

.stone-row span:nth-child(2) {
  flex: 1;
  font-weight: 900;
}

.stone-row strong {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.stone-dot {
  display: inline-block;
  flex: 0 0 auto;
  border-radius: 50%;
}

.stone-dot.small {
  width: 22px;
  height: 22px;
  background: radial-gradient(circle at 35% 28%, #5b5b5b 0%, #161616 48%, #000 100%);
  box-shadow:
    inset -4px -6px 10px rgba(0, 0, 0, 0.45),
    inset 3px 3px 8px rgba(255, 255, 255, 0.12),
    0 7px 14px rgba(0, 0, 0, 0.22);
}

.stone-dot.medium {
  width: 26px;
  height: 26px;
  background: radial-gradient(circle at 35% 28%, #47c3a6, #16785f 70%, #0f4f3f);
  box-shadow: inset -4px -6px 9px rgba(0, 0, 0, 0.22), 0 7px 14px rgba(0, 0, 0, 0.16);
}

.stone-dot.large {
  width: 31px;
  height: 31px;
  background: radial-gradient(circle at 35% 28%, #df8356, #b94e2f 70%, #78301f);
  box-shadow: inset -4px -6px 9px rgba(0, 0, 0, 0.24), 0 7px 14px rgba(0, 0, 0, 0.18);
}

.chat-panel {
  min-height: 240px;
}

.chat-messages {
  display: grid;
  align-content: start;
  gap: 0;
  max-height: 190px;
  overflow: auto;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chat-messages li {
  border-bottom: 1px solid rgba(216, 205, 184, 0.75);
  padding: 10px 0;
}

.chat-messages span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.chat-messages p {
  overflow-wrap: anywhere;
  margin: 4px 0 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
}

.chat-messages .chat-empty {
  color: var(--muted);
  font-size: 13px;
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 12px;
}

.chat-form .command-button {
  min-height: 42px;
  padding: 0 12px;
}

.group-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 0;
}

.group-stats div {
  border-top: 1px solid rgba(216, 205, 184, 0.78);
  padding-top: 12px;
}

.group-stats dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.group-stats dd {
  margin: 5px 0 0;
  font-size: 24px;
  font-weight: 950;
}

.event-log {
  display: grid;
  gap: 8px;
  max-height: 180px;
  overflow: auto;
  margin: 0;
  padding: 0 0 0 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.event-log li::marker {
  color: var(--danger);
  font-weight: 900;
}

.rules-dialog {
  width: min(720px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.5), transparent),
    rgba(255, 250, 240, 0.96);
  color: var(--ink);
  padding: 0;
  box-shadow: 0 32px 80px rgba(28, 22, 14, 0.28);
}

.rules-dialog::backdrop {
  background: rgba(20, 15, 10, 0.36);
  backdrop-filter: blur(4px);
}

.rules-dialog article {
  display: grid;
  gap: 18px;
  padding: 24px;
}

.rules-dialog header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid rgba(216, 205, 184, 0.82);
  padding-bottom: 14px;
}

.rules-dialog h2 {
  margin: 4px 0 0;
  font-family: "Zen Kaku Gothic New", "Noto Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 34px;
  line-height: 1;
}

.dialog-close {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 250, 240, 0.86);
  color: var(--ink);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.rules-summary {
  margin: 0;
  color: #3d382f;
  font-size: 16px;
  font-weight: 750;
  line-height: 1.45;
}

.rules-body {
  display: grid;
  gap: 16px;
}

.rules-body section {
  border-top: 1px solid rgba(216, 205, 184, 0.72);
  padding-top: 14px;
}

.rules-body h3 {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 15px;
}

.rules-body ul {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 19px;
  color: var(--muted);
  line-height: 1.45;
}

.rules-body li::marker {
  color: var(--danger);
}

.rule-figure {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.rule-diagram {
  display: grid;
  grid-template-columns: repeat(var(--rule-cols), 26px);
  gap: 4px;
  width: max-content;
  max-width: 100%;
  border: 1px solid rgba(139, 104, 64, 0.28);
  border-radius: 8px;
  background: linear-gradient(135deg, #efcb83, #d8a85b);
  padding: 8px;
}

.rule-cell {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: #151515;
  font-size: 11px;
  font-weight: 950;
}

.rule-cell.empty {
  border-radius: 4px;
  background:
    linear-gradient(rgba(70, 45, 20, 0.34), rgba(70, 45, 20, 0.34)) center / 100% 1px no-repeat,
    linear-gradient(90deg, rgba(70, 45, 20, 0.34), rgba(70, 45, 20, 0.34)) center / 1px 100% no-repeat;
}

.rule-cell.own {
  background: radial-gradient(circle at 35% 28%, #5b5b5b, #111 62%, #000);
  color: #fffaf0;
}

.rule-cell.opponent,
.rule-cell.dead {
  background: radial-gradient(circle at 35% 28%, #fff, #eee 52%, #b9b5aa);
  color: #151515;
}

.rule-cell.dead {
  outline: 2px dashed rgba(182, 64, 42, 0.72);
}

.rule-cell.eye,
.rule-cell.ghost {
  border: 2px solid rgba(13, 104, 72, 0.62);
  background: rgba(255, 250, 240, 0.72);
  color: var(--accent);
}

.rule-cell.ghost {
  border-style: dashed;
}

.rule-gap {
  height: 4px;
}

.rule-figure p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.hidden {
  display: none !important;
}

@media (max-width: 1180px) {
  .lobby-layout,
  .game-layout {
    grid-template-columns: 1fr;
  }

  .side-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .canvas-wrap {
    width: min(100%, 860px);
    min-width: 0;
  }
}

@media (max-width: 820px) {
  .app {
    width: min(100vw - 24px, 720px);
    padding-top: 20px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar h1 {
    font-size: 42px;
  }

  .logo-stamp {
    width: 48px;
    height: 48px;
    font-size: 26px;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
    gap: 8px;
  }

  .top-actions .user-badge {
    white-space: normal;
  }

  .top-actions .command-button {
    width: 100%;
  }

  .auth-layout,
  .score-strip,
  .side-panel,
  .chat-form,
  .mode-field,
  .setting-grid {
    grid-template-columns: 1fr;
  }

  .rules-link {
    width: 100%;
  }

  .player-score.terra {
    justify-content: start;
  }

  .score-track {
    height: 34px;
    background: transparent;
  }

  .score-strip.realtime-mode .score-track {
    height: 2px;
  }

  .hud-meters {
    justify-content: start;
  }

  .score-fill {
    display: none;
  }

  .canvas-wrap {
    padding: 14px;
  }

  .fame-list li,
  .match-list li {
    align-items: flex-start;
    flex-direction: column;
  }
}
