:root {
  /* --- Vintage High-Stakes / Casino Boardgame UI --- */
  --bg-0: #0e1016; /* table shadow */
  --bg-1: #141925; /* leather */
  --bg-2: #1a2131; /* highlight */

  --surface-0: rgba(23, 26, 34, 0.92);
  --surface-1: rgba(18, 20, 26, 0.82);
  --surface-2: rgba(30, 34, 45, 0.92);

  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.22);

  --text: #eef2ff;
  --muted: rgba(238, 242, 255, 0.72);
  --soft: rgba(238, 242, 255, 0.56);

  /* Light-surface text tokens (inputs, chips, badges on light bg) */
  --ink: #181926;
  --ink-muted: rgba(24, 25, 38, 0.72);
  --ink-soft: rgba(24, 25, 38, 0.56);
  --line-ink: rgba(24, 25, 38, 0.18);
  --line-ink-strong: rgba(24, 25, 38, 0.28);

  --primary: #c5a059; /* gold */
  --primary-2: #8c5a2b; /* bronze */
  --good: #38b86a; /* emerald */
  --warn: #e03131;
  --plus: #ffb74d;
  --minus: #e03131;

  --blue-glow: rgba(197, 160, 89, 0.18);
  --good-glow: rgba(56, 184, 106, 0.18);
  --warn-glow: rgba(224, 49, 49, 0.18);

  --shadow-lg: 0 22px 56px rgba(0, 0, 0, 0.55);
  --shadow-md: 0 14px 38px rgba(0, 0, 0, 0.42);
  --shadow-sm: 0 8px 18px rgba(0, 0, 0, 0.32);
  --shadow-depth: 2px;
  --shine: inset 0 1px 0 rgba(255, 255, 255, 0.06), inset 0 -10px 24px rgba(0, 0, 0, 0.25);
  --focus-ring: 0 0 0 3px rgba(197, 160, 89, 0.26), 0 0 0 7px rgba(140, 90, 43, 0.18);

  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-sm: 12px;

  --anim-fast: 140ms;
  --anim-mid: 220ms;
  --anim-slow: 500ms;
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-right: env(safe-area-inset-right, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-left: env(safe-area-inset-left, 0px);
  --keyboard-offset: 0px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--text);
  background:
    radial-gradient(circle at 18% 14%, rgba(197, 160, 89, 0.16) 0%, transparent 42%),
    radial-gradient(circle at 78% 22%, rgba(140, 90, 43, 0.14) 0%, transparent 48%),
    radial-gradient(circle at 50% 115%, rgba(0, 0, 0, 0.76) 0%, transparent 54%),
    linear-gradient(180deg, var(--bg-0) 0%, var(--bg-1) 100%);
  font-family:
    ui-rounded,
    "Segoe UI Rounded",
    "Apple SD Gothic Neo",
    "Malgun Gothic",
    "Noto Sans KR",
    "Segoe UI",
    sans-serif;
  letter-spacing: -0.01em;
  position: relative;
}

button,
a,
input,
select,
textarea,
.custom-select-trigger,
.custom-select-option,
.cell {
  -webkit-tap-highlight-color: transparent;
}

body.mode-room {
  background: var(--bg-0);
}

body.mode-room::after {
  opacity: 0.12;
}

body::before,
body::after {
  content: "";
  position: fixed;
  pointer-events: none;
  z-index: 0;
}

body::before {
  display: none;
}

body::after {
  inset: 0;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.04) 1px, transparent 2px),
    radial-gradient(circle at 2px 2px, rgba(255, 255, 255, 0.02) 1px, transparent 3px);
  background-size: 20px 20px, 28px 28px;
  background-position: 0 0, 8px 12px;
  opacity: 0.14;
}

@keyframes bgFloat {
  0% {
    transform: translate3d(-2.5%, -1.5%, 0) scale(1);
  }
  100% {
    transform: translate3d(3.5%, 2.5%, 0) scale(1.07);
  }
}

.app-shell {
  width: min(1540px, 100%);
  margin: 0 auto;
  padding: 14px;
  padding:
    calc(14px + env(safe-area-inset-top, 0px))
    calc(14px + env(safe-area-inset-right, 0px))
    calc(14px + env(safe-area-inset-bottom, 0px))
    calc(14px + env(safe-area-inset-left, 0px));
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.screen {
  margin-top: 12px;
}

.panel {
  border: 3px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-0);
  box-shadow: var(--shadow-md), var(--shine);
  padding: 14px;
  position: relative;
}

.panel.select-overlay {
  z-index: 90;
}

.panel-glass {
  border-color: var(--line-strong);
  background: var(--surface-1);
  box-shadow: var(--shadow-md), var(--shine);
  color: var(--text);
}

.panel-strong {
  border-color: var(--line-strong);
  background: var(--surface-0);
  box-shadow: var(--shadow-md), var(--shine);
}

.panel-hero {
  border-width: 3px;
  border-color: var(--line-strong);
  background: var(--surface-0);
  box-shadow: var(--shadow-lg), var(--shine);
}

.panel-center {
  text-align: center;
  display: grid;
  gap: 10px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.brand {
  display: grid;
  gap: 6px;
}

.brand-kicker {
  margin: 0;
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 3px solid var(--line-strong);
  background: var(--surface-0);
  box-shadow: var(--shadow-sm);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand #brandTitle {
  display: inline-block;
  position: relative;
  background: none;
  color: var(--text);
  text-shadow: 1px 1px 0 rgba(43, 38, 38, 0.08);
  padding-bottom: 8px;
}

.brand #brandTitle::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 42px;
  height: 4px;
  border-radius: 999px;
  background: var(--primary);
  box-shadow: 1px 1px 0 rgba(43, 38, 38, 0.12);
  opacity: 0.92;
}

