.game-page {
  min-height: 100vh;
}

.game-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--line);
}

.game-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  min-width: 0;
}

.game-top h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0.04em;
  font-size: clamp(1.35rem, 3.4vw, 1.85rem);
  line-height: 0.95;
  color: var(--paper);
}

.game-top .account {
  justify-content: flex-end;
}

.game-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.25rem 1rem 2rem;
  gap: 1rem;
}

.hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem 1.25rem;
  width: min(100%, 480px);
}

.hud .stat {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 0.9rem;
}

.hud .stat strong {
  color: var(--acid);
  font-weight: 500;
}

#stage {
  width: min(100%, 480px);
  aspect-ratio: 1;
  border: 1px solid var(--line);
  background: var(--board);
  position: relative;
  overflow: hidden;
}

#stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.game-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  max-width: 28rem;
  line-height: 1.45;
}

.stub-panel {
  width: min(100%, 480px);
  padding: 2rem 1.5rem;
  border: 1px dashed var(--line);
  text-align: center;
}

.stub-panel h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 2rem;
  letter-spacing: 0.04em;
  font-weight: 400;
}

.stub-panel p {
  margin: 0.75rem 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.stub-panel code {
  color: var(--acid);
  font-size: 0.85rem;
}

.rules {
  margin: 1.25rem auto 0;
  max-width: 36rem;
  text-align: left;
}
.rules h2 {
  margin: 0 0 0.45rem;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 400;
  letter-spacing: 0.05em;
  text-align: center;
}
.rules ol {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--muted);
  line-height: 1.5;
}
.rules li + li { margin-top: 0.35rem; }

#tg-end {
  position: relative;
  margin: auto;
  text-align: center;
  background: var(--panel);
  color: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.4rem 1.5rem 1.2rem;
  width: min(26rem, calc(100vw - 2rem));
}
#tg-end::backdrop { background: rgba(0, 0, 0, 0.72); }
#tg-end .dialog-x {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  width: 1.7rem;
  height: 1.7rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}
#tg-end .dialog-x:hover, #tg-end .dialog-x:focus-visible { color: var(--paper); }
#tg-end .result-label {
  margin: 0;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--acid);
  font-size: 0.75rem;
}
#tg-end h2 {
  margin: 0.35rem 0 0.45rem;
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0.04em;
  font-size: 2rem;
}
#tg-end p { margin: 0.35rem 0 0; color: var(--muted); line-height: 1.45; }
#tg-end [data-note][hidden], #tg-end [data-account][hidden] { display: none; }
#tg-end [data-account] {
  margin-top: 0.9rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}
#tg-end .tg-end-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem;
  margin-top: 1rem;
}
#tg-end .btn { padding: 0.55rem 0.95rem; }

.room-box {
  width: min(100%, 480px);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem 1rem 1rem;
  display: grid;
  gap: 0.7rem;
}
[data-local-only][hidden] { display: none !important; }
.room-box[hidden],
.room-box [hidden] { display: none !important; }
.room-box p { margin: 0; color: var(--muted); line-height: 1.4; }
.room-box form { display: grid; gap: 0.55rem; }
.room-code-label {
  text-align: center;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.75rem;
}
.room-code {
  margin: 0.15rem 0 0.35rem;
  text-align: center;
  font-family: var(--font-display);
  font-size: 2.6rem;
  letter-spacing: 0.22em;
  color: var(--paper);
  line-height: 1;
  user-select: all;
}
.room-row { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.room-row .btn { flex: 1; }
.room-box button:disabled { opacity: 0.55; cursor: default; transform: none; }
.room-options:empty { display: none; }
.room-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  color: var(--muted);
}
.room-field select,
.room-box input {
  font: inherit;
  color: var(--paper);
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  min-width: 0;
}
.room-box input { flex: 1; }
.room-seats { margin: 0; padding-left: 1.1rem; color: var(--muted); }
.room-seats li + li { margin-top: 0.2rem; }

#tg-mode {
  position: relative;
  margin: auto;
  background: var(--panel);
  color: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.4rem 1.5rem 1.2rem;
  width: min(26rem, calc(100vw - 2rem));
}
#tg-mode.tg-mode-grid {
  width: min(40rem, calc(100vw - 2rem));
}
#tg-mode::backdrop { background: rgba(0, 0, 0, 0.72); }
#tg-mode .dialog-x {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  width: 1.7rem;
  height: 1.7rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}
#tg-mode h2 {
  margin: 0.35rem 0 0.2rem;
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0.04em;
  font-size: 1.8rem;
}
#tg-mode .result-label {
  margin: 0;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--acid);
  font-size: 0.75rem;
}
.tg-mode-list { display: grid; gap: 0.5rem; margin-top: 1rem; }
.tg-mode-list.cols-2 { grid-template-columns: 1fr 1fr; }
.tg-mode-list.cols-2 .tg-choice {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 4.6rem;
  padding: 0.75rem 0.7rem;
  line-height: 1.25;
}
.tg-choice {
  text-align: left;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  background: var(--board);
  color: var(--paper);
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
}
.tg-choice strong { display: block; font-weight: 600; }
.tg-choice small { display: block; margin-top: 0.15rem; color: var(--muted); }
#tg-login {
  margin: auto;
  background: var(--panel);
  color: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.4rem 1.5rem 1.2rem;
  width: min(26rem, calc(100vw - 2rem));
}
#tg-login::backdrop { background: rgba(0, 0, 0, 0.72); }
#tg-login h2 {
  margin: 0.35rem 0 0.2rem;
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0.04em;
  font-size: 1.8rem;
}
#tg-login .result-label {
  margin: 0;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--acid);
  font-size: 0.75rem;
}
#tg-login p { margin: 0.7rem 0 0; color: var(--muted); }
#tg-login .btn { margin-top: 1.1rem; text-decoration: none; }
#mode-change { margin-left: 0.45rem; padding: 0.2rem 0.55rem; }

button.your-turn {
  border-color: var(--acid);
  box-shadow: 0 0 0 2px var(--acid);
}
