/* RetroPhone Games — shared look for the home page and every game.
   Retro-comic neo-brutalism: a cream poster on black, fat black outlines,
   huge heavy type, flat candy colours, halftone dots and sticker badges. */

:root {
  --paper: #f3e9d2;
  --ink: #141414;
  --pink: #ff8fc7;
  --orange: #ff7a2f;
  --teal: #2fb8a6;
  --blue: #7da2ff;
  --yellow: #ffd23f;

  --line: 3px solid var(--ink);
  --r: 18px;
  --font: "Archivo", "Arial Black", Arial, sans-serif;
  --dots: radial-gradient(rgba(20, 20, 20, .17) 1.2px, transparent 1.7px) 0 0 / 9px 9px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; background: var(--ink); }

body {
  margin: 0;
  min-height: 100dvh;
  padding: 14px;
  background: var(--ink);
  color: var(--ink);
  font: 500 16px/1.45 var(--font);
  touch-action: manipulation;   /* no double-tap zoom anywhere on the site */
}

:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }

.display {
  margin: 0;
  font-weight: 900;
  font-stretch: 125%;
  line-height: .9;
  letter-spacing: -.02em;
  text-transform: uppercase;
}

.poster {
  position: relative;
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px;
  border-radius: 26px;
  background: var(--paper);
  overflow: hidden;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 14px;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: .03em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ---------- home: hero ---------- */

.hero { display: grid; gap: 14px; margin: 4px 0 14px; }
.hero > * { min-width: 0; }

.headline { position: relative; }
.headline h1 { font-size: 12.6vw; }
.badge { position: absolute; right: 0; top: 50%; width: 23vw; max-width: 150px; transform: translateY(-50%) rotate(12deg); }
.badge text { font-family: var(--font); font-weight: 900; font-size: 16px; letter-spacing: 2.5px; }

.about { padding: 16px; border: var(--line); border-radius: var(--r); }
.about .lead {
  margin: 0 0 10px;
  padding-bottom: 10px;
  border-bottom: 2.5px solid var(--ink);
  font-weight: 800;
  font-size: 15px;
  line-height: 1.25;
  text-transform: uppercase;
}
.about p { margin: 0; font-size: 14px; }
.about .pill { min-height: 36px; margin-top: 12px; padding: 0 16px; background: var(--pink); color: var(--ink); font-size: 13px; text-decoration: none; text-transform: none; }
.about .pill:hover { background: var(--yellow); }

/* ---------- home: game cards ---------- */

.cards { display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; }

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  border: var(--line);
  border-radius: var(--r);
  overflow: hidden;
  background: var(--c, var(--pink));
  color: inherit;
  text-decoration: none;
  transition: transform .12s, box-shadow .12s;
}
.card:hover, .card:focus-visible { transform: translate(-3px, -3px); box-shadow: 6px 6px 0 var(--ink); }
.card:active { transform: none; box-shadow: none; }

/* the picture: a live demo of the game, which starts as the film photo */
.card .media { position: relative; display: block; padding: 12px; background: var(--dots); border-bottom: var(--line); }
.card .media iframe, .card .media img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
  border: var(--line);
  border-radius: 12px;
  background: var(--paper);
  object-fit: cover;
  pointer-events: none;
}
.card .burst { position: absolute; left: 0; top: 0; width: 84px; }
.card .burst text { font-family: var(--font); font-weight: 900; font-size: 21px; }

.card-foot {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 6px 12px;
  padding: 12px 14px;
  background: var(--paper);
}
.card .name { font-size: 21px; }
.card .blurb { grid-column: 1; font-size: 14px; line-height: 1.35; }
.card .top-score {
  grid-column: 1 / -1;
  justify-self: start;
  margin-top: 4px;
  padding: 4px 12px;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  background: var(--yellow);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: .02em;
}
.card .top-score[hidden] { display: none; }
.card .play { grid-column: 2; grid-row: 1 / span 2; min-height: 40px; padding: 0 18px; background: var(--ink); color: var(--paper); font-size: 14px; }

.empty { padding: 22px 16px; border: 3px dashed var(--ink); border-radius: var(--r); font-weight: 700; }

