/* The play site: the Cardputer's own 5x7 font and colours, at whole pixels.
   Sizes are multiples of 8px (one dot = 2px at 16px) so the font stays crisp. */
@font-face {
  font-family: 'Cardputer';
  src: url('/fonts/cardputer-5x7.woff') format('woff');
  font-display: block;
}
:root {
  --bg: #0d0b1e;
  --bg2: #17133a;
  --bg3: #221c52;
  --ink: #f4f1ff;
  --dim: #9a93cf;
  --faint: #5a5396;
  --line: #352d78;
  --shadow: #05040c;
  --lime: #b6ff3c;
  --pink: #ff5fa2;
  --cyan: #3cf0ff;
  --yellow: #ffd23c;
  --violet: #a675ff;
  --orange: #ff9a3c;
  --red: #ff4d5e;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font: 16px/24px 'Cardputer', ui-monospace, monospace;
  -webkit-font-smoothing: none;
  background-color: var(--bg);
  background-image: radial-gradient(var(--bg3) 2px, transparent 2px);
  background-size: 32px 32px;
  -webkit-tap-highlight-color: transparent;
}
img, canvas { image-rendering: pixelated; image-rendering: crisp-edges; }
html, body { touch-action: manipulation; } /* no double-tap zoom; the catalogue keeps pinch zoom, the play page's zoom.js stops the rest */
a { color: var(--cyan); text-decoration: none; }
a:hover { color: var(--lime); }
h1, h2, h3, p { margin: 0; font-weight: normal; }
.dim { color: var(--dim); }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* a pixel box: an outline that leaves the corner dots out, a hard shadow */
.box {
  background: var(--bg2);
  box-shadow: 0 -4px 0 0 var(--line), 0 4px 0 0 var(--line), -4px 0 0 0 var(--line), 4px 0 0 0 var(--line),
              8px 12px 0 0 var(--shadow);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; color: var(--bg); background: var(--lime); border: 0; cursor: pointer;
  padding: 8px 16px; margin: 4px;
  box-shadow: inset -4px -4px 0 0 #0005, inset 4px 4px 0 0 #fff6,
              0 -4px 0 0 var(--shadow), 0 4px 0 0 var(--shadow), -4px 0 0 0 var(--shadow), 4px 0 0 0 var(--shadow);
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.btn:hover { filter: brightness(1.1); color: var(--bg); }
.btn:active, .btn.down { transform: translateY(4px); box-shadow: inset 4px 4px 0 0 #0005,
  0 -4px 0 0 var(--shadow), 0 4px 0 0 var(--shadow), -4px 0 0 0 var(--shadow), 4px 0 0 0 var(--shadow); }
.btn.alt { background: var(--bg3); color: var(--ink); }
.btn.pink { background: var(--pink); }
.btn.cyan { background: var(--cyan); }
.btn.yellow { background: var(--yellow); }
.btn.on { background: var(--yellow); color: var(--bg); }
.btn:disabled { filter: grayscale(.8) brightness(.7); cursor: progress; }
.tag {
  display: inline-block; padding: 0 8px; margin: 4px 8px 0 0; color: var(--bg); background: var(--dim);
  box-shadow: 0 -2px 0 0 var(--shadow), 0 2px 0 0 var(--shadow), -2px 0 0 0 var(--shadow), 2px 0 0 0 var(--shadow);
}
.tag.two { background: var(--pink); }
.tag.online { background: var(--cyan); }
.tag.best { background: var(--yellow); }

/* ---- the front page ---- */
.hero { text-align: center; padding: 48px 16px 24px; }
.hero h1 {
  font-size: 64px; line-height: 64px; letter-spacing: 0; color: var(--lime);
  text-shadow: 8px 8px 0 var(--pink), 16px 16px 0 var(--shadow);
}
.hero h1 span { color: var(--cyan); text-shadow: 8px 8px 0 var(--violet), 16px 16px 0 var(--shadow); }
.hero p { margin-top: 32px; color: var(--ink); }
.hero p b { color: var(--yellow); font-weight: normal; }
@media (max-width: 720px) { .hero h1 { font-size: 40px; line-height: 48px; text-shadow: 4px 4px 0 var(--pink), 8px 8px 0 var(--shadow); }
  .hero h1 span { text-shadow: 4px 4px 0 var(--violet), 8px 8px 0 var(--shadow); } }
.links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 24px; }
.shelves { display: flex; flex-wrap: wrap; gap: 4px; margin: 24px 0 16px; }
.shelves .btn { margin: 4px 8px 4px 4px; box-sizing: border-box; width: calc(var(--chars, 6) * 1ch + 32px); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(264px, 1fr)); gap: 32px 28px; padding: 8px 4px 32px; }
.game { display: block; color: var(--ink); padding: 8px; transition: transform .08s steps(2); }
.game:hover, .game:focus-visible { transform: translate(-4px, -4px); color: var(--ink); outline: none;
  box-shadow: 0 -4px 0 0 var(--lime), 0 4px 0 0 var(--lime), -4px 0 0 0 var(--lime), 4px 0 0 0 var(--lime), 12px 16px 0 0 var(--shadow); }