.brand h1 {
  margin: 0;
  font-size: clamp(1.2rem, 2.3vw, 1.7rem);
  letter-spacing: -0.02em;
  line-height: 1.02;
}

.brand p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  text-shadow: none;
}

.status-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.status-pill,
.status-room {
  border: 3px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-0);
  color: var(--text);
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.005em;
  box-shadow: var(--shadow-sm), var(--shine);
}

.status-room {
  cursor: pointer;
  transition: transform var(--anim-fast) ease, filter var(--anim-fast) ease, box-shadow var(--anim-fast) ease;
}

.status-room:hover {
  filter: brightness(1.05);
  box-shadow: var(--shadow-md);
}

.status-room:active {
  transform: translateY(1px);
}

.status-pill[type="button"] {
  cursor: pointer;
}

.status-pill[type="button"]:hover {
  filter: brightness(1.04);
}

.status-pill.online {
  background: var(--good);
  border-color: var(--line-strong);
  color: #ffffff;
  box-shadow: var(--shadow-sm), var(--shine);
}

.status-pill.connecting,
.status-pill.reconnecting {
  background: #fff3bf;
  border-color: var(--line-strong);
  color: rgba(43, 38, 38, 0.92);
  box-shadow: var(--shadow-sm), var(--shine);
}

.status-pill.offline {
  background: var(--primary);
  border-color: var(--line-strong);
  color: #ffffff;
  box-shadow: var(--shadow-sm), var(--shine);
}

.status-pill.status-elo {
  background: #fff9db;
  border-color: rgba(230, 119, 0, 0.9);
  color: rgba(43, 38, 38, 0.92);
  box-shadow: var(--shadow-sm), var(--shine);
}

.hero-banner {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 18px;
  align-items: center;
  overflow: hidden;
}

.hero-mini {
  margin: 0;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.hero-title {
  margin: 6px 0 8px;
  font-size: clamp(1.2rem, 2.5vw, 2rem);
  line-height: 1.1;
}

.hero-desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.46;
  max-width: 68ch;
}

.hero-actions {
  margin-top: 12px;
  display: grid;
  gap: 8px;
  align-items: start;
}

.hero-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

.hero-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.chip {
  border: 3px solid var(--line-strong);
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 0.78rem;
  font-weight: 900;
  background: var(--surface-0);
  box-shadow: var(--shadow-sm), var(--shine);
  color: var(--text);
}

.chip-good {
  border-color: var(--line-strong);
  background: var(--good);
  box-shadow: var(--shadow-sm), var(--shine);
  color: #ffffff;
}

.chip-warn {
  border-color: var(--line-strong);
  background: #fff3bf;
  box-shadow: var(--shadow-sm), var(--shine);
  color: var(--ink);
}

.chip-info {
  border-color: var(--line-strong);
  background: #7a7052;
  box-shadow: var(--shadow-sm), var(--shine);
  color: #ffffff;
}

.lobby-grid {
  margin-top: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.lobby-layout {
  margin-top: 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 10px;
  align-items: start;
}

.lobby-side {
  display: grid;
  gap: 10px;
  align-content: start;
}

.panel-users {
  min-height: 280px;
}

.subhead-title {
  margin: 0;
  font-size: 1.02rem;
  letter-spacing: -0.015em;
  color: var(--text);
}

.count-pill {
  border: 3px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-0);
  color: var(--text);
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow-sm), var(--shine);
}

.count-pill.count-pill-me {
  border-color: var(--line-strong);
  background: var(--good);
  box-shadow: var(--shadow-sm), var(--shine);
  color: #ffffff;
}

.fineprint {
  margin: 10px 0 0;
  color: var(--soft);
  font-size: 0.78rem;
  line-height: 1.4;
}

.fineprint.ok {
  color: #7de2a7;
}

.fineprint.warn {
  color: #f3b37f;
}

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

.panel-guide {
  margin-top: 10px;
}

.panel h2,
.panel h3,
.panel h4 {
  margin: 0 0 10px;
  letter-spacing: -0.015em;
  font-weight: 900;
}

.panel h2 {
  font-size: 1.08rem;
}

.panel > h2::before,
.panel > h3::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--primary-2);
  box-shadow: 0 2px 0 rgba(43, 38, 38, 0.18);
  vertical-align: middle;
}

.panel h3 {
  font-size: 0.97rem;
}

.panel h4 {
  font-size: 0.9rem;
}

.field {
  display: grid;
  gap: 5px;
  margin-bottom: 9px;
}

.field span {
  color: var(--muted);
  font-size: 0.79rem;
  font-weight: 600;
}

.field-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.field-row input {
  flex: 1;
  min-width: 0;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.field-grid.one-col {
  grid-template-columns: 1fr;
}

.details {
  margin-top: 10px;
  border: 3px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface-0);
  overflow: visible;
  box-shadow: var(--shadow-sm);
}

.details-summary {
  cursor: pointer;
  list-style: none;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.86rem;
  font-weight: 900;
  color: var(--text);
  user-select: none;
}

.details-summary:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.details-summary::-webkit-details-marker {
  display: none;
}

.details-summary::after {
  content: "▾";
  color: var(--muted);
  font-size: 0.9rem;
  transition: transform var(--anim-fast) ease;
}

.details[open] .details-summary::after {
  transform: rotate(180deg);
}

.details-body {
  padding: 10px 12px 12px;
  border-top: 1px solid var(--line);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 0.84rem;
}

