/* style.css — coin pusher arcade UI
   The HUD is a DOM overlay; the cabinet itself is rendered into <canvas id="game">.
   Layout is positioned over the canvas via #stage as a relative anchor. */

:root {
  /* Tiffany & Co. inspired palette. The signature box color (PMS 1837) is the
     deep Tiffany blue; the lighter accent is the polished robin's-egg shade
     used on the trim and metallic shine. */
  --tiffany:        #81D8D0;     /* lighter Tiffany blue (primary highlight) */
  --tiffany-deep:   #0ABAB5;     /* deep Tiffany blue (accent) */
  --tiffany-glow:   rgba(129, 216, 208, 0.55);
  --tiffany-edge:   rgba(129, 216, 208, 0.35);
  --tiffany-soft:   rgba(129, 216, 208, 0.18);
  --neon-cyan:      #81D8D0;     /* alias retained for older selectors */
  --neon-magenta:   #f4e7d8;     /* champagne cream — soft secondary */
  --neon-orange:    #e7b27a;     /* warm metallic to complement Tiffany blue */
  --led-red:        #e15869;
  --led-green:      #2bff7d;
  --bg-deep:        #050608;
  --panel:          rgba(10, 14, 22, 0.82);
  --panel-edge:     var(--tiffany-edge);
  --text:           #ecf6f4;
  --text-dim:       #9cb6b0;
  --lcd-bg:         #061412;
  --lcd-fg:         #81D8D0;
  --lcd-shadow:     rgba(129, 216, 208, 0.6);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at 50% 30%, #0e1726 0%, #04060a 65%, #000 100%);
  color: var(--text);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Courier New", monospace;
  overflow: hidden;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* The stage holds the canvas and HUD. Sized to canvas. */
#stage {
  position: relative;
  width: 900px;
  height: 600px;
  box-shadow:
    0 0 0 2px rgba(129, 216, 208, 0.18),
    0 0 80px rgba(129, 216, 208, 0.18),
    0 0 140px rgba(244, 231, 216, 0.12),
    inset 0 0 60px rgba(0, 0, 0, 0.5);
  border-radius: 14px;
  overflow: hidden;
}

#game {
  display: block;
  width: 900px;
  height: 600px;
  background: #000;
}

.hud {
  position: absolute;
  pointer-events: none;
  z-index: 10;
}

.hidden { display: none !important; }

/* ---------- top bar ---------- */
#topbar {
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
}

#attempts-block {
  display: none;                 /* hidden unless debug mode is on */
  flex-direction: column;
  gap: 2px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  padding: 4px 12px;
  border-radius: 6px;
  box-shadow: 0 0 12px rgba(129, 216, 208, 0.2);
}
body.debug #attempts-block { display: flex; }

.hud-label {
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--neon-cyan);
  text-shadow: 0 0 6px var(--neon-cyan);
}

.lcd {
  font-family: ui-monospace, "Courier New", monospace;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--lcd-fg);
  text-shadow:
    0 0 4px var(--lcd-shadow),
    0 0 10px var(--lcd-shadow);
  background: var(--lcd-bg);
  padding: 2px 10px;
  border-radius: 4px;
  border: 1px inset rgba(180, 255, 100, 0.25);
  min-width: 110px;
  text-align: center;
}

#channel-block {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
}

#channel-text { letter-spacing: 0.04em; }

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--led-red);
  box-shadow: 0 0 8px var(--led-red);
  transition: background 0.18s, box-shadow 0.18s;
}
.dot.on { background: var(--led-green); box-shadow: 0 0 10px var(--led-green); }
.dot.off { background: var(--led-red); box-shadow: 0 0 8px var(--led-red); }

/* ---------- stats panel (debug-only) ---------- */
#stats-panel {
  top: 78px;
  right: 8px;
  width: 200px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  box-shadow: 0 0 14px rgba(244, 231, 216, 0.12);
  display: none;                 /* hidden unless debug mode is on */
}
body.debug #stats-panel { display: block; }

.stats-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  border-bottom: 1px dashed rgba(129, 216, 208, 0.12);
}
.stats-row:last-child { border-bottom: none; }
.stats-row span { color: var(--text-dim); }
.stats-row b {
  color: var(--neon-cyan);
  font-weight: 600;
  text-shadow: 0 0 4px rgba(129, 216, 208, 0.4);
}

