@font-face {
  font-family: 'Emulogic';
  src: url('assets/fonts/emulogic.ttf') format('truetype');
  font-display: swap;
}

:root {
  --ink: #080a10;
  --ink-2: #0d1018;
  --panel: #10141d;
  --panel-2: #151a25;
  --line: rgba(255, 255, 255, 0.09);
  --cream: #fff7e4;
  --muted: #8f95a8;
  --red: #ed3a27;
  --gold: #ffc23a;
  --blue: #5f8dff;
  --green: #4be06f;
  --pixel: 'Emulogic', 'Courier New', monospace;
}

* { box-sizing: border-box; }

html, body {
  min-height: 100%;
  margin: 0;
}

body {
  color: var(--cream);
  background:
    radial-gradient(1200px 680px at 52% -12%, rgba(79, 102, 255, 0.18), transparent 65%),
    radial-gradient(900px 520px at 95% 20%, rgba(255, 55, 31, 0.11), transparent 68%),
    radial-gradient(700px 480px at 4% 90%, rgba(255, 194, 58, 0.06), transparent 70%),
    #090b12;
  font-family: 'Trebuchet MS', 'Avenir Next', system-ui, sans-serif;
  overflow-x: hidden;
}

.noise {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.8'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

.page {
  position: relative;
  z-index: 1;
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 28px clamp(18px, 3.4vw, 48px) 20px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 0 2px 20px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: grid;
  grid-template-columns: auto auto;
  align-items: baseline;
  gap: 0 12px;
}

.brand-kicker {
  grid-column: 1 / -1;
  margin-bottom: 7px;
  color: #888fa8;
  font-family: var(--pixel);
  font-size: 8px;
  letter-spacing: 1.7px;
}

.brand-title {
  display: flex;
  gap: 8px;
  align-items: baseline;
  color: var(--cream);
  text-decoration: none;
  font-family: var(--pixel);
  font-size: clamp(18px, 2.6vw, 31px);
  line-height: 1;
  letter-spacing: -1px;
  text-shadow: 0 3px 0 #65120e, 0 5px 20px rgba(0, 0, 0, 0.6);
}
.brand-title span { display: inline-block; }
.brand-super { color: var(--gold); font-size: 0.64em; transform: translateY(-4px) rotate(-3deg); }
.brand-mario { color: #f04a2e; }
.brand-bro { color: var(--cream); }

.brand-sub {
  color: #ffd36b;
  font-family: var(--pixel);
  font-size: 8px;
  letter-spacing: 1.5px;
  transform: translateY(-2px);
}

.top-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-bottom: 2px; }

.chip-button {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  color: #d9dbea;
  font-family: var(--pixel);
  font-size: 8px;
  line-height: 1;
  padding: 10px 13px 9px;
  cursor: pointer;
  transition: 160ms ease;
  white-space: nowrap;
}
.chip-button:hover { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.24); transform: translateY(-1px); }
.chip-button:active { transform: translateY(0); }
.chip-button.is-muted { color: #ffb199; border-color: rgba(255, 93, 65, 0.3); }
.chip-button.danger { color: #ffb19b; border-color: rgba(255, 104, 72, 0.25); }
.chip-button.active { color: #ffd56b; border-color: rgba(255, 194, 58, 0.42); background: rgba(255, 194, 58, 0.1); }
.chip-button .icon { font-family: sans-serif; font-size: 10px; margin-right: 2px; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: clamp(26px, 3.4vw, 48px);
  align-items: start;
  padding-top: 26px;
}

.screen-column { min-width: 0; display: flex; flex-direction: column; align-items: center; }

.cabinet {
  width: min(100%, calc((100vh - 245px) * 1.142857));
  min-width: 0;
  background: linear-gradient(180deg, #1a1c25 0%, #0d0f15 100%);
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 18px;
  padding: 13px;
  box-shadow:
    0 32px 80px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.cabinet-top, .cabinet-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 4px 10px;
  color: #737b90;
  font-family: var(--pixel);
  font-size: 6px;
  letter-spacing: 1px;
}
.cabinet-bottom { padding: 11px 4px 0; border-top: 1px solid rgba(255, 255, 255, 0.06); }
.cabinet-led {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px rgba(75, 224, 111, 0.8);
  margin-right: auto;
}
.cabinet-model { color: #a6acc0; }
.cabinet-hint { color: #8c93a7; letter-spacing: 0.7px; }
.cabinet-serial { color: #5e667c; }

.screen-bezel {
  background: #05060a;
  border-radius: 8px;
  padding: 8px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.07),
    inset 0 0 40px rgba(0, 0, 0, 0.9);
}

.screen {
  position: relative;
  aspect-ratio: 256 / 224;
  width: 100%;
  overflow: hidden;
  border-radius: 3px;
  background: #000;
  box-shadow: 0 0 24px rgba(78, 132, 255, 0.12), 0 0 70px rgba(255, 73, 30, 0.06);
  isolation: isolate;
}

#game {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: pointer;
  outline: none;
}

.scanlines {
  position: absolute; inset: 0; z-index: 3; pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.17) 0px, rgba(0, 0, 0, 0.17) 1px, transparent 1px, transparent 3px);
  opacity: 0.43;
  mix-blend-mode: multiply;
}
.screen-glare {
  position: absolute; inset: 0; z-index: 4; pointer-events: none;
  background:
    radial-gradient(120% 80% at 20% -10%, rgba(255, 255, 255, 0.10), transparent 38%),
    radial-gradient(100% 100% at 50% 50%, transparent 55%, rgba(0, 0, 0, 0.32) 100%);
}

.loading {
  position: absolute; inset: 0; z-index: 7;
  display: grid; place-items: center;
  background:
    radial-gradient(circle at 50% 40%, rgba(255, 92, 22, 0.2), transparent 50%),
    #080b13;
  transition: opacity 420ms ease, visibility 420ms ease;
}
.loading.done { opacity: 0; visibility: hidden; }
.loading-inner { width: 60%; text-align: center; }
.load-logo {
  font-family: var(--pixel);
  font-size: clamp(20px, 4.6vw, 36px);
  color: #f24a2e;
  letter-spacing: -2px;
  text-shadow: 0 4px 0 #6e130d;
}
.load-logo span { color: #fff4d1; margin-left: 5px; }
.load-copy { margin: 18px 0 12px; color: #8e96ad; font-family: var(--pixel); font-size: 7px; letter-spacing: 1.3px; }
.load-track { height: 4px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.load-track i { display: block; width: 0%; height: 100%; background: linear-gradient(90deg, #ff5a2d, #ffc23a); transition: width 180ms ease; }
.load-error { color: #ffad8f; font-family: var(--pixel); font-size: 9px; line-height: 1.8; text-align: center; }

.key-strip {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 8px 16px;
  width: 100%;
  margin-top: 14px;
  color: #888fa3;
  font-size: 11px;
}
.key-strip span { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
kbd {
  font-family: var(--pixel); font-size: 7px; color: #d8dceb;
  background: #171b25; border: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom-color: rgba(0, 0, 0, 0.55); border-radius: 4px;
  padding: 4px 5px 3px; line-height: 1;
}

.side-panel {
  border-left: 1px solid var(--line);
  padding: 6px 0 0 26px;
  position: sticky;
  top: 24px;
}
.eyebrow {
  display: block; color: var(--gold); font-family: var(--pixel);
  font-size: 7px; letter-spacing: 1.7px; margin-bottom: 12px;
}
.side-panel h2 {
  margin: 0 0 16px;
  font-family: var(--pixel);
  font-size: clamp(18px, 2.1vw, 24px);
  line-height: 1.42;
  letter-spacing: -0.5px;
  color: #fff8e8;
}
.side-panel h2 em { color: var(--red); font-style: normal; text-shadow: 0 2px 0 #5d100a; }
.lead { margin: 0 0 20px; color: #a7abba; font-size: 13px; line-height: 1.65; }

.power-card {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 10px 12px;
  align-items: center;
  padding: 13px;
  border: 1px solid rgba(255, 185, 49, 0.22);
  background: linear-gradient(135deg, rgba(255, 173, 46, 0.12), rgba(255, 70, 30, 0.035));
  border-radius: 10px;
  position: relative;
  overflow: hidden;
}
.power-icon {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #ffe48d, #ff8a29 45%, #d52a0e 80%);
  color: #451005; font-size: 28px; font-weight: 900; line-height: 1;
  box-shadow: 0 0 24px rgba(255, 131, 36, 0.42), inset 0 0 8px rgba(255, 255, 255, 0.4);
}
.power-label { color: #d2984e; font-family: var(--pixel); font-size: 6px; letter-spacing: 1.4px; }
.power-value { color: #ffd166; font-family: var(--pixel); font-size: 11px; margin-top: 5px; }
.power-meter { grid-column: 2; height: 3px; background: rgba(255, 255, 255, 0.12); margin-top: -1px; }
.power-meter i { display: block; width: 68%; height: 100%; background: linear-gradient(90deg, #ffb02e, #ff4a2b); box-shadow: 0 0 8px #ff7a2e; }

.feature-list { margin-top: 20px; display: grid; gap: 14px; }
.feature { display: grid; grid-template-columns: 24px 1fr; gap: 8px; }
.feature-num {
  color: #5f6577; font-family: var(--pixel); font-size: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.12); padding-top: 4px;
}
.feature strong { display: block; color: #ece9df; font-family: var(--pixel); font-size: 7px; line-height: 1.5; letter-spacing: 0.3px; }
.feature p { margin: 6px 0 0; color: #858b9d; font-size: 12px; line-height: 1.55; }

.score-card {
  margin-top: 22px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  padding: 10px 12px;
}
.score-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.055);
  color: #7d8497; font-family: var(--pixel); font-size: 6px; letter-spacing: 0.7px;
}
.score-row:last-child { border-bottom: 0; }
.score-row b { color: #d9dbe7; font-weight: 400; }
.side-note { margin: 17px 0 0; color: #737a8f; font-size: 11.5px; line-height: 1.65; }
.side-note .q { color: var(--gold); font-family: var(--pixel); font-size: 10px; }

.footer {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px 22px;
  margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--line);
  color: #565d70; font-family: var(--pixel); font-size: 6px; line-height: 1.7; letter-spacing: 0.7px;
}

.touch-controls { display: none; width: 100%; margin-top: 18px; justify-content: space-between; align-items: center; gap: 22px; }
.dpad, .action-pad { display: flex; gap: 12px; }
.touch-btn {
  width: 68px; height: 58px; border-radius: 15px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: linear-gradient(180deg, #242936, #11141c);
  color: #e8e7f3; font-family: var(--pixel); font-size: 14px;
  box-shadow: 0 5px 0 #06070b, inset 0 1px 0 rgba(255, 255, 255, 0.14);
  touch-action: none; user-select: none;
}
.touch-btn.jump { background: linear-gradient(180deg, #f1502e, #9f1c11); border-color: #ff8f6e; }
.touch-btn.run { background: linear-gradient(180deg, #ffc33c, #906009); border-color: #ffe08b; color: #2d1b00; }
.touch-btn.pressed { transform: translateY(4px); box-shadow: 0 1px 0 #06070b, inset 0 1px 0 rgba(255, 255, 255, 0.2); }

@media (max-width: 1040px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side-panel { border-left: 0; border-top: 1px solid var(--line); padding: 24px 0 0; position: static; display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; }
  .side-panel .panel-heading, .side-panel .lead { grid-column: 1 / -1; }
  .side-panel .power-card { align-self: start; }
  .side-panel .feature-list { margin-top: 0; }
  .side-panel .score-card, .side-panel .side-note { grid-column: 1 / -1; }
  .cabinet { width: min(100%, 780px); }
}

@media (max-width: 760px) {
  .page { padding: 18px 12px 16px; }
  .topbar { align-items: flex-start; flex-direction: column; gap: 12px; }
  .brand-kicker { font-size: 6px; }
  .brand-title { font-size: 20px; }
  .brand-sub { font-size: 6px; }
  .top-actions { align-self: stretch; justify-content: space-between; }
  .layout { padding-top: 16px; }
  .cabinet { padding: 8px; border-radius: 12px; }
  .cabinet-top { padding: 0 2px 8px; font-size: 5px; }
  .cabinet-bottom { padding: 8px 2px 0; font-size: 5px; }
  .screen-bezel { padding: 5px; }
  .key-strip { display: none; }
  .touch-controls { display: flex; }
  .side-panel { display: block; }
  .side-panel .feature-list { margin-top: 20px; }
  .side-panel .score-card { margin-top: 20px; }
  .footer { margin-top: 20px; font-size: 5px; }
}

@media (pointer: coarse) {
  .touch-controls { display: flex; }
  .key-strip { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .noise { display: none; }
  .chip-button { transition: none; }
}

@media (max-width: 380px) {
  .brand-title { font-size: 17px; gap: 5px; }
  .brand-sub { display: none; }
  .chip-button { padding: 9px 10px 8px; font-size: 7px; }
  .touch-controls { gap: 12px; }
  .dpad, .action-pad { gap: 8px; }
  .touch-btn { width: 58px; height: 52px; font-size: 12px; }
  .side-panel h2 { font-size: 17px; }
}
