:root {
  color-scheme: dark;
  --ink: #08110e;
  --field: #0e1712;
  --panel: #14211a;
  --panel-strong: #1b2a21;
  --line: #2f4438;
  --paper: #f3f0df;
  --muted: #9daf9f;
  --lime: #d7ff3f;
  --mint: #49f5a6;
  --coral: #ff6f4b;
  --sky: #79d8ff;
  --amber: #ffc857;
  --shadow: rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(215, 255, 63, 0.04) 1px, transparent 1px),
    linear-gradient(rgba(215, 255, 63, 0.035) 1px, transparent 1px),
    linear-gradient(145deg, rgba(73, 245, 166, 0.13), transparent 42%),
    #08110e;
  background-size: 38px 38px, 38px 38px, auto;
  color: var(--paper);
  font-family: "Avenir Next Condensed", "DIN Condensed", "Trebuchet MS", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  min-height: 100vh;
  padding: 18px;
}

.arena-section {
  display: grid;
  grid-template-rows: auto minmax(360px, 1fr) auto;
  gap: 14px;
  min-width: 0;
}

.topbar,
.control-rail > section {
  border: 1px solid var(--line);
  background: rgba(20, 33, 26, 0.9);
  box-shadow: 0 18px 60px var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
  padding: 14px 18px;
  border-radius: 8px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--mint);
  font-size: 0.78rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
  line-height: 0.95;
}

h1 {
  font-size: clamp(2.25rem, 5vw, 5rem);
}

h2 {
  font-size: 2.1rem;
}

.room-chip {
  display: inline-grid;
  grid-template-columns: auto auto 34px;
  align-items: center;
  gap: 10px;
  min-width: 188px;
  padding: 8px 8px 8px 12px;
  border: 1px solid rgba(215, 255, 63, 0.45);
  border-radius: 8px;
  background: #0b150f;
}

.room-chip span {
  color: var(--muted);
  font-size: 0.78rem;
}

.room-chip strong {
  color: var(--lime);
  font-size: 1.55rem;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-strong);
  color: var(--paper);
}

.canvas-wrap {
  position: relative;
  display: grid;
  min-height: 420px;
  overflow: hidden;
  border: 1px solid rgba(215, 255, 63, 0.28);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 111, 75, 0.08), transparent 35%),
    linear-gradient(315deg, rgba(121, 216, 255, 0.12), transparent 36%),
    #0b130f;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.center-status {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  pointer-events: none;
  text-align: center;
  text-shadow: 0 4px 20px #000;
}

.center-status strong {
  color: var(--lime);
  font-size: clamp(3.5rem, 12vw, 9rem);
  line-height: 0.9;
}

.center-status span {
  color: var(--paper);
  font-size: 1.15rem;
}

.mobile-pad {
  display: none;
  grid-template-columns: repeat(4, minmax(54px, 1fr));
  gap: 8px;
}

.mobile-pad button {
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--paper);
  font-size: 1.35rem;
}

.control-rail {
  display: grid;
  align-content: start;
  gap: 14px;
  min-width: 0;
}

.control-rail > section {
  padding: 16px;
  border-radius: 8px;
}

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

form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
}

label span,
.meta-grid span {
  color: var(--muted);
  font-size: 0.88rem;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 11px;
  background: #09130f;
  color: var(--paper);
  outline: none;
}

input:focus {
  border-color: var(--lime);
  box-shadow: 0 0 0 3px rgba(215, 255, 63, 0.16);
}

.button-row,
.host-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.primary-button,
.ghost-button {
  min-height: 44px;
  border-radius: 7px;
  padding: 0 14px;
  border: 1px solid transparent;
  transition:
    transform 150ms ease,
    border-color 150ms ease,
    background 150ms ease;
}

.primary-button {
  background: var(--lime);
  color: #13200f;
  font-weight: 700;
}

.ghost-button {
  background: transparent;
  border-color: var(--line);
  color: var(--paper);
}

.primary-button:hover,
.ghost-button:hover,
.mobile-pad button:hover,
.icon-button:hover {
  transform: translateY(-1px);
  border-color: var(--lime);
}

.primary-button:disabled,
.ghost-button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none;
}

.message {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--amber);
}

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

.meta-grid div {
  display: grid;
  gap: 4px;
  min-height: 64px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0c1711;
}

.meta-grid strong {
  color: var(--paper);
  font-size: 1.8rem;
  line-height: 1;
}

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

.score-list li {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0c1711;
}

.score-list .rank {
  color: var(--muted);
}

.score-list .player {
  display: grid;
  min-width: 0;
}

.score-list .name {
  overflow: hidden;
  color: var(--paper);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-list .state {
  color: var(--muted);
  font-size: 0.78rem;
}

.score-list .score {
  color: var(--lime);
  font-size: 1.35rem;
}

.swatch {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 7px;
  border-radius: 50%;
  box-shadow: 0 0 14px currentColor;
}

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

  .control-rail {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell {
    gap: 12px;
    padding: 8px 8px 16px;
  }

  .topbar {
    gap: 10px;
    align-items: stretch;
    flex-direction: column;
    min-height: 0;
    padding: 12px;
  }

  .room-chip {
    width: 100%;
  }

  .room-chip strong {
    font-size: 1.3rem;
  }

  .canvas-wrap {
    min-height: clamp(280px, 40svh, 360px);
    max-height: 42svh;
  }

  .center-status strong {
    font-size: clamp(3rem, 15vw, 4.8rem);
  }

  .center-status span {
    font-size: 1rem;
  }

  .mobile-pad {
    display: grid;
    position: sticky;
    bottom: 8px;
    z-index: 5;
    padding: 8px;
    border: 1px solid rgba(47, 68, 56, 0.92);
    border-radius: 8px;
    background: rgba(11, 21, 15, 0.94);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
  }

  .mobile-pad button {
    min-height: 56px;
    font-size: 1.2rem;
  }

  .control-rail {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .control-rail > section {
    padding: 14px;
  }

  .panel-heading {
    align-items: center;
  }

  .panel-heading h2 {
    font-size: 1.8rem;
  }

  .host-actions {
    grid-template-columns: 1fr 1fr;
  }

  h1 {
    font-size: 2.35rem;
    line-height: 0.92;
  }

  .score-list li {
    min-height: 44px;
    padding: 8px;
  }

  .score-list .score {
    font-size: 1.2rem;
  }
}

@media (max-width: 440px) {
  .canvas-wrap {
    min-height: clamp(250px, 36svh, 320px);
    max-height: 38svh;
  }

  .button-row,
  .host-actions,
  .meta-grid {
    gap: 8px;
  }

  .primary-button,
  .ghost-button {
    min-height: 42px;
    padding: 0 10px;
  }

  .panel-heading h2 {
    font-size: 1.6rem;
  }

  h1 {
    font-size: 2.1rem;
  }
}
