:root {
  color-scheme: dark;
  --ink: #090711;
  --plum: #1a1026;
  --brass: #d8a657;
  --flame: #ffd37a;
  --ember: #ef6a4a;
  --moss: #78c091;
  --ice: #83c5d6;
  --bone: #e9dfc7;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% -20%, #29163d 0, transparent 45%),
    repeating-linear-gradient(90deg, rgba(255,255,255,.018) 0 1px, transparent 1px 5px),
    #07050c;
  color: var(--bone);
  font-family: "Courier New", ui-monospace, monospace;
  display: grid;
  place-items: center;
  padding: 24px 12px 32px;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(0,0,0,.65) 100%);
  z-index: 20;
}

.cabinet {
  width: min(960px, 100%);
  border: 4px solid #3b2948;
  border-bottom-width: 10px;
  border-radius: 10px 10px 22px 22px;
  padding: 12px clamp(8px, 2vw, 20px) 18px;
  background: linear-gradient(#21132e, #100a18 72%, #09070e);
  box-shadow:
    0 0 0 3px #08050d,
    0 22px 70px #000,
    inset 0 2px 0 rgba(255,255,255,.08);
  position: relative;
}

.marquee {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(12px, 4vw, 48px);
  text-align: center;
  border: 3px solid #6a4059;
  background:
    linear-gradient(rgba(255,255,255,.03), transparent),
    repeating-linear-gradient(135deg, #2d1734 0 8px, #24132e 8px 16px);
  box-shadow: inset 0 0 28px #09040d, 0 0 18px rgba(239,106,74,.18);
  margin-bottom: 12px;
}

.marquee h1 {
  margin: 0;
  color: var(--flame);
  font-size: clamp(28px, 7vw, 58px);
  line-height: .9;
  letter-spacing: .08em;
  text-shadow: 3px 3px 0 #8b3440, 0 0 15px rgba(255,211,122,.6);
}

.marquee p {
  margin: 8px 0 0;
  color: var(--brass);
  font-weight: bold;
  font-size: clamp(9px, 1.8vw, 14px);
  letter-spacing: .2em;
}

.rune {
  color: var(--ember);
  font-size: clamp(20px, 4vw, 40px);
  text-shadow: 0 0 12px var(--ember);
  animation: pulse 1.3s steps(2, end) infinite;
}

@keyframes pulse { 50% { opacity: .45; transform: scale(.9); } }

.screen-shell {
  padding: clamp(8px, 2vw, 18px);
  border: 4px solid #050407;
  border-radius: 18px;
  background: #18121d;
  box-shadow: inset 0 0 0 3px #35293a, inset 0 0 30px #000;
}

.screen-glow {
  position: relative;
  overflow: hidden;
  border-radius: 7px;
  border: 3px solid #08070a;
  background: #05050a;
  box-shadow: 0 0 24px rgba(239,106,74,.25), inset 0 0 20px #000;
  aspect-ratio: 16 / 9;
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  outline: none;
  touch-action: none;
}

.glass {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,.18) 0 1px, transparent 1px 3px),
    linear-gradient(105deg, rgba(255,255,255,.045), transparent 25% 75%, rgba(255,255,255,.025));
  mix-blend-mode: screen;
}

.control-panel {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: clamp(6px, 2vw, 20px);
  padding-top: 14px;
  color: #9d8ba5;
  font-size: 10px;
  letter-spacing: .1em;
}

.control-panel > div { display: grid; gap: 4px; text-align: center; }

kbd, #mute {
  min-width: 62px;
  padding: 5px 8px;
  border: 2px solid #4a394e;
  border-bottom-width: 4px;
  border-radius: 4px;
  background: #18111c;
  color: var(--bone);
  font: bold 11px/1 "Courier New", monospace;
}

#mute { cursor: pointer; color: var(--brass); }
#mute:active { border-bottom-width: 2px; transform: translateY(2px); }

.field-note {
  width: min(760px, 92vw);
  display: grid;
  gap: 5px;
  margin-top: 18px;
  text-align: center;
  color: #8e7d93;
  font-size: 11px;
  line-height: 1.45;
}

.field-note b { color: var(--brass); letter-spacing: .18em; }

.touch-controls {
  display: none;
  justify-content: space-between;
  align-items: center;
  padding: 16px 8px 0;
  user-select: none;
  touch-action: none;
}

.touch-controls button {
  border: 2px solid #4a394e;
  border-bottom-width: 5px;
  background: #18111c;
  color: var(--bone);
  font: bold 16px/1 "Courier New", monospace;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.touch-controls button.pressed {
  transform: translateY(3px);
  border-bottom-width: 2px;
  background: #2b1d31;
}

.dpad {
  width: 126px;
  height: 126px;
  display: grid;
  grid-template: repeat(3, 42px) / repeat(3, 42px);
}

.dpad button { width: 42px; height: 42px; }
.dpad [data-key="up"] { grid-area: 1 / 2; }
.dpad [data-key="left"] { grid-area: 2 / 1; }
.dpad [data-key="down"] { grid-area: 3 / 2; }
.dpad [data-key="right"] { grid-area: 2 / 3; }

.actions { display: flex; align-items: flex-end; gap: 12px; }
.actions button { border-radius: 50%; width: 62px; height: 62px; }
.actions .swing { width: 76px; height: 76px; color: var(--flame); border-color: #7c4b43; }
.actions small { display: block; font-size: 7px; margin-top: 3px; }

@media (hover: none), (pointer: coarse) {
  body { padding-top: 8px; }
  .touch-controls { display: flex; }
  .control-panel > div { display: none; }
  .cabinet { width: min(720px, 100%); }
}

@media (max-width: 560px) {
  body { padding: 8px 6px 20px; }
  .marquee { min-height: 62px; }
  .screen-shell { padding: 6px; border-radius: 10px; }
  .touch-controls { display: flex; gap: 8px; padding: 12px 0 0; }
  .control-panel { padding-top: 8px; }
  .control-panel > div { display: none; }
  .dpad {
    width: 105px;
    height: 105px;
    grid-template: repeat(3, 35px) / repeat(3, 35px);
  }
  .dpad button { width: 35px; height: 35px; }
  .actions { gap: 7px; }
  .actions button { width: 52px; height: 52px; }
  .actions .swing { width: 64px; height: 64px; }
  .field-note { display: none; }
}