input,
select,
textarea {
  border: 3px solid var(--line-ink-strong);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  -webkit-text-fill-color: var(--ink);
  caret-color: var(--ink);
  padding: 9px 10px;
  font-size: 0.9rem;
  box-shadow: inset 2px 2px 0 rgba(24, 25, 38, 0.05);
  transition: border-color var(--anim-fast) ease, box-shadow var(--anim-fast) ease, transform var(--anim-fast) ease;
}

.field-static {
  border: 3px solid var(--line-ink-strong);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  padding: 9px 10px;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  box-shadow: inset 2px 2px 0 rgba(24, 25, 38, 0.05);
  cursor: help;
  user-select: text;
}

select {
  color-scheme: light;
  background-color: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  -webkit-text-fill-color: var(--ink);
  border-color: var(--line-ink-strong);
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2212%22%20height%3D%228%22%20viewBox%3D%220%200%2012%208%22%3E%3Cpath%20fill%3D%22%23181926%22%20d%3D%22M1.4%200.9a1%201%200%200%201%201.4%200L6%204.1%209.2%200.9a1%201%200%201%201%201.4%201.4l-3.9%203.9a1%201%200%200%201-1.4%200L1.4%202.3a1%201%200%200%201%200-1.4z%22/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px auto;
}

select option {
  background-color: #ffffff !important;
  color: #181926 !important;
}

.custom-select-wrapper {
  position: relative;
  width: 100%;
  z-index: 0;
}

.custom-select-wrapper.open {
  z-index: 80;
}

.custom-select-wrapper select {
  display: none;
}

.custom-select-trigger {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  position: relative;
  border: 3px solid var(--line-ink-strong);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  padding: 9px 34px 9px 10px;
  font-size: 0.9rem;
  width: 100%;
  text-align: left;
  cursor: pointer;
  box-shadow: inset 2px 2px 0 rgba(24, 25, 38, 0.05);
  transition: border-color var(--anim-fast) ease, box-shadow var(--anim-fast) ease, transform var(--anim-fast) ease;
}

.custom-select-trigger::after {
  content: "▾";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-muted);
  font-size: 0.95rem;
}

.custom-select-trigger:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

.custom-select-trigger.is-loading {
  cursor: progress;
  color: var(--ink-muted);
}

.custom-select-trigger.is-empty {
  cursor: default;
  color: var(--ink-muted);
}

.custom-select-trigger.is-error {
  cursor: help;
  border-color: rgba(201, 42, 42, 0.72);
  box-shadow: 0 0 0 1px rgba(201, 42, 42, 0.12);
}

.custom-select-trigger:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  filter: grayscale(0.25);
}

.custom-select-options {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  border: 3px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface-0);
  box-shadow: var(--shadow-lg), var(--shine);
  padding: 6px;
  max-height: 240px;
  overflow: auto;
  display: grid;
  gap: 4px;
  z-index: 1200;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity var(--anim-fast) ease, transform var(--anim-fast) ease;
}

.custom-select-wrapper.open .custom-select-options {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.custom-select-option {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  border: 2px solid var(--line-ink);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  padding: 9px 10px;
  font-size: 0.86rem;
  line-height: 1.25;
  cursor: pointer;
  text-align: left;
  width: 100%;
}

.custom-select-option:hover,
.custom-select-option:focus-visible {
  outline: none;
  border-color: rgba(201, 42, 42, 0.9);
  box-shadow: 0 0 0 3px rgba(201, 42, 42, 0.18);
}

.custom-select-option[aria-selected="true"] {
  border-color: rgba(201, 42, 42, 0.9);
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  box-shadow: 0 4px 0 rgba(43, 38, 38, 0.12);
}

.custom-select-message {
  border: 2px dashed var(--line-ink);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.65);
  color: var(--ink-muted);
  padding: 10px;
  font-size: 0.86rem;
  line-height: 1.25;
  text-align: center;
  white-space: pre-wrap;
  cursor: default;
  user-select: none;
  pointer-events: none;
}

input::placeholder,
textarea::placeholder {
  color: rgba(24, 25, 38, 0.34);
}

input:focus,
select:focus,
textarea:focus,
.custom-select-trigger:focus {
  outline: none;
  border-color: rgba(197, 160, 89, 0.85);
  box-shadow: var(--focus-ring);
}

button:focus-visible {
  outline: 3px solid rgba(197, 160, 89, 0.55);
  outline-offset: 2px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 3px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface-0);
  color: var(--text);
  padding: 10px 14px;
  font-size: 0.84rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: var(--shadow-sm), var(--shine);
  transition:
    transform var(--anim-fast) ease,
    filter var(--anim-fast) ease,
    box-shadow var(--anim-fast) ease,
    border-color var(--anim-fast) ease;
  white-space: nowrap;
  user-select: none;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.03);
  box-shadow: 4px 4px 0 rgba(43, 38, 38, 0.2), 0 12px 22px rgba(43, 38, 38, 0.14), var(--shine);
}

.btn:active:not(:disabled) {
  transform: translate(var(--shadow-depth), var(--shadow-depth));
  box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.08);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.7;
  filter: grayscale(0.25);
}

.btn-wide {
  width: 100%;
}

.btn-accent {
  border-color: var(--line-strong);
  background: var(--primary);
  color: #ffffff;
  text-shadow: 0 2px 0 rgba(43, 38, 38, 0.16);
  box-shadow: var(--shadow-sm), var(--shine);
}

