/* ============================================================
   DataCruise Word Games — Scrub the Data Mess
   Shares the terminal / hacker aesthetic of the series.
   ============================================================ */

:root {
  --bg-0: #06080c;
  --bg-1: #0a0e14;
  --bg-2: #11161f;
  --bg-3: #1a212e;
  --border: #1f2937;
  --border-hi: #2a3445;

  --neon-green: #00ff9c;
  --neon-cyan:  #00f0ff;
  --neon-magenta: #ff2e92;
  --neon-yellow: #ffd700;
  --neon-red: #ff5577;

  --text:   #c9d1d9;
  --text-dim: #8b949e;
  --text-faint: #4a5260;

  --mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Menlo', 'Consolas', monospace;

  --shadow-glow-green: 0 0 12px rgba(0, 255, 156, 0.45), 0 0 30px rgba(0, 255, 156, 0.15);
  --shadow-glow-cyan:  0 0 12px rgba(0, 240, 255, 0.45), 0 0 30px rgba(0, 240, 255, 0.15);
  --shadow-glow-mag:   0 0 12px rgba(255, 46, 146, 0.45), 0 0 30px rgba(255, 46, 146, 0.15);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body {
  background:
    radial-gradient(ellipse at top, rgba(0, 240, 255, 0.07), transparent 60%),
    radial-gradient(ellipse at bottom, rgba(255, 46, 146, 0.06), transparent 60%),
    var(--bg-0);
  min-height: 100vh;
  min-height: 100dvh;
}

/* CRT scanlines */
.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.12) 3px,
    rgba(0, 0, 0, 0) 4px
  );
  mix-blend-mode: multiply;
  opacity: 0.45;
}

#app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 16px;
}

/* =========================
   MENU SCREEN
   ========================= */
.screen-menu {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "brand  magni"
    "card   magni"
    "actions actions"
    "howto  howto";
  gap: 20px 28px;
  align-items: start;
  padding: 8px 0 32px;
}

.brand        { grid-area: brand; }
.menu-magni   { grid-area: magni; }
.card         { grid-area: card; }
.actions      { grid-area: actions; }
.howto        { grid-area: howto; }

.brand-tag {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--neon-cyan);
  opacity: 0.85;
  margin-bottom: 6px;
}
.title {
  font-size: clamp(28px, 5vw, 44px);
  margin: 0;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--text);
  text-shadow: var(--shadow-glow-green);
}
.title .accent {
  color: var(--neon-magenta);
  text-shadow: var(--shadow-glow-mag);
}
.subtitle {
  color: var(--text-dim);
  margin: 10px 0 0;
  max-width: 52ch;
}

.menu-magni {
  width: 140px;
  height: 140px;
  filter: drop-shadow(0 0 20px rgba(0, 240, 255, 0.25));
}

.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}
.card-label {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.diff-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.diff-btn {
  background: var(--bg-2);
  border: 1px solid var(--border-hi);
  border-radius: 8px;
  color: var(--text);
  padding: 12px 10px;
  font-family: var(--mono);
  text-align: left;
  cursor: pointer;
  transition: transform 80ms ease, border-color 120ms, box-shadow 120ms;
  display: grid;
  gap: 4px;
}
.diff-btn:hover { transform: translateY(-1px); border-color: var(--neon-cyan); }
.diff-btn.on {
  border-color: var(--neon-green);
  box-shadow: var(--shadow-glow-green);
}
.diff-name {
  font-size: 14px;
  letter-spacing: 2px;
  color: var(--neon-green);
}
.diff-meta {
  font-size: 11px;
  color: var(--text-dim);
}

.actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.btn-primary {
  background: var(--bg-2);
  color: var(--neon-green);
  border: 1px solid var(--neon-green);
  border-radius: 8px;
  padding: 12px 22px;
  font-family: var(--mono);
  font-size: 15px;
  letter-spacing: 2px;
  cursor: pointer;
  box-shadow: var(--shadow-glow-green);
  transition: transform 80ms ease, background 120ms;
}
.btn-primary:hover { transform: translateY(-1px); background: var(--bg-3); }
.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border-hi);
  border-radius: 8px;
  padding: 10px 14px;
  font-family: var(--mono);
  letter-spacing: 1px;
  cursor: pointer;
  transition: color 120ms, border-color 120ms;
}
.btn-ghost:hover { color: var(--neon-cyan); border-color: var(--neon-cyan); }
.btn-ghost-sm { padding: 6px 10px; font-size: 12px; }

.howto {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.howto-title {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--neon-cyan);
  margin-bottom: 6px;
}
.howto ul {
  margin: 0;
  padding-left: 18px;
  color: var(--text-dim);
  font-size: 13px;
}
.howto li { margin-bottom: 3px; }
.t-messy { color: var(--neon-magenta); }
.t-clean { color: var(--neon-green); }

/* =========================
   PLAY SCREEN
   ========================= */
.screen-play {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
  height: calc(100vh - 32px);
  height: calc(100dvh - 32px);
}

