/* Jev vs You — a bright little arcade.
   Two wells, thick outlines, candy blocks, and a panel that shows the numbers
   that actually moved the piece. */

:root {
  --ink: #2b1f4a;
  --ink-soft: #6a5f8a;
  --paper: #fffdf8;
  --line: #2b1f4a;
  --jev: #7b5cff;
  --you: #ff4d94;
  --lime: #3ddc84;
  --sun: #ffd23f;
  --cell: clamp(15px, 2.2vw, 25px);
  --radius: 18px;
  --shadow: 6px 6px 0 rgba(43, 31, 74, 0.16);

  --I: #46d9ff;
  --O: #ffd23f;
  --T: #b46cff;
  --S: #3ddc84;
  --Z: #ff6b6b;
  --J: #5b7bff;
  --L: #ff9f43;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 12% -10%, #ffe9c9 0%, transparent 60%),
    radial-gradient(900px 500px at 88% 0%, #ffd9ee 0%, transparent 55%),
    linear-gradient(170deg, #fff6ec 0%, #f7ecff 45%, #e6efff 100%);
  background-attachment: fixed;
}

h1, h2, .num, .start, .level, .who, .versus { font-family: Fredoka, system-ui, sans-serif; }

a { color: var(--jev); text-underline-offset: 3px; }

.arcade { max-width: 1260px; margin: 0 auto; padding: 26px 20px 56px; }

/* ------------------------------------------------------------- masthead */

.masthead {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px 24px;
  align-items: center;
  margin-bottom: 22px;
}

.wordmark { display: flex; align-items: center; gap: 16px; }

.logo {
  display: grid;
  grid-template-columns: repeat(2, 15px);
  grid-auto-rows: 15px;
  gap: 3px;
  transform: rotate(-8deg);
}
.logo i { border-radius: 4px; border: 2px solid var(--line); }
.logo i:nth-child(1) { background: var(--T); }
.logo i:nth-child(2) { background: var(--sun); }
.logo i:nth-child(3) { background: var(--I); }
.logo i:nth-child(4) { background: var(--you); }

.masthead h1 { margin: 0; font-size: 2.1rem; font-weight: 700; letter-spacing: -0.5px; }
.masthead h1 em { font-style: normal; color: var(--you); }
.masthead p { margin: 2px 0 0; color: var(--ink-soft); font-size: 0.98rem; }

.setup { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.levels {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--paper);
  border: 2.5px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
}

.level {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 7px 16px;
  border-radius: 999px;
  cursor: pointer;
}
.level:hover { color: var(--ink); }
.level.is-on { background: var(--ink); color: #fff; }

.start {
  border: 2.5px solid var(--line);
  border-radius: 999px;
  background: var(--lime);
  color: var(--ink);
  font-size: 1rem;
  font-weight: 600;
  padding: 10px 22px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.start:hover { transform: translate(-1px, -1px); box-shadow: 8px 8px 0 rgba(43, 31, 74, 0.18); }
.start:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 rgba(43, 31, 74, 0.18); }

.blurb {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
  max-width: 78ch;
}

/* ---------------------------------------------------------------- match */

.match {
  display: grid;
  grid-template-columns: 1fr minmax(150px, 190px) 1fr;
  gap: 18px;
  align-items: start;
}

.player {
  background: var(--paper);
  border: 3px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  display: grid;
  gap: 12px;
  justify-items: center;
}
.player.jev { --accent: var(--jev); }
.player.you { --accent: var(--you); }

.nameplate {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.who { font-size: 1.35rem; font-weight: 600; color: var(--accent); }
.tag {
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border: 2px solid rgba(43, 31, 74, 0.18);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}
.tag.is-live { border-color: var(--accent); color: var(--accent); }
.tag.is-thinking { border-color: var(--jev); color: var(--jev); animation: pulse 1.1s ease-in-out infinite; }
.tag.is-over { border-color: var(--you); color: var(--you); }

@keyframes pulse { 50% { opacity: 0.35; } }

.board { position: relative; overflow: hidden; border-radius: 12px; }

.well {
  display: grid;
  grid-template-columns: repeat(10, var(--cell));
  grid-auto-rows: var(--cell);
  gap: 2px;
  padding: 6px;
  background: linear-gradient(180deg, #f2edff, #fdf4ff);
  border: 3px solid var(--line);
  border-radius: 12px;
}

.well.slam { animation: slam 0.24s cubic-bezier(0.3, 1.4, 0.5, 1); }
@keyframes slam { 35% { transform: translateY(5px) scaleY(0.985); } }

.cell { border-radius: 5px; background: rgba(43, 31, 74, 0.055); }
.cell.on {
  background: var(--c);
  box-shadow: inset 0 3px rgba(255, 255, 255, 0.5), inset 0 -4px rgba(0, 0, 0, 0.16);
}
.cell.ghost { background: transparent; border: 2px dashed var(--c); }
.cell.flash { background: #fff; box-shadow: 0 0 12px #fff, inset 0 0 0 2px var(--sun); }

.stamp {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  font-family: Fredoka, sans-serif;
  font-size: 1.3rem;
  font-weight: 600;
  color: #fff;
  background: rgba(43, 31, 74, 0.55);
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  transform: rotate(-6deg);
}

.readout {
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.stat { display: grid; }
.num { font-size: 1.25rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat.big .num { font-size: 2rem; color: var(--accent); line-height: 1; }
.num.pop { animation: pop 0.34s cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes pop { 40% { transform: scale(1.28) rotate(-3deg); } }

.cap {
  font-size: 0.7rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.next { display: grid; gap: 4px; justify-items: center; }
.mini { display: grid; grid-auto-rows: 9px; gap: 2px; }
.mini .row { display: grid; grid-auto-flow: column; grid-auto-columns: 9px; gap: 2px; }
.mini .blk { border-radius: 2px; background: var(--c); }
.mini .gap { border-radius: 2px; background: transparent; }

/* --------------------------------------------------------------- middle */

.middle { display: grid; gap: 12px; justify-items: center; align-content: start; padding-top: 34px; }

.versus {
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  background: var(--ink);
  border-radius: 999px;
  padding: 10px 20px;
  box-shadow: var(--shadow);
  transform: rotate(-5deg);
}

.clock {
  display: grid;
  justify-items: center;
  gap: 1px;
}
.clock .num { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.clock.is-stopped .num { color: var(--ink-soft); }

.lead {
  text-align: center;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ink-soft);
  min-height: 2.6em;
  line-height: 1.3;
}

.keys, .pad {
  width: 100%;
  background: var(--paper);
  border: 2.5px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
}
.keys ul { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 5px; font-size: 0.84rem; }
.keys li { display: flex; align-items: center; gap: 6px; color: var(--ink-soft); }
kbd {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.72rem;
  background: #f1ecff;
  border: 1.5px solid rgba(43, 31, 74, 0.25);
  border-bottom-width: 3px;
  border-radius: 5px;
  padding: 1px 6px;
  color: var(--ink);
}

.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pad button {
  font-size: 1rem;
  padding: 10px 0;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #f4efff;
  cursor: pointer;
}
.pad button:active { background: var(--sun); }
.pad .wide { grid-column: 1 / -1; font-family: Fredoka, sans-serif; font-weight: 500; }

/* ------------------------------------------------------------- thinking */

.card {
  background: var(--paper);
  border: 3px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}

.thinking { margin-top: 20px; }

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 2px dashed rgba(43, 31, 74, 0.18);
  padding-bottom: 8px;
  margin-bottom: 14px;
}
.card-title { font-weight: 700; letter-spacing: -0.2px; }
.card-note { font-family: "JetBrains Mono", monospace; font-size: 0.74rem; color: var(--ink-soft); }

.thinking-body { display: grid; grid-template-columns: 1.1fr 1.4fr 1fr; gap: 22px; }

.chatter {
  margin: 0 0 8px;
  font-family: Fredoka, sans-serif;
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1.25;
}
.pick { margin: 0; color: var(--ink-soft); font-size: 0.9rem; }
.pick b { color: var(--ink); font-weight: 600; }

.overrule {
  margin: 10px 0 0;
  font-size: 0.86rem;
  background: #fff6d6;
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}

.bars { display: grid; align-content: start; gap: 7px; }
.bars .empty { margin: 0; color: var(--ink-soft); font-size: 0.88rem; }

.bar { display: grid; grid-template-columns: 44px 1fr; gap: 8px; align-items: center; font-size: 0.82rem; }
.bar .pct { font-family: "JetBrains Mono", monospace; text-align: right; color: var(--ink-soft); }
.bar .track { position: relative; background: rgba(43, 31, 74, 0.07); border-radius: 999px; height: 22px; overflow: hidden; }
.bar .fill { position: absolute; inset: 0 auto 0 0; background: #d9cfff; border-radius: 999px; transition: width 0.3s ease; }
.bar .label {
  position: relative;
  padding: 0 10px;
  line-height: 22px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar.is-pick .fill { background: var(--jev); }
.bar.is-pick .label { color: #fff; font-weight: 600; }
.bar.is-taken .track { outline: 2.5px solid var(--sun); outline-offset: 1px; }

.meters { display: grid; align-content: start; gap: 12px; }
.meter-head { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--ink-soft); margin-bottom: 4px; }
.meter-head span:last-child { font-family: "JetBrains Mono", monospace; color: var(--ink); }
.meters .track { background: rgba(43, 31, 74, 0.07); border-radius: 999px; height: 10px; overflow: hidden; }
.meters .fill { height: 100%; width: 0; border-radius: 999px; transition: width 0.35s ease; }
.fill.danger { background: linear-gradient(90deg, var(--lime), var(--sun) 55%, #ff5252); }
.fill.clear { background: var(--I); }
.fill.hold { background: var(--T); }
.fill.conf { background: var(--jev); }
.meter-note { margin: 5px 0 0; font-size: 0.76rem; color: var(--ink-soft); }

.error {
  margin: 14px 0 0;
  background: #ffe7e7;
  border: 2px solid #ff6b6b;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.88rem;
  white-space: pre-wrap;
}

footer { margin: 26px 0 0; color: var(--ink-soft); font-size: 0.86rem; max-width: 90ch; line-height: 1.55; }
footer code { font-family: "JetBrains Mono", monospace; font-size: 0.82em; }

/* ------------------------------------------------------------- confetti */

.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 50; }
.bit {
  position: absolute;
  width: 10px;
  height: 14px;
  border-radius: 3px;
  animation: fall linear forwards;
}
@keyframes fall {
  0% { transform: translate3d(0, 0, 0) rotate(0deg); opacity: 1; }
  100% { transform: translate3d(var(--dx), 105vh, 0) rotate(var(--spin)); opacity: 0.9; }
}

/* --------------------------------------------------------------- finale */

.finale {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(43, 31, 74, 0.45);
  backdrop-filter: blur(3px);
  z-index: 60;
}
.finale-card {
  background: var(--paper);
  border: 3px solid var(--line);
  border-radius: 22px;
  box-shadow: 10px 10px 0 rgba(43, 31, 74, 0.25);
  padding: 30px 38px;
  text-align: center;
  max-width: 460px;
  animation: pop-in 0.35s cubic-bezier(0.2, 1.5, 0.4, 1);
}
@keyframes pop-in { from { transform: scale(0.85) rotate(-2deg); opacity: 0; } }
.finale-kicker { margin: 0; letter-spacing: 0.12em; text-transform: uppercase; font-size: 0.72rem; color: var(--ink-soft); }
.finale h2 { margin: 6px 0 10px; font-size: 2.1rem; }
.finale-line { margin: 0 0 20px; color: var(--ink-soft); line-height: 1.5; }

/* ------------------------------------------------------------ narrower */

@media (max-width: 1040px) {
  .thinking-body { grid-template-columns: 1fr; gap: 16px; }
  .match { grid-template-columns: 1fr; }
  .middle { grid-template-columns: repeat(3, auto); padding-top: 0; align-items: center; }
  .middle .lead { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .masthead { grid-template-columns: 1fr; }
  :root { --cell: 7.5vw; }
  .middle { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
