@font-face {
  font-family: 'PressStart2P';
  src: url('assets/fonts/PressStart2P-Regular.ttf') format('truetype');
  font-display: block;
}

:root {
  --bg: #0d0b1e;
  --panel: #1a1736f0;
  --fg: #f4ead2;
  --muted: #b9b0d6;
  --accent: #ffb347;
  --accent-2: #e94f37;
  --line: #4b4580;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  overflow: hidden;
}

body {
  font-family: 'PressStart2P', ui-monospace, monospace;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#stage {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  /* tacca e angoli arrotondati dei telefoni in orizzontale */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#game {
  display: block;
  width: min(100vw, calc(100vh * 16 / 9));
  width: min(100vw, calc(100dvh * 16 / 9));
  aspect-ratio: 16 / 9;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  touch-action: none;
  cursor: crosshair;
}

#overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(8, 6, 20, 0.55);
}
#overlay.hidden { display: none; }

.panel {
  width: min(660px, 100%);
  max-height: 100%;
  overflow-y: auto;
  background: var(--panel);
  border: 4px solid var(--line);
  box-shadow: 0 0 0 4px #000, 8px 8px 0 4px #000;
  padding: clamp(14px, 3vmin, 28px);
  text-align: center;
  font-size: clamp(9px, 1.9vmin, 13px);
  line-height: 1.8;
}

.logo {
  font-size: clamp(22px, 7vmin, 48px);
  line-height: 1.1;
  margin: 0 0 0.4em;
  color: var(--accent);
  text-shadow: 3px 3px 0 var(--accent-2), 6px 6px 0 #000;
  letter-spacing: 2px;
}
.logo span {
  display: block;
  margin-top: 0.3em;
  font-size: 0.6em;
  color: var(--fg);
  text-shadow: 3px 3px 0 #000;
}

h2 { font-size: 1.3em; color: var(--accent); margin: 0.4em 0 0.8em; line-height: 1.4; }
h2.big { font-size: 2em; }
p { margin: 0.6em 0; }

.hint { color: var(--muted); font-size: 0.85em; }
.rotate { display: none; }
@media (orientation: portrait) and (max-width: 820px) {
  .rotate { display: block; color: var(--accent); }
}
@media (hover: none) {
  .keys { display: none; }
}

.btns {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1em;
}

button {
  font: inherit;
  font-size: 1em;
  color: var(--fg);
  background: #2c2858;
  border: 3px solid var(--line);
  padding: 0.8em 1.2em;
  cursor: pointer;
  box-shadow: 4px 4px 0 #000;
  touch-action: manipulation;
}
button:hover, button:focus-visible { border-color: var(--accent); outline: none; }
button:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 #000; }
button.primary { background: var(--accent-2); border-color: #ff8a6a; font-size: 1.25em; }

.kicker {
  display: inline-block;
  padding: 0.3em 0.6em;
  color: var(--bg);
  background: var(--accent);
}
.cleared { color: #7ee081; margin-bottom: 0.8em; }
.card p { text-align: left; }

.memorial { --panel: #141414f2; --line: #5a5a5a; }
.memorial .kicker { background: #d9d2c3; }
.memorial h2 { color: #efe8d8; }

.nick { display: block; margin-top: 0.4em; color: var(--accent); }
#nick {
  font: inherit;
  font-size: 1.4em;
  width: min(100%, 14em);
  margin: 0.5em auto 0;
  padding: 0.5em 0.6em;
  text-align: center;
  text-transform: uppercase;
  color: var(--fg);
  background: #0d0b1e;
  border: 3px solid var(--line);
  box-shadow: inset 3px 3px 0 #000;
  -webkit-user-select: text;
  user-select: text;
}
#nick:focus { border-color: var(--accent); outline: none; }
.err { color: #ff8a6a; min-height: 1.2em; margin: 0.2em 0; }
.ios { color: var(--accent); }

details { margin-top: 1em; text-align: left; }
summary { cursor: pointer; text-align: center; color: var(--accent); }
summary:focus-visible { outline: 2px solid var(--accent); }

table.board { width: 100%; border-collapse: collapse; margin: 0.6em 0; }
table.board th { color: var(--muted); font-weight: normal; padding: 0.4em 0.3em; border-bottom: 2px solid var(--line); }
table.board td { padding: 0.35em 0.3em; }
table.board td:first-child, table.board th:first-child { text-align: right; width: 2.5em; }
table.board td:nth-child(2), table.board th:nth-child(2) { text-align: left; }
table.board tr:nth-child(-n+3) td { color: #ffd24a; }
table.board tr.me td { background: #2c2858; color: #7ee081; }

.score { font-size: 1.2em; }
.rec { color: #ffd24a; }
.blink { animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.credits { color: var(--muted); font-size: 0.75em; margin-top: 1.4em; }

@media (prefers-reduced-motion: reduce) {
  .blink { animation: none; }
}
