@import url("https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,700;0,900;1,700;1,900&family=Space+Grotesk:wght@400;500;700&display=swap");

/* Serif Storm — neo-brutalism. Palette: 3 colors + black/white.
   RED #FF3D00 · BLUE #2545FF · YELLOW #FFC900 · INK #131313 · PAPER #FFFDF4 */
:root {
  --red: #ff3d00;
  --blue: #2545ff;
  --yellow: #ffc900;
  --ink: #131313;
  --paper: #fffdf4;
  --shadow: 5px 5px 0 var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
  --border: 3px solid var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: "Space Grotesk", system-ui, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  background-image:
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(19,19,19,.06) 31px 32px),
    repeating-linear-gradient(90deg, transparent 0 31px, rgba(19,19,19,.06) 31px 32px);
}

/* ——— header ——— */
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 14px 20px;
  background: var(--ink); color: var(--paper);
  border-bottom: 4px solid var(--ink);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-badge {
  width: 52px; height: 52px; display: grid; place-items: center;
  background: var(--yellow); color: var(--ink);
  font-family: "Playfair Display", serif; font-weight: 900; font-size: 22px;
  border: 3px solid var(--paper); box-shadow: 4px 4px 0 var(--red);
  transform: rotate(-4deg);
}
.topbar h1 {
  font-family: "Playfair Display", serif; font-weight: 900;
  font-size: clamp(26px, 5vw, 40px); margin: 0; line-height: 1;
  letter-spacing: -0.5px;
}
.topbar h1::after { content: " ⛈"; color: var(--yellow); }
.tagline { margin: 4px 0 0; font-size: 13px; opacity: .85; }
.stats { display: flex; gap: 10px; flex-wrap: wrap; }
.stat {
  flex: 1 1 0; min-width: 0;
  text-align: center;
  background: var(--paper); color: var(--ink);
  border: 3px solid var(--paper); box-shadow: 3px 3px 0 var(--blue);
  padding: 4px 8px;
}
.stat:nth-child(2) { box-shadow: 3px 3px 0 var(--red); }
.stat:nth-child(3) { box-shadow: 3px 3px 0 var(--yellow); }
.stat span { display: block; font-weight: 700; font-size: 20px; font-variant-numeric: tabular-nums; }
.stat label { font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px; }

/* ——— ticker ——— */
.ticker {
  background: var(--red); color: var(--paper);
  border-bottom: var(--border);
  overflow: hidden; white-space: nowrap;
  font-weight: 700; font-size: 13px; letter-spacing: 2px;
  padding: 7px 0;
}
.ticker-inner { display: inline-block; animation: tick 18s linear infinite; }
@keyframes tick { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* ——— layout ——— */
#app { max-width: 1060px; margin: 0 auto; padding: 18px 16px 40px; }
.stage-wrap { position: relative; }
#stage {
  display: block; width: 100%; height: min(62vh, 520px); min-height: 340px;
  background: var(--paper);
  border: var(--border); box-shadow: var(--shadow);
  cursor: crosshair; touch-action: none;
}
.stage-hint {
  position: absolute; left: 12px; bottom: -16px;
  background: var(--ink); color: var(--paper);
  font-size: 12px; font-weight: 700; letter-spacing: .5px;
  padding: 6px 12px; border: 3px solid var(--ink);
  box-shadow: var(--shadow-sm); box-shadow: 3px 3px 0 var(--blue);
  pointer-events: none;
}