/* ---------- leaderboard ---------- */
#leaderboard-panel {
  top: 78px;
  right: 8px;
  width: 320px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 0 18px rgba(255, 200, 60, 0.22);
}
/* When debug is on, push the leaderboard left so the stats panel can sit beside it. */
body.debug #leaderboard-panel { right: 220px; }
.lb-title {
  color: var(--neon-orange);
  font-weight: 700;
  letter-spacing: 0.18em;
  font-size: 13px;
  text-shadow: 0 0 8px rgba(255, 170, 60, 0.6);
  margin-bottom: 8px;
  text-align: center;
}
#leaderboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: lb;
}
.lb-row {
  display: grid;
  /* 4 grid items per row: ::before rank | user | meta | percentage */
  grid-template-columns: 22px minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: baseline;
  padding: 5px 0;
  border-bottom: 1px dashed rgba(255, 170, 60, 0.14);
  counter-increment: lb;
}
.lb-row::before {
  content: counter(lb);
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.lb-row:nth-child(1)::before { color: gold;       text-shadow: 0 0 6px rgba(255, 215, 0, 0.7); }
.lb-row:nth-child(2)::before { color: silver;     text-shadow: 0 0 4px rgba(192, 192, 192, 0.6); }
.lb-row:nth-child(3)::before { color: #cd7f32;    text-shadow: 0 0 4px rgba(205, 127, 50, 0.6); }
.lb-row:last-child { border-bottom: none; }
.lb-user {
  color: var(--neon-magenta);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lb-meta {
  color: var(--text-dim);
  font-size: 11px;
  white-space: nowrap;
}
.lb-ret {
  color: var(--neon-orange);
  font-weight: 700;
  text-shadow: 0 0 4px rgba(255, 170, 60, 0.5);
  font-variant-numeric: tabular-nums;
}
.lb-empty {
  color: var(--text-dim);
  font-style: italic;
  text-align: center;
  padding: 6px 0;
}

/* ---------- cheers feed ---------- */
#cheers-feed {
  bottom: 8px;
  left: 8px;
  width: 320px;
  display: flex;
  flex-direction: column-reverse;
  gap: 4px;
  max-height: 200px;
  overflow: hidden;
}

.cheer-line {
  background: linear-gradient(90deg, rgba(129, 216, 208, 0.18), rgba(244, 231, 216, 0.04));
  border-left: 3px solid var(--neon-cyan);
  padding: 4px 8px;
  border-radius: 3px;
  font-size: 12px;
  color: var(--text);
  animation: cheerIn 0.4s ease-out, cheerFade 8s linear forwards;
}
.cheer-line .user { color: var(--neon-magenta); font-weight: 600; }
.cheer-line .bits { color: var(--neon-orange); font-weight: 600; }

@keyframes cheerIn {
  from { transform: translateX(-8px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
@keyframes cheerFade {
  0%, 60% { opacity: 1; }
  100%    { opacity: 0.25; }
}

/* ---------- now-playing banner ---------- */
#now-playing {
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 22px;
  background: linear-gradient(90deg,
    rgba(10, 186, 181, 0.22),
    rgba(129, 216, 208, 0.32),
    rgba(10, 186, 181, 0.22));
  border: 1px solid var(--tiffany);
  border-radius: 999px;
  box-shadow:
    0 0 18px rgba(129, 216, 208, 0.45),
    inset 0 0 12px rgba(129, 216, 208, 0.18);
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-family: ui-monospace, "Courier New", monospace;
  letter-spacing: 0.08em;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
#now-playing.hidden { display: none; }
#now-playing .np-label {
  color: var(--tiffany-deep);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-shadow: 0 0 6px rgba(10, 186, 181, 0.6);
}
#now-playing .np-user {
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  text-transform: uppercase;
  text-shadow: 0 0 8px rgba(129, 216, 208, 0.7);
}
#now-playing .np-bits {
  color: var(--neon-orange);
  font-size: 16px;
  font-weight: 700;
  text-shadow: 0 0 6px rgba(231, 178, 122, 0.6);
}

/* ---------- toast layer ---------- */
#toast-layer {
  top: 110px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.toast {
  background: linear-gradient(180deg, #ffd66a 0%, #ff8a2a 60%, #b3460e 100%);
  color: #1a0a00;
  font-weight: 800;
  font-size: 22px;
  letter-spacing: 0.04em;
  padding: 10px 22px;
  border-radius: 8px;
  border: 2px solid #ffe7a0;
  text-shadow: 0 1px 0 rgba(255,255,255,0.3);
  box-shadow:
    0 0 22px rgba(255, 138, 42, 0.7),
    0 0 60px rgba(255, 138, 42, 0.35),
    inset 0 0 10px rgba(255, 255, 255, 0.4);
  animation: toastIn 0.35s cubic-bezier(.2,1.6,.4,1), toastOut 0.5s ease-in 1.6s forwards;
}

@keyframes toastIn {
  from { transform: translateY(-30px) scale(0.85); opacity: 0; }
  to   { transform: translateY(0)     scale(1);    opacity: 1; }
}
@keyframes toastOut {
  to { transform: translateY(-12px) scale(0.95); opacity: 0; }
}

/* ---------- debug panel ---------- */
#debug-panel {
  top: 78px;
  left: 8px;
  background: var(--panel);
  border: 1px solid var(--neon-magenta);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  pointer-events: auto;
  box-shadow: 0 0 14px rgba(244, 231, 216, 0.35);
  min-width: 220px;
}

.debug-title {
  color: var(--neon-magenta);
  text-shadow: 0 0 6px var(--neon-magenta);
  font-weight: 700;
  letter-spacing: 0.18em;
  margin-bottom: 6px;
}
.debug-hint { color: var(--text-dim); font-weight: 400; letter-spacing: 0.04em; font-size: 10px; }

.debug-row { margin: 4px 0; }
.debug-row button {
  width: 100%;
  background: #142031;
  color: var(--neon-cyan);
  border: 1px solid var(--neon-cyan);
  padding: 6px 8px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: background 0.15s, color 0.15s, transform 0.05s;
}
.debug-row button:hover { background: var(--neon-cyan); color: #04101a; }
.debug-row button:active { transform: translateY(1px); }
