*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #050510;
  font-family: 'Courier New', Courier, monospace;
  color: #fff;
  touch-action: none;
}

#gameCanvas {
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* ── UI Overlay ─────────────────────────────────────────── */
#ui-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: env(safe-area-inset-top, 8px) 8px env(safe-area-inset-bottom, 8px);
  z-index: 10;
}

#scores-top {
  display: flex;
  justify-content: space-between;
  padding: 6px 0 0;
}

#scores-bottom {
  display: flex;
  justify-content: space-between;
  padding: 0 0 6px;
}

.score-pill {
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 20px;
  background: rgba(0,0,0,0.55);
  border: 1px solid currentColor;
  opacity: 0.9;
}

#score-0 { color: #00eeff; }
#score-1 { color: #ff8800; }
#score-2 { color: #cc00ff; }
#score-3 { color: #ff0088; }

#timer-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

#timer {
  font-size: 28px;
  font-weight: bold;
  letter-spacing: 0.12em;
  color: #fff;
  text-shadow:
    0 0 8px rgba(255,255,255,0.9),
    0 0 20px rgba(255,255,255,0.5);
  background: rgba(0,0,0,0.6);
  padding: 4px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.2);
}

/* ── End Screen ─────────────────────────────────────────── */
#end-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(5, 5, 16, 0.82);
  z-index: 100;
  gap: 16px;
}

#end-screen.hidden { display: none; }

#end-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 50%, rgba(255,0,136,0.12) 0%, transparent 70%);
  pointer-events: none;
}

#end-message {
  font-size: 48px;
  font-weight: bold;
  letter-spacing: 0.15em;
  text-shadow: 0 0 30px currentColor, 0 0 60px currentColor;
  color: #ff0088;
  text-align: center;
  line-height: 1.2;
}

#end-sub {
  font-size: 16px;
  color: rgba(255,255,255,0.6);
  letter-spacing: 0.1em;
}

/* ── Start Screen ───────────────────────────────────────── */
#start-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(5,5,16,0.92);
  z-index: 200;
  gap: 20px;
}

#title {
  font-size: 56px;
  font-weight: bold;
  letter-spacing: 0.2em;
  text-align: center;
  line-height: 1.1;
  background: linear-gradient(135deg, #00eeff, #ff0088 60%, #cc00ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 20px rgba(255,0,136,0.5));
}

#start-sub {
  font-size: 14px;
  color: rgba(255,255,255,0.7);
  text-align: center;
  line-height: 1.7;
  letter-spacing: 0.06em;
}

#corner-hint {
  font-size: 13px;
  color: rgba(255,255,255,0.5);
  letter-spacing: 0.08em;
}

/* ── Buttons ────────────────────────────────────────────── */
button {
  font-family: inherit;
  font-size: 18px;
  font-weight: bold;
  letter-spacing: 0.15em;
  color: #fff;
  background: transparent;
  border: 2px solid #ff0088;
  border-radius: 40px;
  padding: 14px 48px;
  cursor: pointer;
  text-shadow: 0 0 10px #ff0088;
  box-shadow: 0 0 20px rgba(255,0,136,0.4), inset 0 0 20px rgba(255,0,136,0.05);
  transition: box-shadow 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

button:active {
  background: rgba(255,0,136,0.15);
  box-shadow: 0 0 40px rgba(255,0,136,0.7), inset 0 0 20px rgba(255,0,136,0.1);
}

button.secondary {
  border-color: #00eeff;
  text-shadow: 0 0 10px #00eeff;
  box-shadow: 0 0 16px rgba(0,238,255,0.35), inset 0 0 16px rgba(0,238,255,0.04);
  font-size: 15px;
  padding: 11px 36px;
}
button.secondary:active {
  background: rgba(0,238,255,0.12);
  box-shadow: 0 0 32px rgba(0,238,255,0.65), inset 0 0 16px rgba(0,238,255,0.08);
}

/* ── Menu & lobby layouts ──────────────────────────────── */
#menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  margin-top: 6px;
}

#conn-status {
  position: absolute;
  bottom: 20px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.15em;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
}
#conn-status.connected { color: rgba(0,238,255,0.7); }
#conn-status.error     { color: rgba(255,68,68,0.9); }

#join-screen, #lobby-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(5,5,16,0.94);
  z-index: 210;
  gap: 16px;
  padding: 24px;
}
#join-screen.hidden, #lobby-screen.hidden { display: none; }

.sub-title {
  font-size: 22px;
  letter-spacing: 0.25em;
  color: rgba(255,255,255,0.75);
  margin-bottom: 4px;
}

#code-input {
  font-family: inherit;
  font-size: 48px;
  font-weight: bold;
  letter-spacing: 0.3em;
  text-align: center;
  width: 240px;
  padding: 14px 10px;
  background: rgba(0,0,0,0.5);
  color: #00eeff;
  border: 2px solid #00eeff;
  border-radius: 12px;
  text-shadow: 0 0 14px #00eeff;
  box-shadow: 0 0 20px rgba(0,238,255,0.35), inset 0 0 20px rgba(0,238,255,0.06);
  outline: none;
  text-transform: uppercase;
}
#code-input::placeholder { color: rgba(0,238,255,0.25); }

#join-error {
  min-height: 18px;
  font-size: 12px;
  letter-spacing: 0.1em;
  color: #ff4466;
  text-shadow: 0 0 8px rgba(255,68,102,0.5);
}

#room-code {
  font-size: 64px;
  font-weight: bold;
  letter-spacing: 0.3em;
  color: #ff0088;
  text-shadow: 0 0 18px #ff0088, 0 0 40px rgba(255,0,136,0.6);
  background: rgba(0,0,0,0.45);
  padding: 10px 24px;
  border-radius: 12px;
  border: 2px solid rgba(255,0,136,0.55);
}
#room-hint {
  font-size: 12px;
  letter-spacing: 0.15em;
  color: rgba(255,255,255,0.55);
  text-transform: uppercase;
}
#ai-fill-note {
  font-size: 11px;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
}

#player-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(320px, 80vw);
  margin: 8px 0;
}

.player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(0,0,0,0.55);
  /* Rainbow gradient border using a layered background trick so the fill
     stays dark but the edge glows with the title's palette. */
  border: 2px solid transparent;
  background-image:
    linear-gradient(rgba(5,5,16,0.85), rgba(5,5,16,0.85)),
    linear-gradient(135deg, #00eeff, #ff0088 55%, #cc00ff);
  background-origin: border-box;
  background-clip: padding-box, border-box;
  font-size: 13px;
  letter-spacing: 0.08em;
  box-shadow: 0 0 14px rgba(255,0,136,0.18), 0 0 14px rgba(0,238,255,0.12);
}
.player-row .name {
  background: linear-gradient(135deg, #00eeff, #ff0088 60%, #cc00ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-transform: uppercase;
  filter: drop-shadow(0 0 6px rgba(255,0,136,0.35));
}
.player-row .tag {
  font-size: 10px;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.55);
  text-transform: uppercase;
}
.player-row.empty {
  opacity: 0.45;
  box-shadow: none;
}
.player-row.empty .name,
.player-row.empty .tag {
  background: none;
  -webkit-text-fill-color: rgba(255,255,255,0.45);
  color: rgba(255,255,255,0.45);
  filter: none;
}