/* ——— deck ——— */
.deck {
  display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px;
  margin-top: 34px;
}
.card {
  background: var(--paper);
  border: var(--border); box-shadow: var(--shadow);
  padding: 16px 16px 18px;
}
.card h2 {
  font-family: "Playfair Display", serif; font-weight: 900;
  font-size: 22px; margin: 0 0 12px;
  display: flex; align-items: center; gap: 10px;
}
.nugget {
  width: 30px; height: 30px; display: inline-grid; place-items: center;
  border: 3px solid var(--ink); font-family: "Space Grotesk", sans-serif;
  font-size: 15px; font-weight: 700; transform: rotate(-3deg);
}
.n-red { background: var(--red); color: #fff; }
.n-blue { background: var(--blue); color: #fff; }

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row .btn { flex-shrink: 0; }
#word-input {
  flex: 1; min-width: 0;
  font: 700 16px "Space Grotesk", sans-serif;
  padding: 10px 12px;
  border: var(--border); background: #fff;
  box-shadow: inset 3px 3px 0 rgba(19,19,19,.12);
}
#word-input:focus { outline: 3px solid var(--yellow); outline-offset: 1px; }
.microcopy { font-size: 12.5px; margin: 10px 0 0; }
kbd {
  border: 2px solid var(--ink); background: var(--yellow);
  padding: 0 6px; font-family: inherit; font-weight: 700; font-size: 11px;
  box-shadow: 2px 2px 0 var(--ink);
}

.poem-card {
  margin-top: 14px; border: var(--border); background: var(--ink);
  color: var(--paper); padding: 10px 12px; box-shadow: 4px 4px 0 var(--red);
}
.poem-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; text-transform: uppercase; letter-spacing: 2px;
  color: var(--yellow); font-weight: 700; margin-bottom: 6px;
}
#poem-line {
  font-family: "Playfair Display", serif; font-style: italic;
  font-size: 17px; line-height: 1.45; margin: 0; min-height: 48px;
}
.mini-btn {
  border: 2px solid var(--paper); background: transparent; color: var(--paper);
  font: 700 11px "Space Grotesk", sans-serif; letter-spacing: 1px;
  padding: 3px 10px; cursor: pointer;
}
.mini-btn:hover { background: var(--yellow); color: var(--ink); border-color: var(--yellow); }
.mini-btn:active { transform: translate(2px, 2px); }

/* sliders */
.slider { display: block; font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 12px; }
.slider b { float: right; background: var(--ink); color: var(--yellow); padding: 0 8px; font-variant-numeric: tabular-nums; }
.slider input[type="range"] {
  width: 100%; margin-top: 8px; appearance: none; height: 12px;
  background: #fff; border: var(--border); cursor: pointer;
}
.slider input[type="range"]::-webkit-slider-thumb {
  appearance: none; width: 24px; height: 24px;
  background: var(--blue); border: 3px solid var(--ink);
  box-shadow: 2px 2px 0 var(--ink); cursor: grab;
}
.slider input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; background: var(--blue);
  border: 3px solid var(--ink); border-radius: 0; cursor: grab;
}

/* buttons */
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
.btn {
  font: 700 14px "Space Grotesk", sans-serif;
  border: var(--border); padding: 10px 8px; cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .06s ease, box-shadow .06s ease;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.btn-red { background: var(--red); color: #fff; }
.btn-blue { background: var(--blue); color: #fff; grid-column: 1 / -1; }
.btn-yellow { background: var(--yellow); color: var(--ink); }
.btn-paper { background: #fff; color: var(--ink); }

.foot {
  margin-top: 30px; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  font-size: 12px; font-weight: 500;
  border-top: var(--border); padding-top: 12px;
}
#toast {
  font-weight: 700; background: var(--yellow);
  border: 2px solid var(--ink); padding: 2px 10px;
  box-shadow: 2px 2px 0 var(--ink);
  opacity: 0; transition: opacity .2s;
}
#toast.show { opacity: 1; }

/* ——— 375px ——— */
@media (max-width: 640px) {
  .deck { grid-template-columns: 1fr; }
  #stage { height: 52vh; min-height: 300px; }
  .topbar { padding: 12px; }
  .stats { width: 100%; }
  .stat { flex: 1; }
  .btn-grid { grid-template-columns: 1fr 1fr; }
  .stage-hint { font-size: 11px; left: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .ticker-inner { animation: none; }
}