.game img.shot { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; background: #000; }
.game .title { display: flex; gap: 12px; align-items: center; margin-top: 12px; }
.game .title img { width: 48px; height: 48px; flex: none; }
.game h3 { font-size: 16px; color: var(--yellow); }
.game p { color: var(--dim); margin-top: 8px; min-height: 48px; }
.game .heart { color: var(--pink); }
.more { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 28px; margin: 24px 4px 48px; }
.more a, .more .note { display: block; padding: 16px; color: var(--ink); }
.more a:hover { color: var(--ink); transform: translate(-4px, -4px); }
.more h2 { color: var(--pink); }
.more p { color: var(--dim); margin-top: 8px; }
footer { text-align: center; color: var(--faint); padding: 32px 16px 48px; }

/* ---- a game's page ---- */
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding-top: 16px; padding-bottom: 8px; }
.top .name { display: flex; align-items: center; gap: 12px; margin-right: auto; }
.top .name img { width: 48px; height: 48px; }
.top h1 { font-size: 32px; line-height: 32px; color: var(--yellow); text-shadow: 4px 4px 0 var(--shadow); }
/* every button in the bar one height; the three levels one width (the widest, NORMAL) */
.top .btn { gap: 0; height: 40px; padding-top: 0; padding-bottom: 0; } /* gap 0: labels in parts read as one word */
.levels { display: inline-grid; grid-template-columns: repeat(3, 1fr); }
.levels .btn { padding-left: 12px; padding-right: 12px; }
/* The buttons keep the first row; a title too long for it goes on the next (play.js: arrangeTop). */
.top.stacked .name { order: 1; flex-basis: 100%; margin-right: 0; }
.top.stacked .levels { margin-left: auto; }
@media (max-width: 680px) { /* a phone held upright, a narrow window: shorter labels, tighter buttons */
  .wide-only { display: none; }
  .top { gap: 8px 4px; }
  .top .btn, .levels .btn { padding-left: 8px; padding-right: 8px; margin: 4px 2px; }
  .top h1 { font-size: 24px; line-height: 24px; text-shadow: 3px 3px 0 var(--shadow); }
}
@media (max-width: 380px) { /* the smallest phones: the buttons still on one row */
  .top { gap: 8px 2px; }
  .top .btn, .levels .btn { padding-left: 5px; padding-right: 5px; margin: 4px 1px; }
}
@media (max-width: 340px) { .tiny-hide { display: none; } }
/* the game as big as the window allows, how to play it underneath */
.stage { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; justify-items: center; padding: 8px 4px 32px; }
.stage > div { width: 100%; display: flex; flex-direction: column; align-items: center; }
.howto { width: 100%; max-width: 1000px; columns: 2 420px; column-gap: 32px; }
.howto > * { break-inside: avoid; }
.screen { position: relative; padding: 12px; background: #000; justify-self: center; }
.screen canvas { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; background: #000; }
.screen .start {
  position: absolute; inset: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; background: #0d0b1ee8; text-align: center; padding: 16px;
}
.screen .start p { color: var(--dim); max-width: 32ch; }
.btn.big { font-size: 32px; line-height: 32px; padding: 16px 32px; }
.screen .menu { overflow: auto; }
.screen .menu h2 { color: var(--yellow); font-size: 32px; line-height: 32px; text-shadow: 4px 4px 0 var(--shadow); }
.screen .menu .choices { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.menu-howto { max-width: 560px; text-align: left; }
.touch .keys-only { display: none; }
.menu-howto table { border-collapse: collapse; margin-top: 8px; }
.menu-howto td { padding: 2px 12px 2px 0; vertical-align: top; }
.menu-howto td:first-child { color: var(--lime); white-space: nowrap; }
.howto { padding: 16px; }
.howto h2 { color: var(--pink); margin-bottom: 8px; }
.howto p { color: var(--ink); margin-bottom: 16px; }
.howto table { border-collapse: collapse; width: 100%; margin-bottom: 16px; }
.howto td { padding: 4px 8px 4px 0; vertical-align: top; }
.howto td:first-child { color: var(--lime); white-space: nowrap; }
.howto .status { color: var(--cyan); }

/* the touch controls */
.pad { display: none; user-select: none; -webkit-user-select: none; touch-action: none; padding: 8px 0 16px; }
.touch .pad { display: block; }
.pad .row { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin-bottom: 16px; }
.pad .row .btn { padding: 4px 10px; }
.pad .main { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 0 8px; }
.dpad { position: relative; width: 168px; height: 168px; flex: none; touch-action: none; }
.dpad span { position: absolute; width: 56px; height: 56px; background: var(--bg3);
  box-shadow: inset -4px -4px 0 0 #0006, inset 4px 4px 0 0 #fff2, 0 0 0 4px var(--shadow); }
.dpad span.down { background: var(--lime); }
.dpad .u { left: 56px; top: 0; } .dpad .d { left: 56px; bottom: 0; } .dpad .l { left: 0; top: 56px; } .dpad .r { right: 0; top: 56px; }
.dpad .c { left: 56px; top: 56px; box-shadow: 0 0 0 4px var(--shadow); }
.actions { display: grid; grid-template-columns: repeat(2, 72px); gap: 16px 12px; justify-content: end; }
.actions .btn { width: 72px; height: 72px; margin: 0; border-radius: 0; font-size: 16px; padding: 0; }
.actions .btn.a { background: var(--pink); }
.actions .btn.b { background: var(--cyan); }
.letters { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 6px; padding: 0 4px; }
.letters .btn { margin: 0; padding: 12px 0; }
.letters .btn.wide { grid-column: span 2; }

/* full screen: the game and its controls only */
.full { background: #000; }
.full .howto { display: none; } /* the bar stays as it is: name, icon, levels */
.full .stage { padding: 8px 0 0; gap: 0; grid-template-columns: minmax(0, 1fr); }
.full .screen { padding: 0; background: none; box-shadow: none; }
.full .screen .start { inset: 0; }

/* a phone on its side: the d-pad and the buttons either side of the screen */
.side .top { padding-top: 4px; padding-bottom: 0; }
.side .top .name img, .side .howto { display: none; }
.side .top h1 { font-size: 16px; line-height: 16px; text-shadow: none; }
.side .stage { padding: 4px 0 0; grid-template-columns: minmax(0, 1fr); }
.side .pad { padding: 8px 0 0; }
.side .pad .main { position: fixed; left: 0; right: 0; bottom: max(16px, env(safe-area-inset-bottom)); pointer-events: none;
  padding: 0 max(16px, env(safe-area-inset-left)) 0 max(16px, env(safe-area-inset-right)); }
.side .pad .main > * { pointer-events: auto; }
.side .pad .row { padding: 0 176px; }
.side .dpad { transform: scale(0.85); transform-origin: bottom left; }
.side .actions { transform: scale(0.85); transform-origin: bottom right; }
