/* ============================================================
   BASE — reset, global grit layer, shared components
   ============================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  background: var(--ink);
  color: var(--cream);
  font-family: var(--font-mono);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

body {
  background-image: var(--dotgrid);
  background-size: 26px 26px;
  overflow-x: hidden;
}

img { display: block; max-width: 100%; }
a { color: var(--teal); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

::selection { background: var(--orange); color: var(--ink); }

/* ---------- Global grit: grain + scanlines + vignette ---------- */
.grit-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9000;
}
.grit-layer::before {
  /* film grain via feTurbulence data-uri */
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.grit-layer::after {
  /* scanlines + vignette */
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(0,0,0,0.55) 100%),
    var(--scanlines);
  opacity: 0.5;
}

/* ---------- Type utilities ---------- */
.display {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 0.95;
}
.mono-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--cream-dim);
}
.jp {
  font-family: var(--font-jp);
  letter-spacing: 0.35em;
  font-size: 11px;
  color: var(--orange);
}

/* ---------- Riveted metal panel ---------- */
.panel {
  position: relative;
  background: var(--metal-brush);
  border: 1px solid rgba(242, 227, 194, 0.18);
  border-radius: var(--r-panel);
  box-shadow:
    inset 0 1px 0 rgba(242, 227, 194, 0.12),
    inset 0 -8px 24px rgba(0, 0, 0, 0.5),
    0 12px 40px rgba(0, 0, 0, 0.6);
}
.panel::before, .panel::after {
  /* corner rivets */
  content: "";
  position: absolute;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #555c68, #181b21 70%);
  box-shadow: inset 0 -1px 1px rgba(0,0,0,0.8), 0 0 2px rgba(0,0,0,0.6);
}
.panel::before { top: 9px; left: 9px; }
.panel::after  { bottom: 9px; right: 9px; }
.panel .rivet-tr, .panel .rivet-bl {
  position: absolute;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #555c68, #181b21 70%);
}
.panel .rivet-tr { top: 9px; right: 9px; }
.panel .rivet-bl { bottom: 9px; left: 9px; }

.panel-screen {
  /* dark "CRT screen" inset inside a panel */
  background:
    linear-gradient(180deg, rgba(127, 176, 168, 0.05), transparent 30%),
    var(--ink-2);
  border: 1px solid rgba(0, 0, 0, 0.7);
  border-radius: 10px;
  box-shadow: inset 0 2px 14px rgba(0, 0, 0, 0.8);
  position: relative;
  overflow: hidden;
}
.panel-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--scanlines);
  opacity: 0.35;
  pointer-events: none;
}

