/* Make Me Smile — the look is a 90s desktop toy, which is where the win
   cascade comes from in the first place. Flat colour, hard black outlines,
   solid offset shadows, window-chrome panels. No gradients, no soft shadows,
   no rounded blobs: those are what made the previous pass read as a template.

   The retro chrome is cosmetic only — touch targets, type size and stacking
   stay modern, because this is played one-handed on a phone. */

:root {
  --desk: #2e9e9e;      /* the old desktop teal */
  --panel: #f4efe2;     /* warm off-white, not battleship grey */
  --chrome: #1b1b2f;    /* title bars */
  --ink: #12121c;
  --ink-soft: #5c5a6f;
  --sun: #ffd400;
  --grape: #6c5ce7;
  --line: 3px solid var(--ink);
  --pop: 5px 5px 0 var(--ink);
  --pop-sm: 3px 3px 0 var(--ink);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  color: var(--ink);
  background-color: var(--desk);
  /* The dithered desktop pattern, drawn rather than shipped as an image. */
  background-image:
    repeating-linear-gradient(45deg, rgba(255,255,255,0.055) 0 2px, transparent 2px 4px),
    repeating-linear-gradient(-45deg, rgba(0,0,0,0.05) 0 2px, transparent 2px 4px);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---- top bar: a window title bar pinned to the top ---- */
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--chrome); border-bottom: var(--line);
}
.brand {
  font-weight: 800; font-size: 19px; letter-spacing: -0.02em; color: #fff;
  text-transform: uppercase; display: flex; align-items: center; gap: 9px; white-space: nowrap;
}
/* The mark: a drawn smiley as inline SVG, not an emoji. Emoji render
   differently on every platform, which is the fastest way to look generic —
   and a CSS-only face can't manage a real grin, only a band. */
