/* Macchina Italiana — cabinet styling.
   Palette: bottle green room, cream lettering, terracotta buttons. */

:root {
  --ink: #ffeac0;
  --ink-dim: #cabfa6;
  --ink-bright: #ffe8ac;
  --green-deep: #101b18;
  --green-room: #193c32;
  --line: #829580;
  --line-soft: #607c69;
  --wood: #ba935c;
  --wood-dark: #a99169;
  --terracotta: #c6513d;
  --terracotta-dark: #80382f;
  --amber: #eead74;
  --radius: 4px;
  --shadow: 0 0 0 2px #342820, 0 7px 0 #101814, 0 14px 32px #09110d80;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100svh;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at 50% 25%, #27433a, #101b18 74%);
  color: var(--ink);
  font: 16px/1.4 'Pizzeria Mono', ui-monospace, monospace;
  -webkit-text-size-adjust: 100%;
}

main {
  width: min(95vw, 950px);
  padding: 16px 0 calc(16px + env(safe-area-inset-bottom));
}

/* ---------- header ---------- */

header,
.hud,
.controls,
footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

header { padding: 0 0 12px; }

h1 {
  margin: 0;
  font: normal clamp(20px, 3.8vw, 43px)/1 'Pizzeria Terminal', ui-monospace, monospace;
  letter-spacing: -0.05em;
}

header strong {
  font: normal clamp(13px, 2vw, 24px)/1 'Pizzeria Terminal', ui-monospace, monospace;
  letter-spacing: 0.18em;
  background: #ae4839;
  color: #ffdfb0;
  padding: 6px 13px;
}

/* ---------- scoreboard ---------- */

.hud {
  padding: 11px 0;
  margin: 4px 0 11px;
  border-block: 1px solid var(--line-soft);
  font: normal clamp(12px, 2vw, 16px)/1 'Pizzeria Terminal', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  flex-wrap: wrap;
  row-gap: 6px;
}

.hud span { color: var(--ink-dim); white-space: nowrap; }
.hud b { color: #ffda89; font-weight: normal; }
.hud .lives b { color: #ff9b8a; letter-spacing: 0.14em; }
.hud .best b { color: #cfe9d5; }

/* ---------- cabinet screen ---------- */

.stage {
  position: relative;
  border: 4px solid var(--wood);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  background: #12211c;
}

canvas {
  width: 100%;
  display: block;
  image-rendering: pixelated;
  touch-action: none;
  cursor: pointer;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: #11241b75;
}

.overlay[hidden] { display: none; }

.menu {
  text-align: center;
  background: var(--green-room);
  color: #fbe8bf;
  padding: clamp(10px, 3vw, 34px);
  border: 4px double #dfba80;
  box-shadow: 5px 6px #14251d;
  max-width: 90%;
}

.menu h2 {
  margin: 0;
  font: normal clamp(26px, 5vw, 58px)/1 'Pizzeria Terminal', ui-monospace, monospace;
}

.menu p {
  max-width: 36ch;
  margin: 10px auto 16px;
  line-height: 1.35;
}

.menu .record {
  margin: -6px auto 14px;
  font: 12px/1.4 'Pizzeria Mono', ui-monospace, monospace;
  letter-spacing: 0.06em;
  color: #ffd79a;
  text-transform: uppercase;
}

.menu .record[hidden] { display: none; }

.menu .keys {
  margin: 12px auto 0;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: #cfe0c9;
  opacity: 0.85;
}

.menu .keys:empty { display: none; }

/* ---------- buttons ---------- */

button {
  cursor: pointer;
  background: #f7dfac;
  color: #272521;
  border: 0;
  border-bottom: 4px solid #ad8b60;
  border-radius: 2px;
  padding: 10px 16px;
  font: bold 15px 'Pizzeria Mono', ui-monospace, monospace;
  touch-action: manipulation;
  transition: transform 60ms ease, filter 120ms ease;
}

button:hover { filter: brightness(1.06); }
button:active { transform: translateY(2px); border-bottom-width: 2px; }
button:focus-visible { outline: 3px solid #ff992b; outline-offset: 3px; }
button:disabled { opacity: 0.55; cursor: wait; }

#serve { background: var(--terracotta); color: #fff4df; border-color: var(--terracotta-dark); }
#sound { background: #28483c; border-color: #172e27; color: #f7dfac; }

.controls {
  justify-content: flex-start;
  margin: 14px 0;
  flex-wrap: wrap;
}

.controls #sound { margin-left: auto; }

.opening #go::before { content: '>'; margin-right: 0.6em; }

/* ---------- opening poster ---------- */

.opening .stage { aspect-ratio: 1.72; }

.opening canvas {
  position: absolute;
  inset: 0;
  height: 100%;
  width: 100%;
}

.opening .overlay {
  display: flex;
  align-items: center;
  background: #173b30 url('art/title-poster.webp') center/cover no-repeat;
}

.opening .overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #0a3028d9, #0b292070 43%, transparent 71%);
}

.opening .menu {
  position: relative;
  z-index: 1;
  text-align: left;
  padding: 0 0 0 5.4%;
  border: 0;
  background: none;
  box-shadow: none;
  width: 61%;
}

.opening #title {
  font: normal clamp(30px, 6.8vw, 76px)/0.99 'Pizzeria Terminal', ui-monospace, monospace;
  letter-spacing: -0.025em;
  text-transform: uppercase;
  color: #ffeac6;
  text-shadow: 2px 3px #502c24;
}

.opening #title small {
  display: block;
  font: normal clamp(12px, 2vw, 24px)/1 'Pizzeria Mono', ui-monospace, monospace;
  color: #f9bc81;
  letter-spacing: 0.34em;
  margin: 14px 0 0;
}

.opening #desc {
  font: clamp(12px, 1.6vw, 17px)/1.4 'Pizzeria Mono', ui-monospace, monospace;
  max-width: 30ch;
  margin: 16px 0 18px;
}

