:root {
  --bg: #0b0e1a;
  --panel: #131730;
  --panel2: #1a2040;
  --border: #2a3160;
  --text: #e8ebff;
  --muted: #8b93c9;
  --neon: #5eead4;
  --pink: #f472b6;
  --gold: #fbbf24;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  background-image: radial-gradient(circle at 20% 0%, #1a1040 0%, transparent 50%),
    radial-gradient(circle at 80% 100%, #0a2438 0%, transparent 50%);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  display: flex;
  flex-direction: column;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}

h1 {
  font-family: 'Press Start 2P', monospace;
  font-size: 18px;
  margin: 0;
  color: var(--neon);
  text-shadow: 0 0 18px rgba(94, 234, 212, 0.45);
  letter-spacing: 1px;
}

.who { display: flex; align-items: center; gap: 8px; }
.who label { color: var(--muted); font-size: 14px; }
.who input {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--pink);
  font-weight: 800;
  padding: 8px 12px;
  width: 160px;
  font-size: 14px;
}

.online {
  color: var(--neon);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  text-shadow: 0 0 10px rgba(94, 234, 212, 0.5);
}

main {
  display: flex;
  flex: 1;
  gap: 20px;
  padding: 20px 24px;
  align-items: stretch;
}

.content { flex: 1; min-width: 0; }

.section-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  color: var(--muted);
  margin: 4px 0 16px;
  letter-spacing: 1px;
}

/* ---------- game cards ---------- */
.games {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.card {
  display: flex;
  gap: 14px;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--neon);
  box-shadow: 0 6px 24px rgba(94, 234, 212, 0.18);
}

.card-emoji { font-size: 34px; line-height: 1; }
.card-body h3 { margin: 0 0 2px; font-size: 16px; }
.card-body .by { margin: 0 0 8px; color: var(--muted); font-size: 12px; }
.card-body p { margin: 0 0 8px; font-size: 13px; color: #b9bfe8; line-height: 1.45; }
.card-body .best { color: var(--gold); font-size: 12px; font-weight: 600; margin: 0; }

/* ---------- play view ---------- */
.play-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.play-bar h2 { margin: 0; font-size: 18px; flex: 1; }

.btn {
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn:hover { border-color: var(--neon); }
.btn.ghost { background: transparent; }
.btn.gold { background: #3a2f10; border-color: #8a6d1d; color: var(--gold); }
.btn.gold:hover { border-color: var(--gold); }

.score-entry { display: flex; gap: 8px; }
.score-entry input {
  width: 130px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 12px;
  font-size: 14px;
}

.play-area { display: flex; gap: 16px; }

#frame {
  flex: 1;
  min-width: 0;
  aspect-ratio: 4 / 3.4;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #000;
}

.boards {
  width: 230px;
  flex-shrink: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}

.boards h3 { margin: 2px 0 10px; font-size: 14px; }
.boards ol { list-style: none; margin: 0; padding: 0; }
.boards li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px dashed #232a55;
  font-size: 13px;
}
.boards .medal { width: 24px; text-align: center; }
.boards .pname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.boards .pscore { color: var(--gold); font-weight: 700; }
.hint { color: var(--muted); font-size: 12px; line-height: 1.5; }

.controls-help { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--border); }
.controls-help p { color: var(--muted); font-size: 12px; line-height: 1.7; margin: 0; }

/* ---------- chat ---------- */
#chat {
  width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  max-height: calc(100vh - 160px);
  position: sticky;
  top: 16px;
}

#messages {
  flex: 1;
  overflow-y: auto;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-right: 4px;
}

.msg { font-size: 13px; line-height: 1.45; word-wrap: break-word; }
.msg .mtime { color: #565e93; font-size: 11px; }
.msg .mname { color: var(--neon); }
.msg.announce .mtext { color: var(--gold); font-weight: 600; }

#chat-form { display: flex; gap: 8px; margin-top: 12px; }
#chat-form input {
  flex: 1;
  min-width: 0;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 12px;
  font-size: 13px;
}

footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}
footer a { color: var(--neon); }

/* ---------- phones ---------- */
@media (max-width: 900px) {
  main { flex-direction: column; }
  #chat { width: 100%; max-height: 320px; position: static; }
  .play-area { flex-direction: column; }
  .boards { width: 100%; }
  #frame { aspect-ratio: 4 / 3.8; }
  h1 { font-size: 14px; }
}