.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
}
.hud-left { display: flex; gap: 20px; }
.hud-right { display: flex; gap: 10px; align-items: center; }
.hud-stat {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.hud-key {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--text-dim);
}
.hud-val {
  font-size: 18px;
  color: var(--neon-green);
  text-shadow: var(--shadow-glow-green);
}
.hud-tot { color: var(--text-faint); font-size: 13px; }
.timer {
  font-size: 28px;
  font-weight: 700;
  color: var(--neon-cyan);
  text-shadow: var(--shadow-glow-cyan);
  letter-spacing: 2px;
  min-width: 92px;
  text-align: right;
  transition: color 120ms, text-shadow 120ms, transform 120ms;
}
.timer.low {
  color: var(--neon-yellow);
  text-shadow: 0 0 12px rgba(255, 215, 0, 0.6);
  animation: pulse 1s infinite;
}
.timer.penalty {
  color: var(--neon-red);
  text-shadow: 0 0 12px rgba(255, 85, 119, 0.7);
  transform: scale(1.08);
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.06); }
}

.playfield {
  position: relative;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr 260px;
  min-height: 0;
}

.heap {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 100%, rgba(0, 240, 255, 0.10), transparent 60%),
    repeating-linear-gradient(0deg, rgba(0, 240, 255, 0.04) 0 1px, transparent 1px 24px),
    repeating-linear-gradient(90deg, rgba(0, 240, 255, 0.04) 0 1px, transparent 1px 24px),
    var(--bg-2);
  border-right: 1px solid var(--border);
}
.heap::after {
  /* a faint ground line at the bottom */
  content: '';
  position: absolute;
  left: 4%;
  right: 4%;
  bottom: 4px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--neon-cyan), transparent);
  opacity: 0.5;
}

.tile {
  position: absolute;
  top: 0; left: 0;
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--border-hi);
  border-radius: 8px;
  padding: 9px 14px;
  font-family: var(--mono);
  font-size: 17px;
  letter-spacing: 0.5px;
  cursor: pointer;
  white-space: pre;
  user-select: none;
  transition:
    transform 380ms cubic-bezier(.34, 1.2, .64, 1),
    opacity 380ms ease,
    background 100ms,
    border-color 100ms,
    box-shadow 100ms,
    filter 380ms ease;
  box-shadow: 0 2px 0 rgba(0,0,0,0.5);
}
.tile:hover {
  background: var(--bg-2);
  border-color: var(--neon-cyan);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.35), 0 2px 0 rgba(0,0,0,0.5);
  z-index: 999 !important;
}
.tile.flying {
  pointer-events: none;
  transition:
    transform 400ms cubic-bezier(.55, .055, .675, .19),
    opacity 400ms ease;
}
.tile.shake.is-clean {
  background: rgba(255, 85, 119, 0.18);
  border-color: var(--neon-red);
  animation: shake 0.45s;
}
@keyframes shake {
  0%, 100% { translate: 0 0; }
  20% { translate: -4px 0; }
  40% { translate: 4px 0; }
  60% { translate: -3px 0; }
  80% { translate: 3px 0; }
}
.tile-text { display: inline-block; }

.bin-area {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding: 16px 8px;
  gap: 8px;
  background:
    radial-gradient(ellipse at 50% 100%, rgba(255, 46, 146, 0.12), transparent 60%),
    var(--bg-1);
}
.magni-side {
  width: 110px;
  height: 110px;
  filter: drop-shadow(0 0 14px rgba(0, 240, 255, 0.25));
}
.bin {
  width: 180px;
  height: 220px;
  filter: drop-shadow(0 6px 0 rgba(0,0,0,0.5));
}
.bin-svg { width: 100%; height: 100%; overflow: visible; }
.bin-lid {
  transform-origin: 14px 50px;
  transition: transform 200ms cubic-bezier(.34, 1.4, .64, 1);
}
.bin.open .bin-lid {
  transform: rotate(-40deg) translateY(-4px);
}

.bubble {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-3);
  border: 1px solid var(--neon-magenta);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  letter-spacing: 1px;
  opacity: 0;
  pointer-events: none;
  box-shadow: var(--shadow-glow-mag);
  transition: opacity 200ms ease, transform 200ms ease;
}
.bubble.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
  animation: bubblePop 1.4s forwards;
}
@keyframes bubblePop {
  0%   { opacity: 0; transform: translateX(-50%) translateY(6px); }
  15%  { opacity: 1; transform: translateX(-50%) translateY(-4px); }
  85%  { opacity: 1; transform: translateX(-50%) translateY(-4px); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-14px); }
}

/* =========================
   SCORE / GRADE primitives — used by the result panel below
   ========================= */