.btn-accent:hover:not(:disabled) {
  box-shadow:
    4px 4px 0 rgba(43, 38, 38, 0.2),
    0 12px 22px rgba(43, 38, 38, 0.14),
    var(--shine);
}

.btn-danger {
  border-color: rgba(201, 42, 42, 0.85);
  background: var(--surface-0);
  color: var(--primary);
  text-shadow: none;
  box-shadow: var(--shadow-sm), var(--shine);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(201, 42, 42, 0.08);
  box-shadow: 4px 4px 0 rgba(43, 38, 38, 0.2), 0 12px 22px rgba(43, 38, 38, 0.14), var(--shine);
}

.btn-lang {
  min-width: 66px;
  padding: 7px 10px;
  border-radius: 999px;
}

.btn-sfx {
  min-width: 56px;
}

.btn-sfx.is-off {
  opacity: 0.65;
  filter: saturate(0.7);
}

.subhead-row {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pill-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.subhead {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.row-right {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

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

.panel-head h2,
.panel-head h3 {
  margin: 0;
}

.btn-small {
  padding: 7px 10px;
  font-size: 0.78rem;
}

.name-link {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 0;
  cursor: pointer;
  text-align: left;
}

.name-link:hover {
  text-decoration: underline;
}

.name-link:focus-visible {
  outline: 3px solid rgba(197, 160, 89, 0.6);
  outline-offset: 2px;
  border-radius: 8px;
}

.profile-overlay {
  position: fixed;
  left: 50%;
  top: 62px;
  top: calc(62px + env(safe-area-inset-top, 0px));
  transform: translateX(-50%) translateY(-8px);
  width: min(92vw, 560px);
  z-index: 70;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.profile-overlay:not(.hidden) {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.profile-overlay-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 3px solid var(--line-strong);
  border-radius: var(--radius-lg);
  padding: 10px 12px;
  background: var(--surface-0);
  box-shadow: var(--shadow-md), var(--shine);
}

.profile-overlay-title {
  font-size: 0.92rem;
  font-weight: 900;
  line-height: 1.2;
  color: var(--text);
}

.profile-overlay-main {
  min-width: 0;
}

.profile-overlay-stats {
  margin-top: 2px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--soft);
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}

.profile-stats-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.ps-pill {
  display: inline-flex;
  align-items: center;
  border: 2px solid var(--line-ink-strong);
  border-radius: 999px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.ps-elo {
  border-color: rgba(230, 119, 0, 0.85);
  background: #fff9db;
}

.ps-rate.is-good {
  border-color: var(--line-strong);
  background: var(--good);
  color: #ffffff;
}

.ps-rate.is-warn {
  border-color: var(--line-strong);
  background: var(--primary);
  color: #ffffff;
}

.ps-rate.is-neutral {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
}

.chat-backdrop {
  display: none;
}

.mt-8 {
  margin-top: 8px;
}

.room-list,
.player-list,
.user-list,
.log-list,
.chat-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.room-list {
  display: grid;
  gap: 7px;
  max-height: 308px;
  overflow: auto;
}

.room-item {
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.18);
  padding: 10px;
  display: grid;
  gap: 7px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--anim-fast) ease, transform var(--anim-fast) ease, box-shadow var(--anim-fast) ease;
}

.room-item:hover {
  border-color: rgba(201, 42, 42, 0.78);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.room-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--soft);
}

.room-name {
  font-size: 0.84rem;
  color: var(--text);
  line-height: 1.36;
}

.guide-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.guide-step {
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.18);
  padding: 10px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 8px;
  font-size: 0.84rem;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.guide-step strong {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-2);
  color: var(--text);
  font-size: 0.8rem;
  box-shadow: 0 3px 0 rgba(43, 38, 38, 0.18);
}

.chat-list {
  max-height: 220px;
  overflow: auto;
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
}

.chat-list li {
  border: 2px solid var(--line);
  border-left-width: 6px;
  border-left-color: rgba(197, 160, 89, 0.72);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.18);
  padding: 7px 9px;
  font-size: 0.8rem;
  line-height: 1.38;
  box-shadow: var(--shadow-sm);
}

.chat-name {
  color: var(--text);
  font-weight: 700;
  margin-right: 5px;
}

.chat-time {
  color: var(--soft);
  font-size: 0.72rem;
  margin-left: 5px;
}

.chat-compose {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.user-list {
  max-height: 420px;
  overflow: auto;
  display: grid;
  gap: 6px;
}

.user-item {
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.18);
  padding: 8px 10px;
  font-size: 0.84rem;
  line-height: 1.35;
  box-shadow: var(--shadow-sm);
}

.user-item.muted {
  border-style: dashed;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.12);
}

.panel-rankings .fineprint {
  margin-top: 8px;
}

.panel-support .fineprint {
  margin-top: 6px;
}

.panel-rankings,
.panel-support {
  display: grid;
  gap: 10px;
}

.panel-rankings .subhead-row,
.panel-support .subhead-row {
  margin-top: 0;
}

.panel-rankings .fineprint,
.panel-support .fineprint {
  margin: 0;
}

.panel-rankings .ranking-list {
  margin-top: 0;
}

#adFreeBadge {
  border-color: rgba(230, 119, 0, 0.85);
  background: #fff9db;
  color: var(--ink);
}

.ranking-head {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 64px 78px;
  gap: 8px;
  padding: 8px 10px;
  border: 2px solid var(--line-ink);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink-muted);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: var(--shadow-sm);
}

.ranking-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  max-height: 420px;
  overflow: auto;
  display: grid;
  gap: 6px;
}

