:root {
  color-scheme: dark;
  --ink: #f4f5e8;
  --muted: rgba(235, 241, 220, 0.68);
  --panel: #102f22;
  --panel-deep: #0a2419;
  --line: rgba(240, 247, 220, 0.12);
  --gold: #f5ca6a;
  --gold-light: #ffe8a6;
  --shadow: 0 24px 70px rgba(5, 25, 14, 0.34);
  --serif: Georgia, "Times New Roman", serif;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at 82% -10%, rgba(147, 184, 91, 0.23), transparent 34%),
    linear-gradient(150deg, #173d2b 0%, #0c2b1e 54%, #071d15 100%);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.shell {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  gap: 18px;
  min-width: 0;
  padding: 24px 22px 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 28%),
    var(--panel);
  border-right: 1px solid var(--line);
  box-shadow: 12px 0 40px rgba(5, 23, 15, 0.22);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 13px;
}

.brand-block h1 {
  margin: 0;
  font: 700 clamp(2.15rem, 4vw, 3.25rem)/0.88 var(--serif);
  letter-spacing: -0.055em;
  color: var(--gold-light);
}

.brand-block p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.brand-mark {
  position: relative;
  width: 52px;
  aspect-ratio: 1;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #b67638;
  box-shadow: inset 0 -8px 0 rgba(88, 46, 20, 0.24), 0 8px 20px rgba(3, 18, 10, 0.24);
}

.brand-mark::before,
.brand-mark span {
  content: "";
  position: absolute;
  border: 2px solid rgba(86, 48, 23, 0.55);
  border-radius: 50%;
}

.brand-mark::before {
  inset: 8px;
}

.brand-mark span:nth-child(1) { inset: 15px; }
.brand-mark span:nth-child(2) { inset: 22px; }
.brand-mark span:nth-child(3) {
  width: 18px;
  height: 2px;
  left: 23px;
  top: 22px;
  border: 0;
  border-top: 2px solid rgba(86, 48, 23, 0.55);
  border-radius: 0;
  transform: rotate(-35deg);
}

.join-form {
  display: grid;
  gap: 8px;
}

.join-form label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.join-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.join-row input {
  min-width: 0;
  padding: 13px 14px;
  color: #173626;
  background: #f3f3df;
  border: 1px solid transparent;
  border-radius: 13px;
  outline: none;
}

.join-row input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(245, 202, 106, 0.2);
}

.join-row button,
.icon-button {
  border: 0;
  cursor: pointer;
}

.join-row button {
  min-width: 74px;
  padding: 12px 15px;
  border-radius: 13px;
  color: #173121;
  background: linear-gradient(145deg, var(--gold-light), var(--gold));
  box-shadow: 0 7px 18px rgba(4, 19, 11, 0.22);
  font-weight: 800;
  transition: transform 120ms ease, filter 120ms ease;
}

.join-row button:hover { filter: brightness(1.04); transform: translateY(-1px); }
.join-row button:active { transform: translateY(1px); }

.score-card {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2px 14px;
  padding: 16px 18px;
  border: 1px solid rgba(255, 232, 166, 0.15);
  border-radius: 19px;
  background:
    radial-gradient(circle at 95% 20%, rgba(255, 215, 116, 0.12), transparent 38%),
    rgba(4, 23, 15, 0.42);
}

.score-card > span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.score-card strong {
  grid-row: 1 / 3;
  grid-column: 2;
  font: 700 2.25rem/1 var(--serif);
  color: var(--gold-light);
}

.score-card small {
  overflow: hidden;
  color: rgba(235, 241, 220, 0.55);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scoreboard {
  min-height: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(4, 22, 15, 0.28);
}

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

.section-heading h2 {
  margin: 0;
  font: 700 1.05rem/1.2 var(--serif);
  color: var(--gold-light);
}

.section-heading span {
  color: var(--muted);
  font-size: 0.75rem;
}

.score-list {
  display: grid;
  gap: 7px;
  max-height: 100%;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(245, 202, 106, 0.35) transparent;
}

.score-row {
  display: grid;
  grid-template-columns: 25px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.045);
}

.score-row.is-you {
  background: rgba(245, 202, 106, 0.12);
  box-shadow: inset 0 0 0 1px rgba(245, 202, 106, 0.28);
}

.score-rank {
  color: rgba(235, 241, 220, 0.42);
  font-size: 0.75rem;
}

.score-name {
  overflow: hidden;
  font-size: 0.9rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-value {
  color: var(--gold-light);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.empty-scores {
  padding: 12px 4px;
  color: var(--muted);
  font-size: 0.87rem;
}

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

.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.76rem;
}

.connection-status i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d6a34b;
  box-shadow: 0 0 0 3px rgba(214, 163, 75, 0.12);
}

.connection-status.is-online i {
  background: #7ac67d;
  box-shadow: 0 0 0 3px rgba(122, 198, 125, 0.12);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  color: var(--muted);
  background: transparent;
  border-radius: 10px;
}

