/* ============================================================
   RAW ARCADE — stylesheet
   ============================================================ */

:root {
  --void: #07050e;
  --deep: #100823;
  --panel: #231145;
  --magenta: #ff2e7e;
  --cyan: #25f4ee;
  --amber: #ffb627;
  --lime: #a3ff12;
  --ink: #f4ecff;
  --dim: #8d7bb8;
  --faint: #5b4c80;
  --edge: rgba(255, 255, 255, 0.10);
  --glass: rgba(255, 255, 255, 0.05);
  --disp: 'Press Start 2P', monospace;
  --body: 'VT323', 'Courier New', monospace;
  --c: var(--magenta);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }

body {
  background: var(--void);
  color: var(--ink);
  font-family: var(--body);
  font-size: 20px;
  overflow-x: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: none;
}

canvas { display: block; image-rendering: pixelated; }
button, input { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input { cursor: text; }
::selection { background: var(--magenta); color: #000; }
.hidden { display: none !important; }

/* ---------- CRT atmosphere ---------- */
#bg { position: fixed; inset: 0; z-index: 0; }

#scanlines {
  position: fixed; inset: 0; z-index: 90; pointer-events: none;
  mix-blend-mode: multiply;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, .32) 0 1px, transparent 1px 3px);
}
#vignette {
  position: fixed; inset: 0; z-index: 91; pointer-events: none;
  background: radial-gradient(ellipse 125% 95% at 50% 50%, transparent 38%, rgba(0, 0, 0, .8) 100%);
}

/* ---------- boot ---------- */
#boot {
  position: fixed; inset: 0; z-index: 200; background: var(--void);
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  padding: 24px; text-align: center;
}
#boot.off { opacity: 0; pointer-events: none; transition: opacity .5s; }

#bootlog {
  font-size: 19px; color: var(--lime); text-align: left; width: min(440px, 92vw);
  line-height: 1.45; min-height: 200px; text-shadow: 0 0 8px currentColor;
}
#bootlog b { color: var(--cyan); font-weight: 400; }

#insert-coin {
  margin-top: 24px; font-family: var(--disp); font-size: 13px; color: var(--amber);
  padding: 17px 24px; border: 2px solid var(--amber); background: rgba(255, 182, 39, .07);
  animation: blink 1s steps(1) infinite;
  box-shadow: 0 0 28px rgba(255, 182, 39, .28), inset 0 0 24px rgba(255, 182, 39, .08);
}
@keyframes blink { 50% { opacity: .28; } }

/* ---------- shell ---------- */
#shell { position: relative; z-index: 10; min-height: 100%; display: none; flex-direction: column; }
#shell.on { display: flex; }

header {
  position: sticky; top: 0; z-index: 40;
  background: linear-gradient(180deg, rgba(16, 8, 35, .98), rgba(16, 8, 35, .86));
  backdrop-filter: blur(12px);
  border-bottom: 2px solid var(--edge);
  box-shadow: 0 5px 0 rgba(0, 0, 0, .5), 0 0 44px rgba(255, 46, 126, .16);
}
.bar { max-width: 1200px; margin: 0 auto; padding: 11px 16px; display: flex; align-items: center; gap: 12px; }

#logo {
  font-family: var(--disp); font-size: clamp(11px, 3.2vw, 19px); line-height: 1.35;
  letter-spacing: 1px; cursor: pointer; user-select: none; flex: 1;
  text-shadow: 2px 0 var(--magenta), -2px 0 var(--cyan), 0 0 24px rgba(255, 46, 126, .6);
}
#logo small {
  display: block; font-family: var(--body); font-size: 15px; letter-spacing: 3px;
  color: var(--dim); text-shadow: none; margin-top: 5px;
}

.hud { display: flex; align-items: center; gap: 7px; }
.chip {
  font-family: var(--disp); font-size: 9px; padding: 9px 10px; border: 2px solid var(--edge);
  background: var(--glass); color: var(--dim); line-height: 1; white-space: nowrap;
}
.chip b { color: var(--amber); font-weight: 400; }
.chip.on { border-color: var(--cyan); color: var(--cyan); }

