@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800;900&family=Space+Mono:wght@400;700&display=swap");

:root {
  color-scheme: dark;
  --bg: #080a0c;
  --panel: #0e1115;
  --line: #273039;
  --text: #f4f7f8;
  --muted: #84919b;
  --blue: #24c8ff;
  --red: #ff416d;
  --acid: #d9ff43;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 12% 15%, rgba(36, 200, 255, 0.08), transparent 25rem),
    radial-gradient(circle at 88% 78%, rgba(255, 65, 109, 0.07), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
}

button {
  color: inherit;
  font: inherit;
}

.app {
  width: min(1400px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 18px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font: 700 10px/1.2 "Space Mono", monospace;
  letter-spacing: 0.22em;
}

h1 {
  margin: 0;
  font-size: clamp(25px, 3vw, 42px);
  font-weight: 900;
  letter-spacing: -0.055em;
  line-height: 0.95;
}

h1 span {
  color: var(--acid);
  font-family: "Space Mono", monospace;
  font-size: 0.58em;
  letter-spacing: -0.08em;
}

.icon-button {
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 10px 13px;
  background: #101419;
  color: var(--muted);
  cursor: pointer;
  font: 700 10px "Space Mono", monospace;
  letter-spacing: 0.08em;
  transition: 160ms ease;
}

.icon-button:hover,
.icon-button.active {
  border-color: var(--acid);
  color: var(--acid);
}

.scoreboard {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 54px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 5px 5px 0 0;
  background: rgba(14, 17, 21, 0.92);
}

.team {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 0 22px;
  font: 800 12px "Space Mono", monospace;
  letter-spacing: 0.16em;
}

.team-red {
  justify-content: flex-end;
}

.team-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.team-blue .team-dot {
  background: var(--blue);
  box-shadow: 0 0 12px var(--blue);
}

.team-red .team-dot {
  background: var(--red);
  box-shadow: 0 0 12px var(--red);
}

.score {
  display: flex;
  gap: 14px;
  align-items: center;
  font: 900 27px/1 "Space Mono", monospace;
}

.score span {
  color: #49545d;
  font-size: 18px;
}

.timer {
  position: absolute;
  top: 50%;
  right: 22px;
  transform: translateY(-50%);
  color: var(--muted);
  font: 700 12px "Space Mono", monospace;
}

.game-shell {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0 0 5px 5px;
  background: #111922;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.45);
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(5, 8, 10, 0.68);
  backdrop-filter: blur(8px);
  transition: opacity 240ms ease, visibility 240ms ease;
}

.overlay.hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.overlay-card {
  width: min(660px, 100%);
  padding: clamp(24px, 5vw, 48px);
  border: 1px solid #3a444d;
  border-radius: 4px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.025), transparent 50%),
    rgba(10, 13, 16, 0.96);
  text-align: center;
  box-shadow: 12px 12px 0 rgba(0, 0, 0, 0.32);
}

.overlay-card h2 {
  margin: 6px 0 8px;
  font-size: clamp(27px, 5vw, 52px);
  font-weight: 900;
  letter-spacing: -0.06em;
}

.lead {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 14px;
  align-items: center;
  margin: 32px 0;
}

.control-card {
  display: flex;
  min-height: 104px;
  flex-direction: column;
  justify-content: center;
  border: 1px solid var(--line);
  background: #0d1114;
}

.control-card span,
.control-card small {
  color: var(--muted);
  font: 700 9px "Space Mono", monospace;
  letter-spacing: 0.12em;
}

.control-card strong {
  margin: 8px 0;
  font: 700 19px "Space Mono", monospace;
  letter-spacing: 0.12em;
}

.blue-card {
  border-top-color: var(--blue);
}

.blue-card strong {
  color: var(--blue);
}

.red-card {
  border-top-color: var(--red);
}

.red-card strong {
  color: var(--red);
}

.versus {
  color: #606b73;
  font: 700 11px "Space Mono", monospace;
}

