:root {
  --ink: #0b1030;
  --paper: #f6f1e0;
  --gold: #ffd34d;
  --red: #ff4d5e;
  --cyan: #59e1ff;
  --shadow: 0 6px 0 rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(120% 90% at 50% 0%, #1a2a6c 0%, #0b1030 55%, #05060f 100%);
  color: var(--paper);
  font-family: "Trebuchet MS", "DejaVu Sans", system-ui, sans-serif;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}

#canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: auto;
}

/* Balayage CRT discret, pour l'ambiance jeu télé des années 90. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, .028) 0 1px,
    transparent 1px 3px
  );
  mix-blend-mode: overlay;
}

#hud {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px 22px 16px;
  pointer-events: none;
}

.top, .bottom {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.spacer { flex: 1; }

.card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(9, 12, 32, .62);
  border: 1px solid rgba(255, 255, 255, .12);
  backdrop-filter: blur(6px);
}

.label {
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  opacity: .62;
}

.code {
  font-family: "Courier New", monospace;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: .18em;
  color: var(--gold);
  text-shadow: var(--shadow);
}

.sip {
  font-size: 12px;
  opacity: .8;
  font-family: "Courier New", monospace;
}

.stats {
  display: flex;
  gap: 10px;
}

.stat {
  min-width: 78px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(9, 12, 32, .58);
  border: 1px solid rgba(255, 255, 255, .1);
}

.stat span:last-child {
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

#lives { color: var(--red); letter-spacing: 2px; }
#time { color: var(--cyan); }

.keys {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 48vw;
}

.key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 8px;
  background: rgba(9, 12, 32, .55);
  border: 1px solid rgba(255, 255, 255, .12);
  font-size: 12px;
}

.key b {
  display: inline-block;
  min-width: 18px;
  text-align: center;
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--gold);
  color: #23180a;
  font-family: "Courier New", monospace;
}

.key.hot {
  border-color: var(--gold);
  box-shadow: 0 0 12px rgba(255, 211, 77, .45);
}

.feed {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(9, 12, 32, .58);
  border: 1px solid rgba(255, 255, 255, .1);
}

.digits {
  font-family: "Courier New", monospace;
  font-size: 20px;
  letter-spacing: .22em;
  color: var(--gold);
  min-width: 110px;
}

.latency { font-size: 11px; opacity: .6; font-variant-numeric: tabular-nums; }

.message {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 42px;
  font-weight: 800;
  color: var(--gold);
  text-shadow: 0 8px 0 rgba(0, 0, 0, .45);
  opacity: 0;
  transition: opacity .25s ease;
  text-align: center;
  max-width: 80vw;
}

.message.show { opacity: 1; }

.status {
  position: fixed;
  right: 18px;
  bottom: 64px;
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  opacity: .45;
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  background: rgba(5, 6, 15, .72);
  backdrop-filter: blur(3px);
  transition: opacity .4s ease;
}

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

.overlay h1 {
  font-size: clamp(34px, 7vw, 72px);
  margin: 0;
  color: var(--gold);
  letter-spacing: .06em;
  text-shadow: 0 10px 0 rgba(0, 0, 0, .4);
}

.overlay p { max-width: 620px; font-size: 17px; line-height: 1.5; opacity: .9; }
.overlay .hint { font-size: 13px; opacity: .55; }

@media (max-width: 720px) {
  .stats { flex-wrap: wrap; justify-content: flex-end; }
  .stat { min-width: 62px; }
  .stat span:last-child { font-size: 19px; }
  .code { font-size: 26px; }
  .keys { display: none; }
  .message { font-size: 30px; }
}
