:root {
  color-scheme: dark;
  font-family: 'Segoe UI', system-ui, -apple-system, Arial, Helvetica, sans-serif;
  background: #050910;
  color: #edf3f0;
  --lime: #b7f571;
  --cyan: #4de8ff;
  --magenta: #ff5ca8;
  --amber: #ffcf5c;
  --panel: #0d1722;
  --border: #2a3e4d;
  --muted: #8499a8;
}

* { box-sizing: border-box; }

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

body {
  background:
    radial-gradient(ellipse at 50% 15%, rgba(44, 108, 130, 0.30), transparent 60%),
    radial-gradient(ellipse at 18% 85%, rgba(183, 245, 113, 0.08), transparent 45%),
    radial-gradient(ellipse at 82% 80%, rgba(255, 92, 168, 0.10), transparent 45%),
    #050910;
}

main {
  height: 100vh;
  height: 100dvh;
  max-width: 1280px;
  margin: auto;
  padding: 16px 24px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  gap: 12px;
}

header, footer {
  display: flex;
  justify-content: space-between;
  font: 10px monospace;
  letter-spacing: 2px;
  color: var(--muted);
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--lime); }

.heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0;
}

.eyebrow, .label {
  font: 10px monospace;
  letter-spacing: 2px;
  color: var(--muted);
}

.heading .eyebrow { margin: 0 0 8px; }

h1 {
  font-size: 38px;
  letter-spacing: -2.5px;
  line-height: 0.9;
  margin: 0;
  text-shadow: 0 0 24px rgba(183, 245, 113, 0.2);
}

h1 span {
  font-size: 12px;
  letter-spacing: 5px;
  display: block;
  margin-top: 8px;
  color: var(--cyan);
}

.heading-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.arcade-exit {
  font: 600 11px monospace;
  color: #ff9ec9;
  background: rgba(45, 18, 36, 0.6);
  border: 1px solid rgba(255, 92, 168, 0.4);
  padding: 8px 11px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  transition: border-color 0.14s, color 0.14s, background 0.14s, box-shadow 0.14s;
}

.arcade-exit:hover {
  border-color: var(--magenta);
  background: rgba(74, 24, 56, 0.85);
  color: #ffffff;
  box-shadow: 0 0 14px rgba(255, 92, 168, 0.25);
}

button {
  font: 600 12px monospace;
  color: #dce5e9;
  background: rgba(18, 32, 44, 0.78);
  border: 1px solid #354b5a;
  padding: 10px 13px;
  cursor: pointer;
  border-radius: 7px;
  touch-action: none;
  transition: border-color 0.14s, color 0.14s, background 0.14s, transform 0.08s, box-shadow 0.14s;
}

button:hover {
  border-color: var(--lime);
  color: var(--lime);
  box-shadow: 0 0 14px rgba(183, 245, 113, 0.16);
}

button:active { transform: translateY(1px); }
button:focus-visible { outline: 2px solid var(--lime); outline-offset: 3px; }

.machine {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  min-height: 0;
}

.machine > aside {
  flex: 0 0 202px;
  min-width: 0;
}

.hud-left strong {
  display: block;
  font: 700 32px monospace;
  color: var(--lime);
  letter-spacing: -1.5px;
  text-shadow: 0 0 18px rgba(183, 245, 113, 0.35);
}

aside b {
  font: 700 18px monospace;
  color: #edf5f2;
}

.hud-row {
  display: flex;
  gap: 14px;
  align-items: flex-end;
}

#mult { color: var(--amber); }
#ramps { color: var(--cyan); }

.label { margin: 14px 0 5px; }

.rule {
  height: 1px;
  background: linear-gradient(90deg, rgba(77, 232, 255, 0.35), rgba(44, 57, 66, 0.3));
  margin: 16px 0;
}

#status {
  font: 600 12px monospace;
  color: var(--cyan);
  min-height: 36px;
  margin: 6px 0 12px;
  line-height: 1.4;
  text-shadow: 0 0 10px rgba(77, 232, 255, 0.25);
}

#start, #play {
  background: linear-gradient(135deg, #c6ff7e, #8ee550);
  color: #0d1c10;
  border: 0;
  font-weight: 700;
  box-shadow: 0 4px 18px rgba(183, 245, 113, 0.28);
}

#start:hover, #play:hover {
  color: #08130a;
  box-shadow: 0 4px 24px rgba(183, 245, 113, 0.45);
}

.hud-left button {
  width: 100%;
  margin-top: 8px;
}

#table {
  position: relative;
  flex: 1 1 auto;
  height: 100%;
  max-width: 680px;
  min-width: 280px;
  min-height: 0;
  aspect-ratio: 560 / 760;
  background: radial-gradient(circle at 50% 32%, #0d1d2d, #050a12 80%);
  border: 2px solid #35586b;
  border-radius: 26px;
  overflow: hidden;
  box-shadow:
    0 0 0 6px #101d28,
    0 0 0 8px rgba(77, 232, 255, 0.16),
    0 24px 70px rgba(0, 0, 0, 0.78),
    inset 0 0 36px rgba(0, 0, 0, 0.55);
}

#table.overdrive {
  border-color: var(--magenta);
  box-shadow:
    0 0 0 6px #1c1022,
    0 0 28px rgba(255, 92, 168, 0.45),
    0 24px 70px rgba(0, 0, 0, 0.78);
}

#table canvas.gl-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

#table canvas.hud-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

#overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 42%, rgba(12, 28, 42, 0.90), rgba(5, 11, 18, 0.94));
  backdrop-filter: blur(4px);
}

#overlay p {
  font: 700 11px monospace;
  letter-spacing: 3px;
  color: var(--cyan);
  margin: 0;
}

#overlay h2 {
  font-size: 42px;
  line-height: 1.02;
  letter-spacing: -2px;
  margin: 14px 0 12px;
  color: #f3faf5;
  text-shadow: 0 0 26px rgba(183, 245, 113, 0.28);
}

#overlay span {
  font-size: 13px;
  line-height: 1.5;
  color: #a9becb;
  max-width: 320px;
  margin: 2px 12px 22px;
}

#overlay #play {
  padding: 13px 26px;
  font-size: 13px;
  letter-spacing: 0.5px;
}

.instructions .orbit-mark {
  font-size: 36px;
  color: var(--lime);
  line-height: 1;
  text-shadow: 0 0 16px rgba(183, 245, 113, 0.4);
}

.instructions .label { margin-top: 8px; }
.instructions h2 { font-size: 24px; letter-spacing: -1px; margin: 6px 0 10px; line-height: 1.05; }
.instructions p { font-size: 11.5px; line-height: 1.62; color: #a7bcc9; margin: 4px 0; }
.instructions strong { display: inline; font-family: inherit; font-size: 11.5px; font-weight: 700; color: #e9f2f0; letter-spacing: 0; text-shadow: none; }
.instructions em { color: var(--lime); font-style: normal; font-weight: 600; }
.instructions .rule { margin: 12px 0; }
.instructions #restart { width: 100%; margin-top: 10px; }

kbd {
  font: 700 10px monospace;
  border: 1px solid #445c6c;
  background: rgba(16, 30, 42, 0.85);
  color: #e4f0f5;
  padding: 2px 5px;
  border-radius: 4px;
}

.touch {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 0;
}

.touch button {
  min-width: 108px;
  padding: 10px 16px;
  background: linear-gradient(180deg, #1a2e3d, #11202c);
  user-select: none;
  -webkit-user-select: none;
}

.touch button.active {
  background: var(--lime);
  color: #0e1c10;
  border-color: var(--lime);
  box-shadow: 0 0 18px rgba(183, 245, 113, 0.45);
}

footer { margin: 0; font-size: 9px; }

@media (max-width: 960px) {
  main { padding: 14px 18px; gap: 10px; }
  .machine { gap: 18px; }
  .machine > aside { flex-basis: 162px; }
  .instructions { display: none; }
}

@media (max-width: 580px) {
  main {
    padding: 10px 12px;
    gap: 8px;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
  }
  header { font-size: 8px; }
  header > span { display: none; }
  .heading .eyebrow { font-size: 7px; margin-bottom: 4px; }
  h1 { font-size: 24px; }
  h1 span { font-size: 9px; margin-top: 4px; }
  .heading button, .arcade-exit { padding: 7px 9px; font-size: 10px; }
  .machine { flex-direction: column; gap: 8px; }
  .machine > aside.hud-left {
    flex: 0 0 auto;
    width: 100%;
    display: grid;
    grid-template-columns: 1.1fr 1.1fr 1fr;
    gap: 4px 10px;
    align-items: center;
  }
  .hud-left .label { margin: 0; font-size: 8px; letter-spacing: 1px; }
  .hud-left strong { font-size: 19px; }
  .hud-left b { font-size: 14px; }
  .hud-left .hud-row { grid-column: 3; grid-row: 1 / 3; gap: 8px; }
  .hud-left .rule, .hud-left .status-label, #status, #start, #pause { display: none; }
  #table {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: auto;
    flex: 1 1 auto;
    border-radius: 18px;
  }
  .touch { gap: 6px; }
  .touch button { min-width: 0; flex: 1; padding: 12px 6px; min-height: 44px; font-size: 11px; }
  footer { display: none; }
  #overlay h2 { font-size: clamp(24px, 6vh, 38px); margin: 10px 0; }
  #overlay span { font-size: 11px; margin-bottom: 16px; }
}

@media (min-width: 581px) {
  main {
    position: relative;
    padding: 8px 24px;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 10px;
  }
  main > header, main > footer { display: none; }
  .heading {
    position: absolute;
    top: 14px;
    left: 24px;
    z-index: 4;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    width: 185px;
  }
  .heading .eyebrow { display: none; }
  .heading h1 { font-size: 26px; }
  .heading h1 span { font-size: 10px; margin-top: 5px; letter-spacing: 4px; }
  .heading button, .arcade-exit { padding: 7px 10px; font-size: 10.5px; }
  .machine { grid-row: 1; align-items: center; }
  .machine > aside.hud-left { padding-top: 108px; }
  .touch { grid-row: 2; }
}

@media (min-width: 581px) and (max-height: 740px) {
  main { gap: 8px; padding: 8px 20px; }
  .instructions .orbit-mark, .instructions h2, .instructions > .label { display: none; }
  .machine > aside .label { margin: 10px 0 4px; }
  .machine > aside .rule { margin: 10px 0; }
  .machine > aside.hud-left strong { font-size: 26px; }
  #status { margin: 4px 0 8px; min-height: 24px; }
  .hud-left button { padding: 8px 10px; }
}

@media (min-width: 581px) and (max-height: 600px) {
  .heading { top: 10px; left: auto; right: 20px; width: auto; }
  .heading > div { display: none; }
  .machine > aside.hud-left { padding-top: 0; }
}