.primary-button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  border: 0;
  border-radius: 2px;
  padding: 17px 20px;
  background: var(--acid);
  color: #0a0d0e;
  cursor: pointer;
  font: 900 13px "Space Mono", monospace;
  letter-spacing: 0.14em;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.primary-button:hover {
  transform: translate(-3px, -3px);
  box-shadow: 6px 6px 0 #63751f;
}

.primary-button span {
  font-size: 19px;
}

.game-message {
  position: absolute;
  top: 18%;
  left: 50%;
  transform: translate(-50%, -15px);
  color: white;
  opacity: 0;
  pointer-events: none;
  font-size: clamp(34px, 7vw, 86px);
  font-weight: 900;
  letter-spacing: -0.06em;
  text-shadow: 0 8px 40px rgba(0, 0, 0, 0.8);
  transition: 180ms ease;
}

.game-message.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

footer {
  display: flex;
  justify-content: space-between;
  padding: 14px 4px 0;
  color: #5f6971;
  font: 700 9px "Space Mono", monospace;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

footer p {
  margin: 0;
}

kbd {
  border: 1px solid #434c54;
  border-radius: 2px;
  padding: 2px 5px;
  background: #14191e;
  color: #a6b0b7;
  font-family: inherit;
}

@media (max-width: 720px) {
  .app {
    width: min(100% - 16px, 1400px);
  }

  .scoreboard {
    grid-template-columns: 1fr auto 1fr;
  }

  .team {
    padding: 0 10px;
    font-size: 9px;
  }

  .timer {
    display: none;
  }

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

  .versus {
    display: none;
  }

  .control-card {
    min-height: 88px;
  }

  footer p:nth-child(2) {
    display: none;
  }
}

/* Online lobby and match layout */
.hidden {
  display: none !important;
}

.connection-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: #59636a;
}

.connection-dot.online {
  background: var(--acid);
  box-shadow: 0 0 10px var(--acid);
}

.header-actions {
  display: flex;
  gap: 8px;
}

.lobby-view {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(11, 14, 17, 0.86);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
}

.lobby-intro {
  display: grid;
  grid-template-columns: 1fr minmax(240px, 340px);
  gap: 30px;
  align-items: end;
  padding: clamp(30px, 5vw, 62px);
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(circle at 85% 40%, rgba(217, 255, 67, 0.07), transparent 24rem),
    linear-gradient(140deg, rgba(36, 200, 255, 0.05), transparent 45%);
}

.lobby-intro h2 {
  margin: 0;
  font-size: clamp(36px, 6vw, 76px);
  font-weight: 900;
  letter-spacing: -0.065em;
  line-height: 0.94;
}

.lobby-intro h2 em {
  color: var(--acid);
  font-style: normal;
}

.nickname-field,
.number-field,
.form-field {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.nickname-field span,
.number-field span,
.form-field span,
.team-size-field legend {
  color: var(--muted);
  font: 700 9px "Space Mono", monospace;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.identity-fields {
  display: grid;
  grid-template-columns: 1fr 92px;
  gap: 9px;
  align-items: start;
}

.number-field small {
  color: #5f6b72;
  font: 400 7px "Space Mono", monospace;
  white-space: nowrap;
}

.number-field input {
  text-align: center;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  border: 1px solid #354049;
  border-radius: 2px;
  outline: 0;
  padding: 13px 14px;
  background: #0a0d10;
  color: var(--text);
  font: 600 13px Inter, sans-serif;
}

input:focus,
select:focus {
  border-color: var(--acid);
  box-shadow: 0 0 0 2px rgba(217, 255, 67, 0.08);
}

.lobby-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.7fr);
  min-height: 480px;
}

.rooms-panel,
.create-panel {
  padding: clamp(24px, 4vw, 42px);
}

.rooms-panel {
  border-right: 1px solid var(--line);
}

.create-panel {
  display: flex;
  flex-direction: column;
  gap: 22px;
  background: rgba(7, 9, 11, 0.45);
}

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

