:root {
  --bg: #0e1118;
  --panel: #171c28ee;
  --text: #e9edf5;
  --muted: #9aa3b5;
  --accent: #ffd23f;
  --red: #e8453c;
  --blue: #3d8bfd;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Rubik', system-ui, sans-serif;
  overflow: hidden;
}

#app {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#stage {
  position: relative;
  line-height: 0;
}

canvas {
  display: block;
  image-rendering: pixelated;
  border-radius: 6px;
  box-shadow: 0 0 0 3px #2a3142, 0 20px 60px #0008;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0d14b0;
  backdrop-filter: blur(2px);
  line-height: 1.4;
  border-radius: 6px;
}

.panel {
  background: var(--panel);
  border: 3px solid #2f374b;
  border-radius: 10px;
  padding: 24px 32px;
  min-width: 320px;
  max-width: 92%;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 10px 40px #000a;
}

h1, h2 {
  margin: 0;
  font-weight: 900;
  letter-spacing: 1px;
}

h1 {
  font-size: 44px;
  background: linear-gradient(90deg, var(--blue), #fff 50%, var(--red));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sub {
  margin: -6px 0 6px;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  color: var(--accent);
}

.menu-page { display: flex; flex-direction: column; gap: 10px; }
.hidden { display: none !important; }

.row { display: flex; gap: 8px; }

.rounds-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 700;
  color: var(--muted);
}
.seg { display: flex; gap: 4px; direction: ltr; }
.seg button {
  font-family: 'Press Start 2P', monospace;
  font-size: 13px;
  width: 44px;
  height: 36px;
  border-radius: 6px;
  border: 2px solid #3a445c;
  background: #11151f;
  color: var(--muted);
  cursor: pointer;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--accent); border-color: #c9a21f; color: #1a1a1a; }
.row .btn { flex: 1; }

.btn {
  font: inherit;
  font-size: 18px;
  font-weight: 700;
  padding: 12px 18px;
  border-radius: 8px;
  border: 2px solid #3a445c;
  background: #232a3a;
  color: var(--text);
  cursor: pointer;
  transition: transform .08s, background .15s;
}
.btn:hover { background: #2d364b; transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: #1a1a1a; border-color: #c9a21f; }
.btn.primary:hover { background: #ffdc66; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); font-size: 15px; }
.btn.small { font-size: 14px; padding: 8px 12px; }

select, input {
  font: inherit;
  font-size: 16px;
  border-radius: 8px;
  border: 2px solid #3a445c;
  background: #11151f;
  color: var(--text);
  padding: 8px 10px;
}

#join-code {
  font-family: 'Press Start 2P', monospace;
  font-size: 22px;
  text-align: center;
  letter-spacing: 6px;
  text-transform: uppercase;
  direction: ltr;
}

.code {
  font-family: 'Press Start 2P', monospace;
  font-size: 30px;
  letter-spacing: 8px;
  color: var(--accent);
  direction: ltr;
  padding: 10px;
  background: #0d1018;
  border-radius: 8px;
  user-select: all;
}

.status { color: var(--muted); min-height: 1.4em; margin: 0; }
.status.err { color: #ff7b72; }

.help {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
  display: grid;
  gap: 4px;
  text-align: right;
  border-top: 1px solid #2f374b;
  padding-top: 12px;
}

kbd {
  display: inline-block;
  min-width: 20px;
  padding: 1px 5px;
  margin: 0 1px;
  font-family: inherit;
  font-size: 11px;
  border-radius: 4px;
  background: #2a3142;
  border-bottom: 2px solid #11151f;
  color: var(--text);
  text-align: center;
}

.final {
  font-family: 'Press Start 2P', monospace;
  font-size: 34px;
  direction: ltr;
}
.final .r { color: var(--red); }
.final .b { color: var(--blue); }

#toolbar {
  position: absolute;
  top: 8px;
  left: 62%;
  line-height: 1;
  display: flex;
  gap: 6px;
}
.tbtn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 2px solid #2f374b;
  background: #171c28;
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
}
.tbtn:hover { background: #232a3a; }

#toast {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: #000c;
  padding: 8px 16px;
  border-radius: 8px;
  line-height: 1.4;
  font-size: 15px;
  white-space: nowrap;
}

@media (max-width: 600px) {
  .panel { padding: 16px; min-width: 0; gap: 8px; }
  h1 { font-size: 30px; }
  .btn { font-size: 15px; padding: 9px 12px; }
  .help { display: none; }
  .tbtn { width: 26px; height: 26px; font-size: 12px; }
}