/* ---------- home: bottom panels ---------- */

.extras { display: grid; gap: 14px; margin-top: 14px; }

.shout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border: var(--line);
  border-radius: var(--r);
  background: var(--teal);
}
.shout .display { font-size: 24px; }
.shout svg { flex: none; width: 54px; height: 54px; }

.scores { padding: 14px 16px; border: var(--line); border-radius: var(--r); background: var(--orange); }
.scores .display { margin-bottom: 8px; font-size: 22px; }
.scores ol { display: flex; flex-wrap: wrap; gap: 4px 22px; margin: 0; padding: 0; list-style: none; }
.scores li { font-weight: 800; }
.scores li span { margin-left: 6px; padding: 1px 8px; border: 2.5px solid var(--ink); border-radius: 999px; background: var(--paper); }
.scores p { margin: 0; font-weight: 700; }

@media (min-width: 640px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .extras { grid-template-columns: 1fr 1.6fr; }
}

@media (min-width: 900px) {
  body { padding: 24px; }
  .poster { padding: 22px; }
  .hero { grid-template-columns: 1.9fr 1fr; align-items: end; }
  .headline h1 { font-size: min(7.6vw, 96px); }
  .badge { right: 9%; width: clamp(110px, 13vw, 172px); max-width: none; }
  .cards { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- game pages ---------- */

.poster.game { max-width: 820px; }

.game-top { display: flex; align-items: center; gap: 12px; padding-bottom: 14px; }
.back { flex: none; min-height: 40px; background: var(--yellow); color: var(--ink); font-size: 13px; text-decoration: none; }
.back:active { transform: translateY(2px); }
.game-title { min-width: 0; font-size: clamp(19px, 5.2vw, 30px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.stage {
  position: relative;
  height: min(560px, calc(100dvh - 216px));
  min-height: 320px;
  overflow: hidden;
  border: var(--line);
  border-radius: var(--r);
  background: var(--ink);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.stage canvas { display: block; width: 100%; height: 100%; margin: 0 auto; touch-action: none; }
/* the film photo, laid over the game until it morphs away */
.stage .morph { position: absolute; inset: 0; z-index: 5; image-rendering: pixelated; }

.hud { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 14px; }
.hud > * {
  padding: 5px 13px;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  background: var(--yellow);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: .02em;
  text-transform: uppercase;
  white-space: nowrap;
}
.hud > :nth-child(2) { background: var(--blue); }
.hud > :nth-child(3) { background: var(--pink); }

.dialog {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 100000;
  width: min(340px, calc(100% - 28px));
  transform: translate(-50%, -50%);
  padding: 20px 18px 18px;
  border: var(--line);
  border-radius: var(--r);
  background: var(--paper);
  box-shadow: 6px 6px 0 var(--ink);
  text-align: center;
}
.dialog[hidden] { display: none; }
.dialog { max-height: calc(100% - 16px); overflow-y: auto; }
.dialog p { margin: 0 0 10px; font-size: 15px; }
.dialog .big { margin-bottom: 12px; font-weight: 900; font-stretch: 125%; font-size: 22px; line-height: 1; letter-spacing: -.01em; text-transform: uppercase; }

.btn {
  min-height: 46px;
  margin-top: 4px;
  padding: 0 28px;
  border: var(--line);
  border-radius: 999px;
  background: var(--orange);
  box-shadow: 0 4px 0 var(--ink);
  color: var(--ink);
  font: 900 15px var(--font);
  letter-spacing: .03em;
  text-transform: uppercase;
  cursor: pointer;
}
.btn:active { transform: translateY(4px); box-shadow: none; }

/* ---------- picture instructions in a start box ---------- */

.how { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 14px; padding: 0; list-style: none; }
.how li {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  padding: 10px 6px 8px;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  background: #fff;
  font-weight: 800;
  font-size: 11.5px;
  line-height: 1.2;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.how .pics { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; min-height: 38px; }
.how img { width: auto; image-rendering: pixelated; }
.how kbd {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border: 2px solid var(--ink);
  border-bottom-width: 4px;
  border-radius: 6px;
  background: var(--paper);
  font: 800 11px var(--font);
}
/* a little phone with a finger on it */
.touch { position: relative; flex: none; width: 24px; height: 36px; border: 2.5px solid var(--ink); border-radius: 6px; background: var(--paper); }
.touch::before {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--orange);
}
.touch.left::before { left: 0; bottom: 5px; }
.touch.right::before { right: 0; bottom: 5px; }
.touch.tap::before, .touch.hold::before { left: 50%; top: 50%; transform: translate(-50%, -50%); }
.touch.hold::before { box-shadow: 0 0 0 3px var(--yellow), 0 0 0 5px var(--ink); }

/* ---------- the film photo behind a game page ---------- */

.photo-bg { background: none; }
.photo-bg::before { content: ""; position: fixed; inset: 0; z-index: -1; background: var(--photo) center / cover no-repeat; }
/* on phones the page behind a game is plain black */
@media (max-width: 640px) {
  .photo-bg { background: var(--ink); }
  .photo-bg::before { display: none; }
}

/* ---------- leaderboard ---------- */

.post { margin: 4px 0 14px; text-align: center; }
.post[hidden] { display: none; }
.dialog .post .post-title { margin: 0 0 8px; font-weight: 800; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; }
.post input {
  flex: 1;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0 16px;
  border: var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font: 500 16px var(--font);
}
.post .names { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
/* one pill: the email box with the Post button tucked inside its right end */
.post .send { display: flex; border: var(--line); border-radius: 999px; background: #fff; overflow: hidden; }
.post .send input { border: 0; border-radius: 0; background: none; padding-right: 4px; }
.post .send input:focus { outline: none; }
.post .send:focus-within { outline: 3px solid var(--blue); outline-offset: 3px; }
.post .btn { min-height: 44px; margin: 0; padding: 0 20px; border: 0; border-left: var(--line); border-radius: 0; background: var(--yellow); box-shadow: none; font-size: 13px; }
.post .btn:active { transform: none; background: var(--ink); color: var(--paper); }
.dialog .post p:last-child { margin: 8px 0 0; font-size: 12px; color: #5d564a; }
.dialog .post-status { font-weight: 700; font-size: 14px; }
.post-status button { padding: 0; border: 0; background: none; color: inherit; font: inherit; text-decoration: underline; cursor: pointer; }

/* game-over box: the score is the headline */
.dialog #over-score { margin: 2px 0 8px; font-weight: 900; font-stretch: 125%; font-size: 52px; line-height: 1; letter-spacing: -.02em; }
.dialog #over-note {
  display: inline-block;
  margin: 0 0 14px;
  padding: 4px 12px;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  background: var(--yellow);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.dialog #over .big { margin-bottom: 6px; font-size: 16px; }
.dialog #over .btn { display: block; margin: 0 auto; }
.dialog #over .post .btn { display: inline-block; }

.board { margin-top: 16px; padding: 14px 16px 16px; border: var(--line); border-radius: var(--r); background: var(--teal); }
.board .display { margin-bottom: 10px; font-size: 20px; }
.board ol { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.board li {
  display: grid;
  grid-template-columns: 2em 1fr auto;
  gap: 8px;
  padding: 6px 14px;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  font-weight: 800;
  font-size: 14px;
}
.board li.you { background: var(--yellow); }
.board li span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-note { margin: 0; font-weight: 700; font-size: 14px; }
.board-note[hidden] { display: none; }

@media (max-width: 640px) {
  body { padding: 8px; }
  .poster { padding: 12px; border-radius: 20px; }
  .stage { height: calc(100dvh - 182px); }
  .game-top { padding-bottom: 12px; }
  .hud { padding-top: 12px; }
}

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

/* ---------- demo mode: just the game, filling its frame ---------- */

.demo, .demo body { background: var(--paper); }
.demo body { padding: 0; min-height: 0; overflow: hidden; }
.demo .poster.game { max-width: none; padding: 0; border-radius: 0; }
.demo .game-top, .demo .hud, .demo .dialog, .demo .board { display: none !important; }
.demo .stage { height: 100vh; min-height: 0; border: 0; border-radius: 0; }