.panel-heading > div {
  display: flex;
  gap: 11px;
  align-items: center;
}

.panel-heading h3 {
  margin: 0;
  font-size: 14px;
}

.step {
  color: var(--acid);
  font: 700 9px "Space Mono", monospace;
}

.refresh-button {
  border: 1px solid #465159;
  border-radius: 2px;
  padding: 9px 12px;
  background: #11161a;
  color: #b4c0c5;
  cursor: pointer;
  font: 700 9px "Space Mono", monospace;
  transition: 150ms ease;
}

.refresh-button:hover {
  border-color: var(--acid);
  color: var(--acid);
}

.refresh-button.loading,
.refresh-button:disabled {
  border-color: #30383e;
  color: #626d73;
  cursor: wait;
}

.room-list {
  display: grid;
  gap: 8px;
}

.room-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto auto auto;
  gap: 20px;
  align-items: center;
  border: 1px solid #253039;
  border-left: 3px solid #36444c;
  padding: 16px 18px;
  background: #0d1115;
  transition: 150ms ease;
}

.room-row:hover {
  border-color: #53616a;
  border-left-color: var(--acid);
  transform: translateX(3px);
}

.room-name {
  min-width: 0;
}

.room-name strong {
  display: block;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-name small,
.room-meta {
  color: var(--muted);
  font: 700 8px "Space Mono", monospace;
}

.room-name small {
  display: block;
  margin-top: 5px;
}

.room-status {
  border: 1px solid #35424a;
  padding: 5px 7px;
  color: #85929a;
  font: 700 7px "Space Mono", monospace;
  letter-spacing: 0.08em;
}

.room-status.waiting {
  border-color: rgba(217, 255, 67, 0.45);
  color: var(--acid);
}

.join-button {
  border: 1px solid var(--acid);
  padding: 9px 12px;
  background: transparent;
  color: var(--acid);
  cursor: pointer;
  font: 800 9px "Space Mono", monospace;
}

.join-button:hover {
  background: var(--acid);
  color: #0a0d0e;
}

.join-button:disabled {
  border-color: #333b40;
  color: #586168;
  cursor: not-allowed;
}

.room-empty {
  display: grid;
  min-height: 250px;
  place-items: center;
  border: 1px dashed #303940;
  color: #68737a;
  font-size: 12px;
  text-align: center;
}

.team-size-field {
  margin: 0;
  border: 0;
  padding: 0;
}

.team-size-field legend {
  margin-bottom: 9px;
}

.size-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.size-options input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.size-options span {
  display: grid;
  min-height: 42px;
  place-items: center;
  border: 1px solid #354049;
  background: #0a0d10;
  color: #8e9aa1;
  cursor: pointer;
  font: 800 10px "Space Mono", monospace;
}

.size-options input:checked + span {
  border-color: var(--acid);
  background: rgba(217, 255, 67, 0.09);
  color: var(--acid);
}

.create-panel .primary-button {
  margin-top: auto;
}

.create-note {
  margin: -10px 0 0;
  color: #59656d;
  font-size: 9px;
  line-height: 1.5;
}

.game-view .scoreboard {
  grid-template-columns: 1fr auto 1fr;
  min-height: 74px;
}

.score-center {
  display: flex;
  min-width: 170px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.score-center .timer {
  display: block;
  position: static;
  transform: none;
  margin-bottom: 6px;
  color: var(--acid);
  font-size: 15px;
  letter-spacing: 0.08em;
  text-shadow: 0 0 15px rgba(217, 255, 67, 0.38);
}

.score-center .timer.golden {
  color: #fff06a;
  font-size: 11px;
}

.game-view .game-shell {
  border-radius: 0 0 5px 5px;
}

.waiting-card {
  max-width: 720px;
}

.roster {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 26px 0 16px;
}

.roster-team {
  min-height: 110px;
  border: 1px solid var(--line);
  padding: 14px;
  text-align: left;
}

.roster-team.blue {
  border-top-color: var(--blue);
}

.roster-team.red {
  border-top-color: var(--red);
}

.roster-team > span {
  display: block;
  margin-bottom: 9px;
  color: var(--muted);
  font: 700 8px "Space Mono", monospace;
}

.roster-player {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding: 6px 0;
  color: #ccd4d7;
  font-size: 10px;
}

.roster-player.me {
  color: var(--acid);
}

.online-control {
  min-height: 78px;
  margin-top: 12px;
  border-top-color: var(--acid);
}

.online-control strong {
  color: var(--acid);
}

.network-badge {
  position: absolute;
  right: 14px;
  bottom: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 5px 7px;
  background: rgba(5, 8, 10, 0.72);
  color: #77848b;
  font: 700 7px "Space Mono", monospace;
}

.game-footer {
  display: flex;
  justify-content: space-between;
  padding: 14px 4px 0;
  color: #5f6971;
  font: 700 9px "Space Mono", monospace;
}

.game-footer p {
  margin: 0;
}

.room-chat {
  display: grid;
  grid-template-columns: 150px 1fr minmax(280px, 0.55fr);
  align-items: stretch;
  margin-top: 14px;
  border: 1px solid var(--line);
  background: rgba(10, 13, 16, 0.92);
}

.chat-heading {
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-right: 1px solid var(--line);
  padding: 14px;
}

.chat-heading span {
  color: var(--acid);
  font: 700 9px "Space Mono", monospace;
  letter-spacing: 0.12em;
}

.chat-heading small {
  margin-top: 6px;
  color: #58636a;
  font-size: 8px;
  line-height: 1.45;
}

.chat-messages {
  display: flex;
  min-width: 0;
  max-height: 92px;
  flex-direction: column;
  gap: 5px;
  overflow-y: auto;
  padding: 11px 14px;
  scrollbar-color: #3b474e transparent;
  scrollbar-width: thin;
}

.chat-empty {
  margin: auto 0;
  color: #59646b;
  font-size: 9px;
}

.chat-message {
  margin: 0;
  color: #c7d0d3;
  font-size: 10px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.chat-message strong {
  margin-right: 6px;
  font: 700 9px "Space Mono", monospace;
}

.chat-message.blue strong {
  color: var(--blue);
}

.chat-message.red strong {
  color: var(--red);
}

.chat-message.me {
  color: #f3f6f7;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px;
  align-items: center;
  border-left: 1px solid var(--line);
  padding: 10px;
}

.chat-form input {
  min-width: 0;
  padding: 10px 11px;
  font-size: 11px;
}

.chat-form button {
  height: 100%;
  border: 1px solid var(--acid);
  padding: 0 14px;
  background: transparent;
  color: var(--acid);
  cursor: pointer;
  font: 800 9px "Space Mono", monospace;
}

.chat-form button:hover {
  background: var(--acid);
  color: #0a0d0e;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10;
  max-width: min(380px, calc(100% - 44px));
  transform: translateY(20px);
  border: 1px solid #49555c;
  padding: 13px 16px;
  background: #101519;
  color: #dfe5e6;
  opacity: 0;
  pointer-events: none;
  font-size: 11px;
  transition: 180ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

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

  .rooms-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .room-row .room-status {
    display: none;
  }
}

@media (max-width: 620px) {
  .lobby-intro {
    padding: 28px 20px;
  }

  .rooms-panel,
  .create-panel {
    padding: 22px 16px;
  }

  .room-row {
    gap: 10px;
    padding: 13px;
  }

  .room-meta {
    display: none;
  }

  .game-view .team {
    padding: 0 8px;
  }

  .score-center {
    min-width: 120px;
  }

  .game-footer p:last-child {
    display: none;
  }

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

  .chat-heading {
    display: none;
  }

  .chat-messages {
    min-height: 74px;
    max-height: 110px;
  }

  .chat-form {
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}