.ticker { overflow: hidden; border-bottom: 2px solid var(--edge); background: #000; padding: 5px 0; }
.ticker span {
  display: inline-block; white-space: nowrap; font-size: 17px; color: var(--amber);
  letter-spacing: 1px; animation: scroll 40s linear infinite;
}
@keyframes scroll { from { transform: translateX(100vw); } to { transform: translateX(-100%); } }

main { flex: 1; max-width: 1200px; width: 100%; margin: 0 auto; padding: 20px 16px 60px; }

/* ---------- hero ---------- */
.hero {
  display: grid; grid-template-columns: minmax(0, 290px) minmax(0, 1fr); gap: 22px;
  align-items: center; border: 2px solid var(--edge);
  background: linear-gradient(135deg, var(--panel), var(--deep) 62%);
  padding: 18px; margin-bottom: 24px; position: relative; overflow: hidden;
}
.hero::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 16% 18%, rgba(255, 46, 126, .2), transparent 55%);
}
.hero .frame {
  position: relative; background: #000; border: 3px solid #000; aspect-ratio: 4 / 3;
  box-shadow: inset 0 0 34px rgba(0, 0, 0, .95), 0 0 44px -10px var(--c);
}
.hero .frame canvas { width: 100%; height: 100%; }
.hero .frame::after {
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, .35) 0 1px, transparent 1px 3px);
}
.hero .meta { position: relative; min-width: 0; }
.kicker { font-family: var(--disp); font-size: 9px; color: var(--amber); letter-spacing: 2px; margin-bottom: 12px; }
.hero h1 {
  font-family: var(--disp); font-size: clamp(15px, 4vw, 27px); margin: 0 0 12px;
  color: var(--c); line-height: 1.35; text-shadow: 3px 3px 0 rgba(0, 0, 0, .7);
}
.hero p { margin: 0 0 16px; font-size: 20px; color: var(--dim); line-height: 1.25; max-width: 44ch; }

.row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; align-items: center; }
.hero .row { justify-content: flex-start; }