.ranking-item {
  border: 2px solid var(--line-ink);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 64px 78px;
  gap: 8px;
  align-items: center;
  font-size: 0.84rem;
  line-height: 1.35;
  box-shadow: var(--shadow-sm);
}

.ranking-item .rk-rank {
  font-weight: 900;
  text-align: center;
  color: var(--ink);
}

.ranking-item .rk-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
}

.ranking-item .rk-elo {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-weight: 900;
  text-align: right;
  color: var(--ink);
}

.ranking-item .rk-record {
  text-align: right;
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.ranking-item.rank-1 .rk-rank { color: #ffd56a; text-shadow: 0 0 10px rgba(255, 213, 106, 0.28); }
.ranking-item.rank-2 .rk-rank { color: #d7e0ff; }
.ranking-item.rank-3 .rk-rank { color: #f3b37f; }

.ranking-item.me {
  border-color: rgba(78, 128, 86, 0.55);
  box-shadow: var(--shadow-sm);
}

.ranking-item.muted {
  border-style: dashed;
  color: var(--ink-muted);
  background: rgba(255, 255, 255, 0.62);
}

.ranking-item.ranking-empty {
  grid-template-columns: 1fr;
  justify-items: center;
  text-align: center;
  padding: 12px 10px;
  word-break: keep-all;
  line-break: normal;
}

.ranking-item.ranking-empty .rk-empty {
  grid-column: 1 / -1;
}

.me-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  border-radius: 999px;
  border: 2px solid rgba(78, 128, 86, 0.55);
  background: var(--good);
  padding: 1px 8px;
  font-size: 0.72rem;
  font-weight: 800;
  color: #ffffff;
  vertical-align: middle;
}

.guest-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  border-radius: 999px;
  border: 2px solid rgba(230, 119, 0, 0.7);
  background: rgba(197, 160, 89, 0.16);
  padding: 1px 8px;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text);
  vertical-align: middle;
}

.room-grid-main {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 10px;
}

.left-col,
.right-col {
  display: grid;
  gap: 10px;
  align-content: start;
}

.room-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

#roomTitle {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
}

#roomStateText {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.panel-glass #roomStateText {
  color: var(--muted);
  text-shadow: none;
}

.player-list {
  display: grid;
  gap: 7px;
}

.player-card {
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  padding: 8px;
  background: var(--surface-1);
  box-shadow: var(--shadow-sm);
}

.player-card .top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.player-card .player-identity {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.player-card .avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 2px solid rgba(197, 160, 89, 0.35);
  background: rgba(0, 0, 0, 0.2);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.28), 0 8px 14px rgba(0, 0, 0, 0.35);
  flex: 0 0 auto;
}

.player-card .meta {
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ready-pill {
  border-radius: 999px;
  border: 2px solid var(--line);
  background: rgba(0, 0, 0, 0.22);
  font-size: 0.72rem;
  padding: 3px 8px;
}

.ready-pill.on {
  border-color: rgba(56, 184, 106, 0.55);
  background: rgba(56, 184, 106, 0.18);
}

.room-info-dock {
  display: grid;
  gap: 10px;
  align-content: start;
}

@media (min-width: 1101px) {
  .room-grid-main {
    grid-template-columns: 360px 1fr 340px;
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
      "hud hud info"
      "chat board info"
      "log actions info";
    gap: 12px;
    align-items: start;
  }

  .room-grid-main > aside.left-col,
  .room-grid-main > section.right-col {
    display: contents;
  }

  #roomPlayersPanel {
    grid-area: hud;
  }

  #roomPlayersPanel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    grid-template-areas:
      "title title"
      "players controls";
    gap: 12px;
    padding: 12px;
    border-color: rgba(197, 160, 89, 0.22);
    background: linear-gradient(135deg, rgba(30, 34, 45, 0.92) 0%, rgba(18, 20, 26, 0.86) 100%);
  }

  #roomPlayersPanel > h3 {
    grid-area: title;
    margin: 0;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    font-size: 0.82rem;
    color: var(--muted);
  }

  #roomPlayersPanel > ul {
    grid-area: players;
  }

  #roomPlayersPanel .player-controls {
    grid-area: controls;
    display: grid;
    gap: 8px;
    align-content: start;
  }

  #roomInfoDock {
    grid-area: info;
  }

  #roomChatPanel {
    grid-area: chat;
  }

  #roomLogPanel {
    grid-area: log;
  }

  #waitingPanel,
  #gamePanel {
    grid-area: board;
  }

  #actionPanel {
    grid-area: actions;
  }

  #roomPlayersPanel .player-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  #gamePanel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    grid-template-rows: auto auto auto auto 1fr auto;
    grid-template-areas:
      "header header"
      "meter meter"
      "indicator indicator"
      "legend legend"
      "board score"
      "hint score";
    gap: 10px;
    align-items: start;
  }

  #gamePanel .board-header {
    grid-area: header;
  }

  #gamePanel .timer-meter {
    grid-area: meter;
  }

  #gamePanel #turnIndicator {
    grid-area: indicator;
  }

  #gamePanel .board-legend {
    grid-area: legend;
    justify-content: flex-start;
  }

  #gamePanel #board {
    grid-area: board;
    width: min(58vmin, 700px);
    justify-self: center;
  }

  #gamePanel #illegalHint {
    grid-area: hint;
    margin-top: 0;
  }

  #gamePanel .score-grid {
    grid-area: score;
    margin-top: 0;
    grid-template-columns: 1fr;
    gap: 10px;
    align-content: start;
  }

  #actionPanel {
    padding: 12px;
  }

  #actionPanel .btn-grid {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }
}