.opening #go { padding: 12px 24px; }

.opening .keys {
  font: 12px/1.5 'Pizzeria Mono', ui-monospace, monospace;
  color: #ffeac6;
  opacity: 0.75;
  margin: 14px 0 0;
  letter-spacing: 0.02em;
}

.opening .record,
.opening .keys {
  max-width: none;
  text-align: left;
  margin-left: 0;
}

.opening .record { margin-bottom: 12px; }

.opening #desc,
.opening .record,
.opening .keys { text-shadow: 0 1px 3px #081b14, 0 0 12px #081b14; }
.opening .hud,
.opening header,
.opening .controls button:not(#sound) { display: none; }
.opening #pause { display: none; }
.opening .controls { float: none; display: flex; justify-content: flex-end; margin: 12px 0 4px; }
.opening #sound { margin: 0; }
.opening footer { min-height: 54px; justify-content: flex-start; gap: 16px; }

/* ---------- footer ---------- */

footer {
  font-size: 13px;
  color: #bfbdab;
  flex-wrap: wrap;
}

a { color: #f0cf98; }

.live {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---------- responsive ---------- */

@media (max-width: 600px) {
  main { width: 96vw; }
  .controls { gap: 6px; }
  .controls button { padding: 9px 11px; font-size: 13px; }
  .controls #sound { margin-left: 0; }
  .stage { border-width: 2px; }
  .menu p { font-size: 13px; }
  footer { font-size: 12px; }
}

@media (max-width: 540px) {
  .opening .stage { aspect-ratio: 1.18; }
  .opening .menu { width: 76%; padding-left: 4%; }
  .opening #title { font-size: 26px; }
  .opening #desc { font-size: 11px; line-height: 1.35; max-width: 23ch; margin: 6px 0 8px; }
  .opening .record { font-size: 10px; margin-bottom: 8px; }
  .opening .keys { display: none; }
  .opening #go { padding: 8px 12px; font-size: 13px; }
  .opening #title small { margin-top: 6px; font-size: 11px; letter-spacing: 0.28em; }
  .opening .overlay { background-position: 62% center; }
  .opening footer { gap: 5px; flex-direction: column; align-items: flex-start; }
  footer .legend { display: none; }
  .hud { font-size: 11px; gap: 8px; }
}

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