.icon-button:hover { background: rgba(255, 255, 255, 0.06); color: var(--ink); }
.icon-button svg { width: 19px; fill: currentColor; }
.icon-button svg .sound-waves { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.icon-button[aria-pressed="false"] .sound-waves { display: none; }
.icon-button span { font-size: 0.78rem; }

.game-area {
  min-width: 0;
  padding: 18px;
}

.field-frame {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: calc(100vh - 36px);
  height: calc(100dvh - 36px);
  min-height: 520px;
  border: 1px solid rgba(234, 244, 208, 0.18);
  border-radius: 34px;
  background:
    radial-gradient(circle at 18% 20%, rgba(228, 242, 174, 0.14), transparent 22%),
    radial-gradient(circle at 82% 68%, rgba(24, 83, 42, 0.25), transparent 30%),
    repeating-radial-gradient(ellipse at 50% 110%, transparent 0 26px, rgba(23, 84, 38, 0.08) 27px 29px),
    linear-gradient(155deg, #84b960 0%, #67a04e 42%, #4f8c42 100%);
  box-shadow: var(--shadow), inset 0 0 80px rgba(20, 70, 31, 0.23);
  isolation: isolate;
}

.field-frame::before,
.field-frame::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.field-frame::before {
  inset: 0;
  z-index: 1;
  opacity: 0.38;
  background-image:
    radial-gradient(ellipse at 10% 20%, rgba(255, 243, 176, 0.24) 0 2px, transparent 3px),
    radial-gradient(ellipse at 62% 72%, rgba(27, 85, 36, 0.25) 0 2px, transparent 3px);
  background-size: 58px 61px, 73px 67px;
}

.field-frame::after {
  inset: 0;
  z-index: 2;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), inset 0 -80px 100px rgba(30, 74, 30, 0.15);
}

.field-glow {
  position: absolute;
  z-index: 1;
  top: -22%;
  right: 5%;
  width: 56%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(248, 236, 163, 0.18), transparent 67%);
  pointer-events: none;
}

.forest-grid {
  z-index: 3;
}

.round-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(7, 27, 17, 0.45);
  backdrop-filter: blur(4px);
}

.round-overlay[hidden] { display: none; }

.round-message {
  max-width: 540px;
  padding: 34px 42px;
  text-align: center;
  border: 1px solid rgba(255, 235, 174, 0.28);
  border-radius: 28px;
  background: rgba(10, 39, 25, 0.91);
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.28);
}

.round-message span {
  display: block;
  margin-bottom: 7px;
  color: var(--gold);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.round-message strong {
  display: block;
  font: 700 clamp(2.5rem, 7vw, 5.5rem)/0.95 var(--serif);
  color: var(--gold-light);
  letter-spacing: -0.045em;
}

.round-message p {
  margin: 13px 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.toast {
  position: absolute;
  z-index: 60;
  left: 50%;
  bottom: 24px;
  max-width: min(88%, 480px);
  padding: 11px 16px;
  color: #fff6d7;
  text-align: center;
  border: 1px solid rgba(255, 231, 159, 0.24);
  border-radius: 13px;
  background: rgba(9, 37, 23, 0.9);
  box-shadow: 0 12px 35px rgba(7, 27, 17, 0.28);
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 980px) {
  .shell { grid-template-columns: 250px minmax(0, 1fr); }
  .sidebar { padding: 18px 16px 14px; gap: 13px; }
  .brand-mark { width: 43px; }
  .brand-block h1 { font-size: 2.1rem; }
  .brand-block p { display: none; }
  .game-area { padding: 12px; }
  .field-frame { height: calc(100dvh - 24px); min-height: 470px; border-radius: 26px; }
  .forest-grid { inset: 24px 18px; }
}

@media (max-width: 720px) {
  .shell { display: block; }
  .sidebar {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
    grid-template-rows: auto auto auto;
    padding: 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .brand-block { align-self: center; }
  .join-form { grid-column: 2; }
  .score-card { grid-column: 1; padding: 12px 14px; }
  .scoreboard { grid-column: 2; grid-row: 2 / 4; max-height: 155px; padding: 12px; }
  .sidebar-footer { grid-column: 1; }
  .game-area { padding: 10px; }
  .field-frame { height: 70vh; min-height: 500px; }
  .forest-grid { inset: 20px 10px; }
  .tree-visual { max-width: 94px; }
  .stage-4 .tree-visual { max-width: 124px; }
}

@media (max-width: 480px) {
  .sidebar { grid-template-columns: 1fr; }
  .brand-block, .join-form, .score-card, .scoreboard, .sidebar-footer { grid-column: 1; grid-row: auto; }
  .scoreboard { max-height: 135px; }
  .field-frame { height: 68vh; min-height: 460px; }
  .round-message { padding: 28px 24px; }
}