.brand::before {
  content: ""; width: 26px; height: 26px; flex: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Ccircle cx='16' cy='16' r='14' fill='%23ffd400' stroke='%2312121c' stroke-width='3'/%3E%3Ccircle cx='11.5' cy='13' r='2.1' fill='%2312121c'/%3E%3Ccircle cx='20.5' cy='13' r='2.1' fill='%2312121c'/%3E%3Cpath d='M9.5 18.5 Q16 25 22.5 18.5' fill='none' stroke='%2312121c' stroke-width='2.8' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

.whoami { display: flex; gap: 8px; align-items: center; font-size: 13px; color: #cfcbe8; font-weight: 700; }
.credits {
  background: var(--sun); color: var(--ink); padding: 3px 10px;
  border: 2.5px solid var(--ink); font-weight: 800; font-size: 13px;
}

.hidden { display: none !important; }

#app { max-width: 720px; margin: 0 auto; padding: 18px 16px 72px; }

h1 {
  font-size: clamp(32px, 9vw, 52px); line-height: 0.98; letter-spacing: -0.035em;
  font-weight: 800; text-transform: uppercase; margin: 6px 0 12px;
  color: #fff; text-shadow: var(--pop-sm);
}
.sub { color: #eafafa; font-size: 16px; line-height: 1.45; font-weight: 600; }

/* ---- panels: each card is a little application window ---- */
.card {
  background: var(--panel); border: var(--line); box-shadow: var(--pop);
  padding: 0 16px 16px; margin-bottom: 20px;
}
/* The h2 becomes the window's title bar — full-bleed across the panel top. */
.card h2 {
  font-size: 15px; font-weight: 800; letter-spacing: 0.02em; text-transform: uppercase;
  margin: 0 -16px 14px; padding: 9px 14px; background: var(--chrome); color: #fff;
  border-bottom: var(--line); display: flex; align-items: center; gap: 8px;
}
.card p { color: var(--ink-soft); font-size: 15px; line-height: 1.45; margin: 0; font-weight: 600; }

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
@media (max-width: 680px) { .cards { grid-template-columns: 1fr; } }

/* ---- controls ---- */
form { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

input, select {
  flex: 1; min-width: 150px; padding: 13px 14px;
  border: 2.5px solid var(--ink); border-radius: 0; background: #fff; color: var(--ink);
  font-size: 17px; /* 16px+ stops iOS zooming the page on focus */
  font-family: inherit; font-weight: 700;
}
input::placeholder { color: #9a95a8; font-weight: 600; }
input:focus, select:focus { outline: none; box-shadow: inset 0 0 0 3px var(--sun); }

/* Buttons sit on a hard offset shadow and slam into it when pressed. */
button {
  padding: 13px 20px; border: 2.5px solid var(--ink); border-radius: 0;
  background: var(--grape); color: #fff; font-family: inherit; font-weight: 800;
  font-size: 16px; text-transform: uppercase; letter-spacing: 0.02em; cursor: pointer;
  box-shadow: var(--pop-sm);
  transition: transform 0.05s steps(2), box-shadow 0.05s steps(2);
  -webkit-tap-highlight-color: transparent;
}
button:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
button:disabled { background: #cfc9bb; color: #837e73; cursor: not-allowed; transform: none; }
button.link {
  background: none; color: var(--grape); padding: 0; border: none;
  text-decoration: underline; box-shadow: none; font-size: 14px; text-transform: none;
}
button.link:active { transform: none; }

/* The one obvious thing to press. */
#btnFindOpponent {
  background: var(--sun); color: var(--ink); width: 100%;
  font-size: 19px; padding: 16px 20px; box-shadow: var(--pop);
}
#btnFindOpponent:active { transform: translate(5px, 5px); box-shadow: 0 0 0 var(--ink); }

.screen { animation: snap 0.12s steps(3); }
@keyframes snap { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .screen { animation: none; }
  button { transition: none; }
}

.status { margin-top: 12px; font-size: 14px; color: var(--ink-soft); font-weight: 700; }
.status.center { text-align: center; font-size: 16px; margin-bottom: 12px; color: #eafafa; }

.bookings-list { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.booking-row {
  display: flex; justify-content: space-between; align-items: center;
  background: #fff; border: 2.5px solid var(--ink); padding: 10px 12px;
  font-size: 14px; font-weight: 700;
}
.booking-row .tag {
  font-size: 11px; padding: 3px 8px; background: var(--sun); border: 2px solid var(--ink);
  color: var(--ink); font-weight: 800; text-transform: uppercase;
}

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  width: min(460px, calc(100% - 28px));
  background: var(--panel); border: var(--line); box-shadow: var(--pop);
  padding: 18px; display: flex; flex-direction: column; gap: 12px; align-items: center;
  z-index: 10; text-align: center;
}
.toast p { margin: 0; font-weight: 800; font-size: 16px; }
.toast > div { display: flex; gap: 10px; }

/* ---- safety gate: also a window ---- */
#screen-safety { background: var(--panel); border: var(--line); box-shadow: var(--pop); padding: 0 18px 18px; }
#screen-safety h2 {
  font-size: 15px; text-transform: uppercase; letter-spacing: 0.02em;
  margin: 0 -18px 16px; padding: 9px 16px; background: var(--chrome); color: #fff;
  border-bottom: var(--line);
}
.safety-copy { font-size: 16px; line-height: 1.5; color: var(--ink); font-weight: 600; }
.safety-check {
  display: flex; gap: 12px; align-items: center; margin: 18px 0;
  font-size: 16px; font-weight: 800; cursor: pointer;
}
.safety-check input { flex: none; width: 24px; height: 24px; accent-color: var(--grape); }

/* ---- match screen ---- */
.video-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 680px) { .video-grid { grid-template-columns: 1fr; } }
.video-cell {
  position: relative; background: #101018; overflow: hidden; aspect-ratio: 4/3;
  border: var(--line); box-shadow: var(--pop);
}
.video-cell video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.video-cell canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }
.video-label {
  position: absolute; bottom: 0; left: 0; background: var(--chrome); color: #fff;
  padding: 5px 11px; font-size: 12px; font-weight: 800; text-transform: uppercase;
  border-top: 2.5px solid var(--ink); border-right: 2.5px solid var(--ink);
}

.timer {
  text-align: center; font-size: 44px; font-weight: 800; margin-top: 18px;
  font-variant-numeric: tabular-nums; letter-spacing: -0.03em;
  color: #fff; text-shadow: var(--pop-sm);
}

/* Countdown digits — big enough to read at arm's length while you're getting
   your face ready, and visually distinct from the round clock that follows. */
.timer.countdown {
  font-size: clamp(88px, 26vw, 140px); line-height: 1; color: var(--sun);
  animation: thump 1s steps(6) infinite;
}
@keyframes thump {
  0% { transform: scale(1.22); opacity: 0.55; }
  40% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { .timer.countdown { animation: none; } }

/* Role banner — the one thing a player must know at a glance each round,
   since roles swap between rounds of a best-of-3. */
.role-banner {
  text-align: center; font-weight: 800; font-size: 16px; text-transform: uppercase;
  letter-spacing: 0.02em; padding: 12px 16px; margin: 0 auto 14px; max-width: 34rem;
  background: var(--sun); color: var(--ink); border: var(--line); box-shadow: var(--pop-sm);
}

h2#resultHeadline {
  font-size: clamp(38px, 11vw, 62px); text-transform: uppercase; letter-spacing: -0.03em;
  color: #fff; text-shadow: var(--pop); margin: 10px 0; line-height: 0.95;
}
#screen-result .sub { font-size: 17px; }
.credits-big {
  display: inline-block; font-size: 26px; font-weight: 800; color: var(--ink);
  background: var(--sun); border: var(--line); box-shadow: var(--pop-sm);
  padding: 8px 16px; margin: 14px 0 18px;
}

#doubleOrNothingBlock { margin: 16px 0; }
#btnBackHome { background: var(--panel); color: var(--ink); }

/* ---- phone ---- */
@media (max-width: 560px) {
  /* Side-by-side fields leave each one too narrow to read what you typed. */
  form { flex-direction: column; gap: 12px; }
  form input, form select, form button { width: 100%; min-width: 0; }
  #app { padding: 14px 14px 72px; }
  .topbar { padding: 9px 12px; }
  .brand { font-size: 15px; }
  .brand::before { width: 22px; height: 22px; }
  .whoami { font-size: 12px; gap: 6px; }
  .credits { padding: 2px 8px; font-size: 12px; }
}

/* ---- opening title sequence ----
   The title flies in from the corner and sweeps a wide U through the middle —
   the path it travels is the smile — then loops back and lands centred. */
.intro {
  position: fixed; inset: 0; z-index: 9998;
  background-color: var(--desk);
  background-image:
    repeating-linear-gradient(45deg, rgba(255,255,255,0.055) 0 2px, transparent 2px 4px),
    repeating-linear-gradient(-45deg, rgba(0,0,0,0.05) 0 2px, transparent 2px 4px);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
body.intro-playing { overflow: hidden; }

.intro-title {
  font-weight: 800;
  font-size: clamp(34px, 11vw, 78px);
  line-height: 0.95;
  letter-spacing: -0.04em;
  text-transform: uppercase;
  color: var(--ink);
  text-align: center;
  max-width: 88vw;
  animation: swoop 2s cubic-bezier(0.34, 0.03, 0.21, 1) both;
}

/* Down the left, across the bottom, up the right, then a short loop back to
   the middle — a circle closed on a smile. */
@keyframes swoop {
  0%   { opacity: 0; transform: translate(-64vw, -62vh) rotate(-38deg) scale(0.42); }
  12%  { opacity: 1; }
  28%  { transform: translate(-36vw, 6vh) rotate(-22deg) scale(0.62); }
  46%  { transform: translate(-16vw, 27vh) rotate(-10deg) scale(0.78); }
  60%  { transform: translate(0, 33vh) rotate(0deg) scale(0.86); }
  74%  { transform: translate(17vw, 26vh) rotate(10deg) scale(0.92); }
  86%  { transform: translate(29vw, 5vh) rotate(18deg) scale(0.96); }
  94%  { transform: translate(13vw, -6vh) rotate(8deg) scale(1.02); }
  100% { opacity: 1; transform: translate(0, 0) rotate(0deg) scale(1); }
}

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