.ready-pill.on {
  border-color: rgba(78, 128, 86, 0.6);
  background: var(--good);
  color: #ffffff;
  box-shadow: var(--shadow-sm), var(--shine);
}

#gamePanel {
  overflow: hidden;
}

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

.phase-badge {
  border: 2px solid rgba(230, 119, 0, 0.85);
  border-radius: 999px;
  background: #fff9db;
  padding: 5px 11px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
  box-shadow: var(--shadow-sm), var(--shine);
}

.timer-wrap {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--muted);
}

#turnTimer {
  font-size: 1.4rem;
  min-width: 36px;
  text-align: right;
  font-family: "JetBrains Mono", "Cascadia Code", "D2Coding", monospace;
  color: var(--text);
}

#turnTimer.low {
  color: var(--warn);
  text-shadow: 0 0 12px rgba(201, 42, 42, 0.35);
  animation: warnPulse 0.86s infinite;
}

@keyframes warnPulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

.timer-meter {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  border: 2px solid var(--line);
  overflow: hidden;
  margin-bottom: 9px;
  box-shadow: var(--shadow-sm);
}

.timer-fill {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--good);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
  transition: width 220ms linear, background var(--anim-fast) ease, box-shadow var(--anim-fast) ease;
}

#gamePanel.timer-critical .timer-fill {
  background: var(--primary);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}

.turn-indicator {
  margin-bottom: 9px;
  color: var(--ink);
  font-weight: 700;
  font-size: 0.92rem;
  border: 2px solid var(--line-ink);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.86);
  padding: 8px 10px;
  box-shadow: var(--shadow-sm);
}

.board-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 14px;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.78rem;
}

.legend-plus,
.legend-minus {
  font-weight: 900;
  margin-right: 4px;
}

.legend-plus {
  color: var(--plus);
}

.legend-minus {
  color: var(--minus);
}

.phase-flash {
  position: absolute;
  left: 50%;
  top: 48%;
  transform: translate(-50%, -50%) scale(0.92);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: clamp(1rem, 5vw, 2.5rem);
  font-weight: 900;
  color: rgba(255, 255, 255, 0);
  pointer-events: none;
  z-index: 6;
  opacity: 0;
}

.phase-flash.pop {
  animation: phaseFlash 700ms ease;
}

@keyframes phaseFlash {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.78);
    color: rgba(180, 228, 255, 0);
    text-shadow: none;
  }
  25% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.02);
    color: #d9f3ff;
    text-shadow: 0 0 16px rgba(90, 196, 255, 0.72);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.12);
    color: rgba(217, 243, 255, 0);
    text-shadow: 0 0 28px rgba(90, 196, 255, 0);
  }
}

.board {
  --size: 11;
  width: min(72vmin, 740px);
  aspect-ratio: 1 / 1;
  border: 3px solid var(--line-strong);
  border-radius: 14px;
  background: #d6b384;
  display: grid;
  grid-template-columns: repeat(var(--size), 1fr);
  grid-template-rows: repeat(var(--size), 1fr);
  overflow: hidden;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    inset 0 16px 28px rgba(0, 0, 0, 0.14),
    var(--shadow-lg);
  position: relative;
}

.board::before {
  display: none;
}

.board::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow:
    inset 0 0 0 1px rgba(43, 38, 38, 0.18),
    inset 0 0 18px rgba(0, 0, 0, 0.22);
}

.board.my-turn {
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    0 0 0 1px rgba(201, 42, 42, 0.42),
    0 0 18px rgba(201, 42, 42, 0.2),
    0 14px 32px rgba(0, 0, 0, 0.46);
}

.board.opponent-turn {
  filter: saturate(0.88);
}

@keyframes boardSweep {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(130%);
  }
}

.cell {
  appearance: none;
  border: none;
  margin: 0;
  padding: 0;
  background: transparent;
  position: relative;
  cursor: pointer;
}

.cell::before,
.cell::after {
  content: "";
  position: absolute;
  pointer-events: none;
  background: rgba(43, 23, 8, 0.38);
}

.cell::before {
  width: 1px;
  left: 50%;
  top: 0;
  bottom: 0;
  transform: translateX(-0.5px);
}

.cell::after {
  height: 1px;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-0.5px);
}

.cell:hover,
.cell:active {
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.26) 0%, rgba(255, 255, 255, 0.08) 58%, transparent 76%);
}

.marker {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: clamp(0.76rem, 1.6vw, 1.02rem);
  pointer-events: none;
}

.marker.plus {
  color: var(--plus);
  text-shadow: 0 0 10px rgba(244, 192, 56, 0.5);
}

.marker.minus {
  color: var(--minus);
  text-shadow: 0 0 10px rgba(240, 77, 121, 0.56);
}

.stone {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 78%;
  height: 78%;
  border-radius: 50%;
  pointer-events: none;
}