.score-grade {
  font-weight: 800;
  letter-spacing: 0;
}
.grade-s { color: var(--neon-yellow); text-shadow: 0 0 18px rgba(255, 215, 0, 0.6); }
.grade-a { color: var(--neon-green);  text-shadow: var(--shadow-glow-green); }
.grade-b { color: var(--neon-cyan);   text-shadow: var(--shadow-glow-cyan); }
.grade-c { color: var(--text); }
.grade-d { color: var(--neon-magenta); text-shadow: var(--shadow-glow-mag); }
.grade-f { color: var(--neon-red);    text-shadow: 0 0 14px rgba(255, 85, 119, 0.5); }
.pct-sym { font-size: 0.55em; color: var(--text-dim); margin-left: 4px; }

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

/* =========================
   REVEAL PHASE — heap stays in place, missed tiles light up by kind.
   ========================= */
.heap.revealing .tile { cursor: default; pointer-events: none; }

.tile.reveal-clean {
  opacity: 0.18;
  filter: grayscale(0.8);
}

.tile.reveal-messy {
  z-index: 500 !important;
  animation: tilePulse 1.6s ease-in-out infinite;
}

@keyframes tilePulse {
  0%, 100% { transform-origin: center; }
  50%      { filter: brightness(1.15); }
}

/* Per-kind colors — bright glow + matching border */
.tile.reveal-typo {
  background: rgba(255, 215, 0, 0.18);
  border-color: var(--neon-yellow);
  color: var(--neon-yellow);
  box-shadow: 0 0 14px rgba(255, 215, 0, 0.55), 0 0 32px rgba(255, 215, 0, 0.25);
}
.tile.reveal-junk {
  background: rgba(255, 85, 119, 0.20);
  border-color: var(--neon-red);
  color: var(--neon-red);
  box-shadow: 0 0 14px rgba(255, 85, 119, 0.55), 0 0 32px rgba(255, 85, 119, 0.25);
}
.tile.reveal-off-topic {
  background: rgba(255, 46, 146, 0.20);
  border-color: var(--neon-magenta);
  color: var(--neon-magenta);
  box-shadow: 0 0 14px rgba(255, 46, 146, 0.55), 0 0 32px rgba(255, 46, 146, 0.25);
}
.tile.reveal-duplicate {
  background: rgba(0, 240, 255, 0.18);
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.55), 0 0 32px rgba(0, 240, 255, 0.25);
}
.tile.reveal-bad-format {
  background: rgba(0, 255, 156, 0.18);
  border-color: var(--neon-green);
  color: var(--neon-green);
  box-shadow: 0 0 14px rgba(0, 255, 156, 0.55), 0 0 32px rgba(0, 255, 156, 0.25);
}

/* Small "kind" badge beneath the tile text */
.tile-badge {
  display: block;
  margin-top: 4px;
  font-size: 9px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid currentColor;
  color: inherit;
  text-align: center;
  white-space: nowrap;
  font-weight: 600;
}

/* =========================
   RESULT PANEL — replaces the bin area at round end
   ========================= */
.bin-area.show-result {
  background:
    radial-gradient(ellipse at 50% 0%, rgba(0, 255, 156, 0.10), transparent 70%),
    var(--bg-1);
  justify-content: flex-start;
  padding: 18px 12px;
  gap: 10px;
}
.result-panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.result-magni {
  width: 90px;
  height: 90px;
  filter: drop-shadow(0 0 14px rgba(0, 240, 255, 0.25));
}
.result-magni.cheer {
  filter: drop-shadow(0 0 18px rgba(0, 255, 156, 0.45));
  animation: bob 1.2s ease-in-out infinite;
}
.result-headline {
  font-size: 15px;
  letter-spacing: 3px;
  color: var(--neon-cyan);
  text-shadow: var(--shadow-glow-cyan);
}
.result-score {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 4px;
}
.result-score .score-grade {
  font-size: 56px;
  line-height: 0.9;
  font-weight: 800;
}
.result-score .score-pct {
  font-size: 30px;
  color: var(--text);
}
.result-meta {
  color: var(--text-dim);
  font-size: 12px;
  text-align: center;
}
.result-stats {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  width: 100%;
  max-width: 220px;
}
.result-stats li {
  display: flex;
  justify-content: space-between;
  color: var(--text-dim);
  font-size: 12px;
}
.result-stats strong { color: var(--neon-green); font-weight: 600; }
.result-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  align-items: stretch;
  margin-top: 10px;
}
.result-actions .btn-primary,
.result-actions .btn-ghost {
  width: 100%;
  text-align: center;
}

/* =========================
   Responsive tweaks
   ========================= */
@media (max-width: 720px) {
  .screen-menu {
    grid-template-columns: 1fr;
    grid-template-areas:
      "brand"
      "magni"
      "card"
      "actions"
      "howto";
  }
  .menu-magni { width: 100px; height: 100px; justify-self: center; }

  .playfield { grid-template-columns: 1fr 160px; }
  .bin { width: 130px; height: 160px; }
  .magni-side { width: 70px; height: 70px; }
  .tile { font-size: 12px; padding: 4px 8px; }
  .timer { font-size: 22px; min-width: 70px; }
  .hud-left { gap: 12px; }
  .hud-val { font-size: 15px; }
}
