/* ColdSnap Arcade. Tokens and components follow coldsnap.fr (coldsnap/css/coldsnap.css in yukisando.github.io). */

@font-face {
  font-family: 'Comfortaa';
  src: url('/brand/Comfortaa-var.woff2') format('woff2');
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --orange: #F5841A;
  --orange-dark: #d9700e;
  --coral: #E8607A;
  --blue: #6BBFD0;
  --bg-dark: #12141b;
  --bg-darker: #0c0e13;
  --bg-card: #1b1e29;
  --bg-card-hover: #232738;
  --bg-raised: #171a23;
  --text-primary: #f4f1ea;
  --text-secondary: rgba(244, 241, 234, 0.7);
  --text-muted: rgba(244, 241, 234, 0.45);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --radius: 20px;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --gutter: 32px;
  --font: 'Comfortaa', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-dark);
  color: var(--text-primary);
  font-family: var(--font);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }
a { color: inherit; }
main { flex: 1; width: 100%; }
button, input { font: inherit; color: inherit; }
h1, h2 { font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; border-radius: 6px; }
::selection { background: var(--orange); color: #fff; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 var(--gutter) 48px; }

/* Navigation */
.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(12, 14, 19, 0.82);
  backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--border-color);
}
.nav__inner {
  max-width: 1200px;
  height: 72px;
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: flex;
  align-items: center;
  gap: 16px;
}
.nav__brand { display: inline-flex; align-items: center; gap: 12px; margin-right: auto; text-decoration: none; }
.nav__brand img { transition: transform 0.4s var(--ease-out); }
.nav__brand:hover img { transform: rotate(-8deg) scale(1.06); }
.nav__name { font-weight: 700; font-size: 1.3rem; letter-spacing: -0.02em; }
.nav__tag, .hero__tag, .eyebrow {
  color: var(--orange);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}
.lang-switch { display: inline-flex; padding: 3px; border: 1px solid var(--border-strong); border-radius: 999px; }
.lang-switch button {
  border: 0;
  background: transparent;
  padding: 4px 10px;
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
}
.lang-switch button[aria-pressed="true"] { background: var(--text-primary); color: var(--bg-darker); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 22px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s var(--ease-out), background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.btn--primary { background: var(--orange); color: #fff; }
.btn--primary:hover { background: var(--orange-dark); transform: translateY(-2px); }
.btn--ghost { background: transparent; border-color: var(--border-strong); color: var(--text-primary); }
.btn--ghost:hover { border-color: var(--orange); color: var(--orange); }
.btn:disabled { opacity: 0.6; cursor: default; transform: none; }

/* Home */
.hero {
  display: grid;
  justify-items: center;
  gap: 16px;
  padding: 56px 0 48px;
  text-align: center;
}
.hero h1 { font-size: clamp(2.4rem, 7vw, 3.4rem); }
.hero__tag { margin-top: 8px; font-size: 0.82rem; letter-spacing: 0.3em; }
.hero__lead { max-width: 56ch; color: var(--text-secondary); font-size: 1.05rem; }

.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: 24px; }
.game-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-raised);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  transition: transform 0.25s var(--ease-out), border-color 0.25s ease, background 0.25s ease;
}
.game-card:hover { transform: translateY(-4px); border-color: var(--orange); background: var(--bg-card); }
.game-card__cover { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: #000; image-rendering: pixelated; }
.game-card__body { display: flex; flex: 1; flex-direction: column; gap: 8px; padding: 20px 24px 24px; }
.game-card h2 { font-size: 1.3rem; }
.game-card__blurb { flex: 1; color: var(--text-secondary); font-size: 0.92rem; }
.game-card__foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.game-card__record { color: var(--blue); font-size: 0.82rem; overflow-wrap: anywhere; }

/* Game page */
.back {
  display: inline-block;
  margin: 24px 0 16px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  text-decoration: none;
}
.back:hover { color: var(--orange); }
#play h1 { margin: 8px 0; font-size: clamp(1.7rem, 5vw, 2.4rem); }

/* The game and its leaderboard share one panel, so the screen reads as part of the page. */
.play {
  --screen-width: max(420px, calc((100svh - 300px) * var(--ratio, 1.3333)));
  display: grid;
  grid-template-columns: minmax(0, var(--screen-width)) minmax(280px, 1fr);
  margin-top: 20px;
  overflow: hidden;
  background: var(--bg-raised);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
}
.play--no-board { grid-template-columns: minmax(0, var(--screen-width)); justify-content: center; }
#screen { aspect-ratio: var(--ratio, 1.3333); background: var(--bg-darker); }
#game { width: 100%; height: 100%; }
.controls { padding: 12px 20px; border-top: 1px solid var(--border-color); color: var(--text-muted); font-size: 0.8rem; }

/* The emulator's start button, in ColdSnap style */
#screen .ejs_start_button {
  height: auto;
  padding: 10px 26px;
  border: 0;
  border-radius: 999px;
  background: var(--orange);
  box-shadow: var(--shadow);
  color: #fff;
  font: 600 0.95rem/1.6 var(--font);
  text-shadow: none;
  text-transform: none;
  animation: none;
}
#screen .ejs_start_button:hover { background: var(--orange-dark); }