/* ---------- Buttons (double-stroke retro, gritted) ---------- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 18px;
  color: var(--ink);
  background: linear-gradient(180deg, var(--cream) 0%, #ddcca6 100%);
  border: 2px solid var(--ink);
  border-radius: var(--r-btn);
  padding: 14px 34px;
  box-shadow:
    0 0 0 3px var(--cream),
    0 0 0 4px rgba(0,0,0,0.8),
    0 6px 0 rgba(0, 0, 0, 0.55),
    0 14px 30px rgba(0, 0, 0, 0.5);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.15s ease;
}
.btn:hover { filter: brightness(1.06); }
.btn:active {
  transform: translateY(4px);
  box-shadow:
    0 0 0 3px var(--cream),
    0 0 0 4px rgba(0,0,0,0.8),
    0 2px 0 rgba(0, 0, 0, 0.55),
    0 6px 14px rgba(0, 0, 0, 0.5);
}
.btn--orange {
  background: linear-gradient(180deg, var(--orange-hot) 0%, var(--orange) 60%, #c45f1e 100%);
  box-shadow:
    0 0 0 3px var(--orange),
    0 0 0 4px rgba(0,0,0,0.8),
    0 6px 0 rgba(0, 0, 0, 0.55),
    0 14px 30px rgba(232, 118, 44, 0.25);
}
.btn--red {
  color: var(--cream);
  background:
    radial-gradient(rgba(242,227,194,0.25) 1px, transparent 1.4px) 0 0 / 8px 8px,
    linear-gradient(180deg, var(--red-hot), var(--red));
  box-shadow:
    0 0 0 3px var(--red),
    0 0 0 4px rgba(0,0,0,0.8),
    0 6px 0 rgba(0, 0, 0, 0.55),
    var(--glow-red);
}
.btn--ghost {
  color: var(--cream);
  background: rgba(242, 227, 194, 0.06);
  border-color: var(--cream);
  box-shadow: 0 0 0 3px transparent, inset 0 0 18px rgba(0,0,0,0.5);
}
.btn--big { font-size: 24px; padding: 18px 52px; }
.btn--skew { transform: skewX(-6deg); }
.btn--skew:active { transform: skewX(-6deg) translateY(4px); }
.btn--skew > * { transform: skewX(6deg); }

/* ---------- Badges & chips ---------- */
.badge-red {
  display: inline-block;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 12px;
  color: var(--cream);
  background: linear-gradient(180deg, var(--red-hot), var(--red));
  border: 1px solid rgba(0,0,0,0.6);
  border-radius: 6px;
  padding: 5px 14px;
  box-shadow: var(--glow-red), inset 0 1px 0 rgba(255,255,255,0.25);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  border: 1px solid currentColor;
  border-radius: var(--r-pill);
  padding: 3px 10px;
}
.chip--common { color: var(--silver); }
.chip--epic { color: var(--gold); text-shadow: 0 0 8px rgba(212,175,106,0.6); }
.chip--legendary {
  color: #fff;
  border: 1px solid transparent;
  background:
    linear-gradient(var(--ink), var(--ink)) padding-box,
    var(--holo) border-box;
  animation: holo-shift 3s linear infinite;
  background-size: auto, 300% 300%;
}
.chip--mystic {
  color: #eaf6ff;
  border: 1px solid transparent;
  background:
    linear-gradient(var(--ink), var(--ink)) padding-box,
    conic-gradient(from 0deg, #5bc8f7, #9b7bff, #6ee78a, #d4af6a, #ff5f9e, #5bc8f7) border-box;
  background-size: auto, 200% 200%;
  animation: holo-shift 4s linear infinite;
  text-shadow: 0 0 8px rgba(91, 200, 247, 0.7);
  box-shadow: 0 0 12px rgba(155, 123, 255, 0.35);
}

/* ---------- Rulers / dividers ---------- */
.ruler {
  height: 2px;
  background-image: linear-gradient(90deg, var(--cream-dim) 0 14px, transparent 14px 22px);
  background-size: 22px 2px;
  opacity: 0.5;
}
.ruler--dots {
  height: 4px;
  background-image: radial-gradient(var(--cream-dim) 1.4px, transparent 1.6px);
  background-size: 12px 4px;
}

/* ---------- Barcode strip ---------- */
.barcode {
  background-image: repeating-linear-gradient(
    90deg,
    var(--cream) 0 1px, transparent 1px 3px,
    var(--cream) 3px 5px, transparent 5px 6px,
    var(--cream) 6px 7px, transparent 7px 11px,
    var(--cream) 11px 13px, transparent 13px 14px
  );
  opacity: 0.75;
}
.barcode--v {
  background-image: repeating-linear-gradient(
    0deg,
    var(--cream) 0 1px, transparent 1px 3px,
    var(--cream) 3px 5px, transparent 5px 6px,
    var(--cream) 6px 7px, transparent 7px 11px,
    var(--cream) 11px 13px, transparent 13px 14px
  );
}

/* ---------- Star sparkles ---------- */
.sparkle {
  position: absolute;
  width: 18px; height: 18px;
  background: currentColor;
  color: rgba(242, 227, 194, 0.35);
  clip-path: polygon(50% 0%, 58% 42%, 100% 50%, 58% 58%, 50% 100%, 42% 58%, 0% 50%, 42% 42%);
  animation: sparkle-pulse 4s ease-in-out infinite;
}
@keyframes sparkle-pulse {
  0%, 100% { transform: scale(0.7); opacity: 0.4; }
  50% { transform: scale(1.15); opacity: 1; }
}

/* ---------- Holo shimmer keyframes (shared) ---------- */
@keyframes holo-shift {
  0% { background-position: 0% 50%; }
  100% { background-position: 300% 50%; }
}
@keyframes holo-rotate {
  to { transform: rotate(360deg); }
}

/* ---------- Warning stripes ---------- */
.hazard {
  background: repeating-linear-gradient(
    -45deg,
    var(--red) 0 12px,
    var(--ink) 12px 24px
  );
  opacity: 0.85;
}

/* ---------- Screen view switching ---------- */
.view { min-height: 100vh; min-height: 100dvh; }
.view:not(.is-active) { display: none !important; }
.view.is-active { animation: view-in 0.45s ease both; }
@keyframes view-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
  }
}