.btn {
  font-family: var(--disp); font-size: 11px; padding: 14px 20px; border: 2px solid var(--cyan);
  color: var(--cyan); background: rgba(37, 244, 238, .08); letter-spacing: 1px;
}
.btn:active { background: var(--cyan); color: #000; }
.btn.primary { border-color: var(--amber); color: var(--amber); background: rgba(255, 182, 39, .1); }
.btn.primary:active { background: var(--amber); color: #000; }
.btn.ghost { border-color: var(--faint); color: var(--dim); background: none; font-size: 10px; padding: 12px 16px; }

/* ---------- search + categories ---------- */
.search {
  display: flex; align-items: center; gap: 9px; border: 2px solid var(--edge);
  background: var(--glass); padding: 9px 12px; margin-bottom: 12px;
}
.search input { flex: 1; font-size: 20px; outline: none; min-width: 0; }
.search input::placeholder { color: var(--faint); }
.search span { font-family: var(--disp); font-size: 10px; color: var(--faint); }

.cats { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.cat {
  font-family: var(--disp); font-size: 9px; padding: 10px 12px; border: 2px solid var(--edge);
  color: var(--dim); white-space: nowrap; background: var(--glass); flex-shrink: 0;
}
.cat.on { border-color: var(--c); color: var(--ink); background: rgba(255, 46, 126, .14); }

.eyebrow {
  font-family: var(--disp); font-size: 10px; color: var(--dim); letter-spacing: 2px;
  display: flex; align-items: center; gap: 12px; margin: 22px 0 14px;
}
.eyebrow::after { content: ''; flex: 1; height: 2px; background: linear-gradient(90deg, var(--edge), transparent); }

/* ---------- game cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 15px; }

.card {
  position: relative; border: 2px solid var(--edge); padding: 0; text-align: left;
  overflow: hidden; display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--panel), var(--deep));
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.card:hover, .card:focus-visible {
  transform: translateY(-6px); border-color: var(--c); outline: none;
  box-shadow: 0 9px 0 rgba(0, 0, 0, .55), 0 0 40px -8px var(--c);
}

.card .marquee {
  font-family: var(--disp); font-size: 9.5px; padding: 9px; color: #0b0616;
  letter-spacing: .5px; background: var(--c); line-height: 1.3;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .28);
  display: flex; justify-content: space-between; align-items: center; gap: 6px;
}
.card .marquee em { font-style: normal; font-size: 7.5px; opacity: .62; flex-shrink: 0; }

.card .tube {
  position: relative; background: #000; aspect-ratio: 4 / 3; overflow: hidden;
  border-top: 3px solid #000; border-bottom: 3px solid #000;
  box-shadow: inset 0 0 26px rgba(0, 0, 0, .95);
}
.card .tube canvas { width: 100%; height: 100%; }
.card .tube::after {
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, .36) 0 1px, transparent 1px 3px);
}

.card .panel { display: flex; align-items: center; gap: 7px; padding: 9px 10px 6px; background: rgba(0, 0, 0, .35); }
.card .stick { width: 12px; height: 12px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 3px rgba(0, 0, 0, .5), 0 0 10px var(--c); }
.card .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); opacity: .85; }
.card .best { margin-left: auto; font-size: 16px; color: var(--dim); }
.card .best b { color: var(--amber); font-weight: 400; }
.card .tagline { padding: 0 10px 10px; font-size: 16px; color: var(--faint); line-height: 1.2; background: rgba(0, 0, 0, .35); }

.empty { display: none; text-align: center; color: var(--dim); padding: 50px 20px; font-size: 21px; line-height: 1.4; }

footer {
  border-top: 2px solid var(--edge); padding: 24px 16px 46px; text-align: center;
  color: var(--dim); font-size: 17px; line-height: 1.6;
}
footer a { color: var(--cyan); text-decoration: none; border-bottom: 1px dotted; }

/* ---------- play screen ---------- */
#play { position: fixed; inset: 0; z-index: 60; display: none; flex-direction: column; background: var(--void); }
#play.on { display: flex; }

.playbar {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-bottom: 2px solid var(--edge); background: var(--deep);
}
#play-name {
  font-family: var(--disp); font-size: 11px; color: var(--c); flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.iconbtn { font-family: var(--disp); font-size: 9px; padding: 10px 11px; border: 2px solid var(--edge); background: var(--glass); }
.iconbtn:active { background: var(--c); color: #000; }

.stage { flex: 1; display: flex; align-items: center; justify-content: center; padding: 10px; min-height: 0; }

.bezel {
  position: relative; padding: 12px; border: 2px solid var(--edge); border-radius: 14px;
  background: linear-gradient(180deg, var(--panel), #0b0618); max-width: 100%; max-height: 100%;
  box-shadow: 0 14px 0 rgba(0, 0, 0, .6), 0 0 64px -14px var(--c), inset 0 2px 0 rgba(255, 255, 255, .07);
}
.bezel::after {
  content: ''; position: absolute; inset: 12px; pointer-events: none; border-radius: 4px;
  background: radial-gradient(ellipse at 50% 0%, rgba(255, 255, 255, .09), transparent 62%);
}
#screen {
  background: #000; width: min(86vw, calc((100dvh - 248px) * 1.333), 640px);
  aspect-ratio: 4 / 3; height: auto; border: 2px solid #000;
  box-shadow: inset 0 0 44px rgba(0, 0, 0, .95), 0 0 22px -4px var(--c);
}
.bezel.power-on #screen { animation: power .5s ease-out; }
@keyframes power {
  0%   { filter: brightness(6) contrast(3); transform: scaleY(.004); }
  45%  { filter: brightness(3) contrast(2); transform: scaleY(.06); }
  100% { filter: none; transform: scaleY(1); }
}

/* ---------- overlay ---------- */
#overlay {
  position: absolute; inset: 12px; display: none; flex-direction: column;
  align-items: center; justify-content: center; gap: 13px;
  background: rgba(5, 3, 12, .93); text-align: center; padding: 18px; z-index: 5;
}
#overlay.on { display: flex; }
#overlay h2 {
  font-family: var(--disp); font-size: clamp(13px, 4.4vw, 24px); margin: 0; color: var(--c);
  text-shadow: 3px 3px 0 rgba(0, 0, 0, .9), 0 0 26px var(--c);
}
#overlay-score { font-size: 25px; line-height: 1.35; }
#overlay-score b { color: var(--amber); font-weight: 400; }
#overlay-hint { font-size: 17px; color: var(--dim); max-width: 340px; line-height: 1.25; }

/* ---------- touch controls ---------- */
.pad {
  display: none; padding: 4px 16px calc(12px + env(safe-area-inset-bottom));
  gap: 12px; align-items: flex-end; justify-content: space-between; user-select: none;
}
body.touch .pad { display: flex; }

.dpad { display: grid; grid-template-columns: repeat(3, 53px); grid-template-rows: repeat(3, 53px); gap: 5px; }
.key {
  border: 2px solid var(--edge); background: linear-gradient(180deg, var(--panel), var(--deep));
  display: flex; align-items: center; justify-content: center; font-size: 23px;
  color: var(--dim); box-shadow: 0 4px 0 rgba(0, 0, 0, .55); touch-action: none;
}
.key.down { background: var(--c); color: #000; transform: translateY(3px); box-shadow: none; }
.key.up { grid-area: 1 / 2; }
.key.left { grid-area: 2 / 1; }
.key.right { grid-area: 2 / 3; }
.key.dn { grid-area: 3 / 2; }
.key.mid { grid-area: 2 / 2; border-color: transparent; background: none; box-shadow: none; }

.actions { display: flex; gap: 11px; align-items: flex-end; }
.key.round {
  width: 76px; height: 76px; border-radius: 50%; font-family: var(--disp); font-size: 12px;
  color: var(--ink); border-color: var(--magenta);
  background: radial-gradient(circle at 35% 30%, #3d2060, #150a26);
}
.key.round.small { border-color: var(--cyan); width: 60px; height: 60px; font-size: 10px; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(90px);
  z-index: 150; font-family: var(--disp); font-size: 10px; padding: 14px 18px;
  border: 2px solid var(--lime); color: var(--lime); background: rgba(7, 5, 14, .96);
  transition: transform .3s; text-align: center; line-height: 1.6; max-width: 88vw;
}
#toast.on { transform: translateX(-50%) translateY(0); }

/* ---------- responsive ---------- */
@media (max-width: 700px) {
  .hero { grid-template-columns: 1fr; gap: 14px; padding: 13px; }
  .hero .frame { max-width: 270px; margin: 0 auto; }
}
@media (max-width: 520px) {
  .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .card .marquee { font-size: 8px; padding: 7px; }
  .card .marquee em { display: none; }
  .card .tagline { font-size: 14px; }
  .card .best { font-size: 14px; }
  main { padding: 14px 11px 40px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