/* The emulator's volume control: a thin cream line instead of a white bar with an orange knob */
#screen .ejs_volume_parent input[type='range'] {
  height: 4px;
  background: rgba(244, 241, 234, 0.2);
  color: var(--text-primary);
}
#screen .ejs_volume_parent input[type='range']::-webkit-slider-runnable-track { height: 4px; }
#screen .ejs_volume_parent input[type='range']::-webkit-slider-thumb {
  width: 12px;
  height: 12px;
  margin-top: -4px;
  background: var(--text-primary);
  box-shadow: none;
}
#screen .ejs_volume_parent input[type='range']::-moz-range-track { height: 4px; background: transparent; }
#screen .ejs_volume_parent input[type='range']::-moz-range-progress { height: 4px; background: var(--text-primary); }
#screen .ejs_volume_parent input[type='range']::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: var(--text-primary);
  box-shadow: none;
}

#board { padding: 24px; border-left: 1px solid var(--border-color); }
#board h2 { margin-bottom: 16px; font-size: 1.2rem; }
#board-status { color: var(--text-secondary); font-size: 0.92rem; }

table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
th { color: var(--text-muted); font-weight: 500; }
th, td { padding: 6px 8px 6px 0; border-bottom: 1px solid var(--border-color); text-align: right; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
th:last-child, td:last-child { padding-right: 0; }
th:nth-child(2), td:nth-child(2) { width: 100%; text-align: left; white-space: normal; overflow-wrap: anywhere; }
td:first-child { color: var(--text-muted); }
tr.me td { color: var(--orange); font-weight: 700; }

.footer { padding: 24px var(--gutter); border-top: 1px solid var(--border-color); color: var(--text-muted); font-size: 0.85rem; text-align: center; }

/* Score entry */
dialog {
  width: min(400px, calc(100vw - 32px));
  margin: auto;
  padding: 28px;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(12, 14, 19, 0.7); backdrop-filter: blur(4px); }
dialog h2 { margin-bottom: 10px; color: var(--orange); font-size: 1.3rem; }
#submit-score { margin-bottom: 18px; color: var(--text-secondary); font-size: 0.92rem; }
label { display: block; margin-bottom: 6px; font-size: 0.9rem; font-weight: 600; }
dialog input {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  background: var(--bg-darker);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
}
dialog input:focus { border-color: var(--orange); outline: none; }
#pad-hint { margin-top: 10px; color: var(--text-muted); font-size: 0.8rem; }
#submit-error { min-height: 1.6em; margin: 8px 0; color: var(--coral); font-size: 0.85rem; }
.actions { display: flex; justify-content: flex-end; gap: 10px; }

@media (max-width: 900px) {
  :root { --gutter: 16px; }
  .play { grid-template-columns: minmax(0, 1fr); }
  #screen { max-height: 100svh; }
  #board { border-left: 0; border-top: 1px solid var(--border-color); }
}

/* Phone held upright: keep the touch pad below the picture, not on top of it. */
@media (hover: none) and (orientation: portrait) {
  #screen {
    aspect-ratio: auto;
    height: calc((100vw - 2 * var(--gutter) - 2px) / var(--ratio, 1.3333) + var(--pad-height, 340px));
    max-height: none;
  }
  #game .ejs_canvas_parent { height: calc(100% - var(--pad-height, 340px)); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