.stone.black {
  background: radial-gradient(circle at 30% 26%, #6f798f 0%, #232e45 42%, #0f1522 100%);
  border: 1px solid #0f1624;
  box-shadow: inset -3px -4px 10px rgba(0, 0, 0, 0.5), 0 2px 7px rgba(0, 0, 0, 0.42);
}

.stone.white {
  background: radial-gradient(circle at 27% 24%, #ffffff 0%, #dbe6f9 44%, #b8c6df 100%);
  border: 1px solid #95a6c6;
  box-shadow: inset -2px -2px 7px rgba(122, 136, 163, 0.45), 0 2px 7px rgba(0, 0, 0, 0.35);
}

.stone.base::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 3px double rgba(230, 119, 0, 0.96);
  box-shadow:
    0 0 0 2px rgba(201, 42, 42, 0.2),
    0 0 16px rgba(230, 119, 0, 0.28);
}

@supports (
  (background: repeating-conic-gradient(from 0deg, #000 0deg, #000 10deg, #fff 10deg, #fff 20deg)) and
    ((-webkit-mask: radial-gradient(#000, transparent)) or (mask: radial-gradient(#000, transparent)))
) {
  .stone.base::after {
    border: 0;
    background:
      repeating-conic-gradient(
        from 18deg,
        rgba(230, 119, 0, 0.96) 0deg,
        rgba(230, 119, 0, 0.96) 14deg,
        rgba(201, 42, 42, 0.92) 14deg,
        rgba(201, 42, 42, 0.92) 28deg
      );
    -webkit-mask: radial-gradient(
      farthest-side,
      transparent calc(100% - 4px),
      #000 calc(100% - 3px),
      #000 100%
    );
    mask: radial-gradient(
      farthest-side,
      transparent calc(100% - 4px),
      #000 calc(100% - 3px),
      #000 100%
    );
    box-shadow:
      0 0 0 2px rgba(201, 42, 42, 0.22),
      0 0 18px rgba(230, 119, 0, 0.3);
  }
}

.stone.hidden-owner {
  opacity: 0.76;
}

.stone.hidden-owner::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 2px dashed #80daff;
}

.stone.hidden-revealed::before {
  content: "";
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #80daff;
  right: 7px;
  top: 7px;
  box-shadow: 0 0 8px rgba(128, 218, 255, 0.85);
}

.stone.spawn {
  animation: stonePop 220ms ease-out;
}

@keyframes stonePop {
  0% {
    transform: translate(-50%, -50%) scale(0.2);
    opacity: 0.12;
  }
  80% {
    transform: translate(-50%, -50%) scale(1.08);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
  }
}

.capture-burst {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 84%;
  height: 84%;
  border-radius: 50%;
  border: 2px solid rgba(255, 109, 132, 0.9);
  box-shadow: 0 0 18px rgba(255, 109, 132, 0.8);
  animation: burstFade 360ms ease-out forwards;
  pointer-events: none;
}

.impact-wave {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 38%;
  height: 38%;
  border-radius: 50%;
  border: 2px solid rgba(109, 205, 255, 0.85);
  box-shadow: 0 0 14px rgba(100, 192, 255, 0.62);
  animation: impactWave 380ms ease-out forwards;
  pointer-events: none;
}

@keyframes impactWave {
  0% {
    opacity: 0.95;
    transform: translate(-50%, -50%) scale(0.35);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(2.35);
  }
}

@keyframes burstFade {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.5);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.45);
  }
}

.cell.illegal {
  animation: illegalFlash 0.8s ease;
}

@keyframes illegalFlash {
  0% {
    background: rgba(255, 90, 90, 0.5);
  }
  100% {
    background: transparent;
  }
}

.cell.territory-p0 {
  background: rgba(74, 199, 255, 0.18);
}

.cell.territory-p1 {
  background: rgba(255, 138, 77, 0.2);
}

.illegal-hint {
  min-height: 1.3rem;
  margin-top: 8px;
  color: rgba(140, 20, 18, 0.9);
  font-weight: 800;
  font-size: 0.86rem;
}

.btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.score-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

#gamePanel.timer-critical {
  box-shadow:
    var(--shadow-md),
    0 0 0 2px rgba(201, 42, 42, 0.18);
}

.score-card {
  border: 2px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.22);
  padding: 8px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.score-card h4 {
  margin: 0;
  font-size: 0.92rem;
}

.score-card p {
  margin: 4px 0 6px;
  color: var(--muted);
  font-size: 0.75rem;
}

.score-card ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 3px;
}

.score-card li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.75rem;
}

.score-card li strong {
  font-family: "JetBrains Mono", "Cascadia Code", "D2Coding", monospace;
}

.log-list {
  max-height: 210px;
  overflow: auto;
  display: grid;
  gap: 5px;
}

.log-list li {
  border: 2px solid var(--line);
  border-left-width: 6px;
  border-left-color: rgba(230, 119, 0, 0.72);
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.18);
  padding: 6px 7px;
  font-size: 0.79rem;
  line-height: 1.38;
  box-shadow: var(--shadow-sm);
}

.log-list li.new {
  animation: newLogPulse 520ms ease;
}

@keyframes newLogPulse {
  0% {
    background: rgba(255, 243, 191, 0.8);
  }
  100% {
    background: rgba(255, 255, 255, 0.78);
  }
}

.log-list li.warn {
  border-left-color: rgba(201, 42, 42, 0.72);
}

.log-list li.good {
  border-left-color: rgba(78, 128, 86, 0.72);
}

.toast {
  position: fixed;
  left: 50%;
  top: 18px;
  top: calc(18px + env(safe-area-inset-top, 0px));
  transform: translateX(-50%) translateY(-8px);
  background: var(--surface-0);
  border: 3px solid var(--line-strong);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 0.84rem;
  font-weight: 700;
  box-shadow: var(--shadow-md), var(--shine);
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  transition: opacity 120ms ease, transform 120ms ease;
}

