:root {
  --ink: #eef4ff;
  --muted: #93a3c2;
  --bg-top: #0d1230;
  --bg-bottom: #050714;
  --amber: #ffb648;
  --tail: #ff5d6c;
  --accent: #4fd6a8;
  --panel: #12183aee;
  --panel-border: #2b3568;
  --board-bg: #080b1e;
  --grid-line: #ffffff10;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg-bottom);
  color: var(--ink);
}

body {
  position: relative;
  overflow-x: hidden;
}

.sky {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse at 80% -10%, #7c4dff33, transparent 55%),
    radial-gradient(ellipse at 10% 100%, #4fd6a822, transparent 50%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
}

a { color: var(--accent); }

.screen { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- landing ---------- */

.landing-card {
  flex: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: 12vh 24px 24px;
  text-align: center;
}

.landing-card h1 {
  font-size: 2.6rem;
  margin: 0 0 8px;
  letter-spacing: -0.02em;
}

.brick-emoji { display: inline-block; animation: drop 1.4s ease-in-out infinite; }
@keyframes drop { 0%, 100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-4px) rotate(8deg); } }

.tagline { color: var(--muted); font-size: 1rem; margin-bottom: 28px; }

#start-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 8px 24px #00000055;
}

#start-form label {
  text-align: left;
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#handle-input {
  font: inherit;
  padding: 12px 14px;
  border-radius: 9px;
  border: 1px solid var(--panel-border);
  background: #0b1030;
  color: var(--ink);
}

#handle-input:focus { outline: 2px solid var(--accent); }

#start-btn, #share-btn, .start-match-btn, #me-edit {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 9px;
  padding: 12px 16px;
  background: var(--accent);
  color: #052018;
  font-weight: 700;
  transition: transform 0.1s ease;
}
#start-btn:hover, #share-btn:hover, .start-match-btn:hover { transform: translateY(-1px); }
#start-btn:active, .start-match-btn:active { transform: translateY(1px); }

.status { min-height: 1.4em; color: var(--accent); font-size: 0.9rem; }
.status.error { color: var(--tail); }

.explainer { color: var(--muted); font-size: 0.85rem; line-height: 1.5; margin-top: 22px; }

.credit { text-align: center; padding: 18px; color: var(--muted); font-size: 0.78rem; }

/* ---------- room screen layout ---------- */

.room-header,
.arena,
#room .credit {
  max-width: 1080px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

#room-status {
  max-width: 1080px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding-left: 20px;
  padding-right: 20px;
  box-sizing: border-box;
}

.room-header {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--panel-border);
  background: #0a0e26cc;
  backdrop-filter: blur(4px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand { font-weight: 800; text-decoration: none; color: var(--ink); font-size: 1.05rem; }
.room-title { font-size: 0.95rem; }
.pill {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #4fd6a822;
  color: var(--accent);
  font-size: 0.72rem;
}

.identity { margin-left: auto; font-size: 0.85rem; color: var(--muted); }
#me-name { color: var(--ink); }
#me-edit {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--muted);
  padding: 4px 10px;
  font-size: 0.75rem;
  margin-left: 6px;
}
.share-btn { padding: 8px 14px; font-size: 0.85rem; }
.copy-btn {
  padding: 8px 14px;
  font-size: 0.85rem;
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--muted);
  border-radius: 9px;
  cursor: pointer;
  font-family: inherit;
}
.copy-btn.copied { color: var(--accent); border-color: var(--accent); }

/* ---------- arena ---------- */

.arena {
  display: flex;
  gap: 20px;
  padding: 20px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.board-col { flex: 0 0 auto; }

.hud-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.hud-box {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 6px 8px;
  text-align: center;
}
.hud-label { font-size: 0.62rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
#hold-canvas { display: block; image-rendering: pixelated; }
#next-canvas { display: block; image-rendering: pixelated; }

.stats-box { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 4px; min-width: 90px; }
.stat { display: flex; justify-content: space-between; font-size: 0.78rem; gap: 8px; }
.stat-label { color: var(--muted); }
.stat span:last-child { font-weight: 800; color: var(--amber); }

.board-wrap {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid var(--panel-border);
  box-shadow: 0 10px 30px #00000066;
  width: 300px;
  height: 600px;
}
#board-canvas { display: block; background: var(--board-bg); image-rendering: pixelated; }

.garbage-meter {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 8px;
  background: #ff5d6c00;
  transition: background 0.15s ease;
}
.garbage-meter.active { background: linear-gradient(0deg, var(--tail), #ff5d6c88); }

.countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  font-weight: 800;
  color: var(--amber);
  background: #00000088;
  text-shadow: 0 0 20px #00000099;
}

.board-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #000000b0;
  text-align: center;
  padding: 20px;
}
.board-overlay .overlay-title { font-size: 1.3rem; font-weight: 800; color: var(--amber); }
.board-overlay .overlay-sub { color: var(--muted); font-size: 0.85rem; }

.controls-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0 4px;
  flex-wrap: wrap;
}
.start-match-btn { font-size: 0.95rem; }
.start-match-btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.match-status-line { color: var(--muted); font-size: 0.82rem; }
.key-hint { color: var(--muted); font-size: 0.72rem; max-width: 300px; line-height: 1.4; }

/* ---------- side column ---------- */

.side-col {
  flex: 1 1 320px;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
}
.panel h2 { margin: 0 0 10px; font-size: 1rem; }
.panel h3 { margin: 14px 0 8px; font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.record-line { color: var(--accent); font-weight: 700; font-size: 0.95rem; margin: 0; }

.history-list, .results-list, .roster-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
}
.results-list { list-style: decimal; padding-left: 20px; }
.history-list li, .roster-list li {
  padding: 6px 8px;
  border-radius: 8px;
  background: #ffffff08;
  border: 1px solid var(--panel-border);
}
.results-list li { padding: 4px 2px; }
.roster-hint { color: var(--muted); font-size: 0.78rem; margin: 0 0 10px; }
.roster-list .you-tag { color: var(--amber); font-weight: 800; font-size: 0.7rem; margin-left: 4px; }

/* ---------- opponents ---------- */

.opponents-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.opponent-card {
  flex: 0 0 auto;
  width: 96px;
  background: #ffffff08;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 6px;
  text-align: center;
  transition: opacity 0.2s ease, filter 0.2s ease;
}
.opponent-card canvas { display: block; margin: 0 auto 4px; image-rendering: pixelated; border-radius: 4px; background: var(--board-bg); }
.opponent-card .opp-name { font-size: 0.66rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.opponent-card .opp-score { font-size: 0.7rem; color: var(--amber); font-weight: 800; }
.opponent-card.eliminated { opacity: 0.4; filter: grayscale(80%); }
.opponents-list .empty-note { color: var(--muted); font-size: 0.8rem; }

/* ---------- flying cheers ---------- */

#cheer-fly-layer { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }

.cheer-bubble-fly {
  position: absolute;
  font-size: 1.4rem;
}

@keyframes pop-fade {
  0% { opacity: 0; transform: translate(-50%, 6px) scale(0.7); }
  20% { opacity: 1; transform: translate(-50%, -4px) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -14px) scale(0.95); }
}

.match-over-banner {
  position: fixed;
  left: 50%;
  top: 18px;
  transform: translateX(-50%);
  background: var(--accent);
  color: #052018;
  font-weight: 800;
  padding: 10px 18px;
  border-radius: 999px;
  z-index: 60;
  animation: pop-fade 3.4s ease forwards;
}

@media (max-width: 720px) {
  .board-wrap { width: 100%; max-width: 300px; }
  .arena { justify-content: center; }
}