.toast:not(.hidden) {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.limit-overlay {
  position: fixed;
  left: 50%;
  top: 18px;
  top: calc(18px + env(safe-area-inset-top, 0px));
  transform: translateX(-50%) translateY(-8px);
  width: min(92vw, 820px);
  z-index: 80;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.limit-overlay:not(.hidden) {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.limit-overlay-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  background: var(--surface-0);
  border: 3px solid rgba(201, 42, 42, 0.82);
  border-radius: 999px;
  padding: 10px 12px;
  box-shadow: var(--shadow-md), var(--shine);
}

.limit-overlay-text {
  font-size: 0.84rem;
  font-weight: 800;
  line-height: 1.32;
}

#entryScreen {
  display: grid;
  justify-items: center;
}

#entryScreen .entry-card {
  width: min(560px, 100%);
}

.site-footer {
  margin-top: 18px;
  padding: 14px 10px;
  border: 2px solid var(--line-ink);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.7);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--ink-muted);
  font-size: 0.82rem;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 10px;
}

.footer-dot {
  opacity: 0.55;
}

.footer-link {
  color: var(--text);
  text-decoration: none;
}

.footer-link:hover {
  color: var(--primary);
  text-decoration: underline;
}

.footer-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.footer-muted {
  color: var(--soft);
}

.site-footer .footer-link {
  color: var(--ink);
}

.site-footer .footer-link:hover {
  color: rgba(230, 119, 0, 0.92);
}

.site-footer .footer-muted {
  color: var(--ink-soft);
}

.legal-page {
  padding: 10px 0 18px;
}

.legal-card h2 {
  margin: 18px 0 10px;
  font-size: 1.05rem;
}

.legal-card ul {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
  color: var(--muted);
  line-height: 1.55;
}

.legal-card p {
  color: var(--muted);
  line-height: 1.6;
}

@media (max-width: 1260px) {
  .hero-banner {
    grid-template-columns: 1fr;
  }

  .hero-chips {
    justify-content: flex-start;
  }
}

@media (max-width: 1100px) {
  button,
  .btn,
  .custom-select-trigger,
  .custom-select-option,
  .details-summary,
  .cell,
  .chip,
  .status-room {
    touch-action: manipulation;
  }

  .lobby-layout {
    grid-template-columns: 1fr;
  }

  .room-grid-main {
    grid-template-columns: 1fr;
  }

  .left-col {
    order: 2;
  }

  .right-col {
    order: 1;
  }

  .board {
    width: min(94vw, 700px);
  }

  body.mode-room .app-shell {
    padding-bottom: 210px;
    padding-bottom: calc(210px + env(safe-area-inset-bottom, 0px));
  }

  #actionPanel {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(10px + var(--keyboard-offset));
    left: calc(10px + env(safe-area-inset-left, 0px));
    right: calc(10px + env(safe-area-inset-right, 0px));
    bottom: calc(10px + env(safe-area-inset-bottom, 0px) + var(--keyboard-offset));
    margin: 0 auto;
    max-width: min(980px, calc(100vw - 20px));
    z-index: 45;
    backdrop-filter: blur(10px);
    transition: bottom var(--anim-mid) ease;
  }

  #actionPanel .btn-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .chat-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--anim-mid) ease;
    z-index: 58;
  }

  body.room-chat-open .chat-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .room-chat-panel {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(10px + var(--keyboard-offset));
    left: calc(10px + env(safe-area-inset-left, 0px));
    right: calc(10px + env(safe-area-inset-right, 0px));
    bottom: calc(10px + env(safe-area-inset-bottom, 0px) + var(--keyboard-offset));
    max-height: 70vh;
    max-height: 70dvh;
    z-index: 60;
    transform: translateY(calc(100% + 20px));
    transition: transform var(--anim-mid) ease, bottom var(--anim-mid) ease;
    border-radius: 18px;
    overflow: hidden;
  }

  body.room-chat-open .room-chat-panel {
    transform: translateY(0);
  }

  .room-chat-panel .chat-list {
    max-height: calc(70vh - 120px);
    max-height: calc(70dvh - 120px);
  }

  body.room-chat-open #actionPanel {
    display: none !important;
  }
}

@media (max-width: 980px) {
  .lobby-grid {
    grid-template-columns: 1fr;
  }

  .guide-steps {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 880px) {
  .score-grid,
  .field-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 720px) {
  .app-shell {
    padding: 9px;
    padding:
      calc(9px + env(safe-area-inset-top, 0px))
      calc(9px + env(safe-area-inset-right, 0px))
      calc(9px + env(safe-area-inset-bottom, 0px))
      calc(9px + env(safe-area-inset-left, 0px));
  }

  .panel {
    border-radius: 13px;
    padding: 10px;
  }

  .btn-grid {
    grid-template-columns: 1fr;
  }

  .board-legend {
    justify-content: flex-start;
  }

  .status-wrap {
    width: 100%;
  }

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

  .room-top .row-right {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .status-room,
  .status-pill {
    font-size: 0.75rem;
  }

  #turnTimer {
    font-size: 1.25rem;
  }

  #actionPanel {
    left: 9px;
    right: 9px;
    bottom: calc(9px + var(--keyboard-offset));
    left: calc(9px + env(safe-area-inset-left, 0px));
    right: calc(9px + env(safe-area-inset-right, 0px));
    bottom: calc(9px + env(safe-area-inset-bottom, 0px) + var(--keyboard-offset));
  }

  #actionPanel .btn {
    padding: 11px 10px;
    font-size: 0.8rem;
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }

  .btn,
  .custom-select-trigger,
  .details-summary {
    min-height: 44px;
  }
}

@media (max-width: 480px) {
  .ranking-head {
    grid-template-columns: 30px minmax(0, 1fr) 64px;
  }

  .ranking-head .rh-record {
    display: none;
  }

  .ranking-item {
    grid-template-columns: 30px minmax(0, 1fr) 64px;
  }

  .ranking-item .rk-record {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
