/* Blindfold — "afterimage" theme.
   The board lives behind your eyelids, so the palette is the colour of closed eyes: a deep violet
   field, lavender text, and two phosphene glows (ember and tide) that only appear around the move
   you're holding in your head. Everything else stays quiet. */

@font-face { font-family: "Young Serif"; src: url("/fonts/young-serif-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Hanken Grotesk"; src: url("/fonts/hanken-grotesk-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Hanken Grotesk"; src: url("/fonts/hanken-grotesk-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Hanken Grotesk"; src: url("/fonts/hanken-grotesk-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }

:root {
  --eyelid: #1c1730;     /* page */
  --dusk: #262040;       /* raised surfaces, inputs */
  --haze: #3b345a;       /* hairlines */
  --lavender: #ddd6f1;   /* text */
  --faded: #9d95bc;      /* secondary text */
  --ember: #ffae7a;      /* phosphene: actions, your turn */
  --tide: #86d9cf;       /* phosphene: confirmations */
  --rose: #ff8f9b;       /* illegal / errors */
  --display: "Young Serif", Georgia, serif;
  --ui: "Hanken Grotesk", -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--eyelid); }
body {
  margin: 0;
  min-height: 100dvh;
  color: var(--lavender);
  font: 400 17px/1.5 var(--ui);
  background:
    radial-gradient(120% 60% at 50% -10%, #2a2247 0%, transparent 60%),
    var(--eyelid);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
main { max-width: 34rem; margin: 0 auto; padding: 1.25rem 1.375rem 3.5rem; }

h1, h2, .display { font-family: var(--display); font-weight: 400; letter-spacing: -0.01em; }
h1 { font-size: 2.5rem; line-height: 1.05; margin: 0; }
h2 { font-size: 1.375rem; line-height: 1.2; margin: 2.5rem 0 0.75rem; }
p { margin: 0.5rem 0; }
.muted { color: var(--faded); }
.small { font-size: 0.875rem; }
a { color: var(--ember); }

:focus-visible { outline: 2px solid var(--ember); outline-offset: 3px; border-radius: 6px; }
input:focus-visible, select:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(255, 174, 122, 0.25); }

/* ---------- Controls ---------- */
button {
  font: 600 1rem/1 var(--ui);
  color: var(--lavender);
  background: var(--dusk);
  border: 1px solid var(--haze);
  border-radius: 999px;
  padding: 0.9rem 1.35rem;
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.15s ease;
}
button:active:not(:disabled) { transform: scale(0.97); }
button:disabled { opacity: 0.4; cursor: default; }
button.primary { background: var(--ember); border-color: var(--ember); color: #2a1709; }
button.text {
  background: none; border: 0; padding: 0.5rem 0; border-radius: 4px;
  color: var(--faded); font-weight: 500;
}
button.text:hover { color: var(--lavender); }
button.text.danger { color: var(--rose); }

label { display: block; font-size: 0.9375rem; color: var(--faded); margin-bottom: 0.4rem; }
input, select {
  width: 100%;
  font: 500 1.0625rem var(--ui);
  color: var(--lavender);
  background: var(--dusk);
  border: 1px solid var(--haze);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  outline: none;
  appearance: none;
}
input:focus, select:focus { border-color: var(--ember); }
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--faded) 50%), linear-gradient(135deg, var(--faded) 50%, transparent 50%);
  background-position: calc(100% - 20px) 55%, calc(100% - 15px) 55%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.field + .field { margin-top: 1rem; }
.actions { display: flex; gap: 0.75rem; margin-top: 1.25rem; flex-wrap: wrap; }
.actions > button { flex: 1 1 auto; }
.msg { min-height: 1.5rem; margin-top: 0.75rem; font-size: 0.9375rem; }
.msg.bad { color: var(--rose); }
.msg.good { color: var(--tide); }
.msg.ask { color: var(--lavender); }

/* ---------- Sign-in ---------- */
.welcome { padding-top: 14vh; }
.welcome h1 { font-size: clamp(3.4rem, 17vw, 5rem); position: relative; }
.welcome h1::before {               /* the one afterimage on this screen */
  content: ""; position: absolute; z-index: -1; inset: -40% -10% -30% -20%;
  background:
    radial-gradient(40% 50% at 30% 55%, rgba(255, 174, 122, 0.35), transparent 70%),
    radial-gradient(35% 45% at 62% 45%, rgba(134, 217, 207, 0.22), transparent 70%);
  filter: blur(18px);
}
.welcome .lede { font-size: 1.1875rem; color: var(--faded); max-width: 24rem; margin: 1rem 0 2.75rem; }

/* ---------- Header ---------- */
.top { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding: 0.5rem 0 0.25rem; }
.top .wordmark { font-family: var(--display); font-size: 1.5rem; }
.top .who { color: var(--faded); font-size: 0.9375rem; display: flex; align-items: baseline; gap: 0.9rem; }

.notice {
  margin-top: 1.25rem; padding: 1rem 1.1rem; border-radius: 16px;
  background: var(--dusk); border: 1px solid var(--haze); font-size: 0.9375rem;
}
.notice.ask { display: flex; align-items: center; gap: 1rem; }
.notice.ask p { flex: 1; margin: 0; }
.notice.ask button { padding: 0.7rem 1.1rem; }

/* ---------- Game lists: rows, not cards ---------- */
.games { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--haze); }
.games li { border-bottom: 1px solid var(--haze); }
.games button {
  all: unset; box-sizing: border-box; width: 100%; cursor: pointer;
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0.15rem 1rem;
  padding: 1rem 0.25rem;
}
.games button:focus-visible { outline: 2px solid var(--ember); outline-offset: -2px; }
.games .opp { font-weight: 600; font-size: 1.0625rem; }
.games .detail { grid-column: 1; color: var(--faded); font-size: 0.9375rem; }
.games .last { grid-row: 1 / span 2; grid-column: 2; font-family: var(--display); font-size: 1.375rem; color: var(--faded); }
.games .yours .last { color: var(--ember); }
.games .yours .opp::after {         /* a small phosphene dot marks games waiting on you */
  content: ""; display: inline-block; width: 7px; height: 7px; margin-left: 0.5rem; vertical-align: 0.15em;
  border-radius: 50%; background: var(--ember); box-shadow: 0 0 10px 2px rgba(255, 174, 122, 0.6);
}
.empty { color: var(--faded); margin-top: 0.5rem; }

.new-game { margin-top: 2.5rem; }
.new-game .pair { display: grid; grid-template-columns: 1fr 9.5rem; gap: 0.75rem; }

/* ---------- Game screen ---------- */
.back { margin: 0.25rem 0 0; }
.matchup { margin: 0.25rem 0 0; color: var(--faded); }
.matchup b { color: var(--lavender); font-weight: 600; }
.views { margin: 0.35rem 0 0; color: var(--faded); font-size: 0.9375rem; }
.form-note { color: var(--faded); font-size: 0.875rem; margin: 0.6rem 0 0; }
.new-game .pair + .pair { margin-top: 1rem; }

.afterimage { position: relative; text-align: center; padding: 3.5rem 0 3rem; isolation: isolate; }
.afterimage::before {
  content: ""; position: absolute; z-index: -1; left: 50%; top: 50%;
  width: min(30rem, 110%); aspect-ratio: 1.5; transform: translate(-50%, -50%);
  background:
    radial-gradient(38% 42% at 42% 52%, rgba(255, 174, 122, 0.42), transparent 72%),
    radial-gradient(34% 40% at 60% 46%, rgba(134, 217, 207, 0.26), transparent 72%);
  filter: blur(22px);
}
.afterimage.quiet::before { opacity: 0.35; }
.afterimage.compact { padding: 1.75rem 0 1.5rem; }
.afterimage.compact .move { font-size: clamp(3rem, 16vw, 4.5rem); }
.afterimage.compact .move.long { font-size: clamp(2.5rem, 12vw, 3.5rem); }
.afterimage .move {
  font-family: var(--display); line-height: 1; margin: 0;
  font-size: clamp(4.5rem, 26vw, 7.5rem); letter-spacing: -0.02em;
  text-shadow: 0 0 28px rgba(255, 214, 190, 0.35);
}
.afterimage .move.long { font-size: clamp(3.25rem, 17vw, 5.25rem); }
.afterimage .move .num { font-size: 0.38em; color: var(--faded); letter-spacing: 0; margin-right: 0.12em; vertical-align: 0.9em; text-shadow: none; }
.afterimage .caption { margin-top: 1rem; color: var(--faded); }
.afterimage .said { display: block; font-size: 1.25rem; font-weight: 500; color: var(--lavender); margin-bottom: 0.2rem; }
.afterimage.arrive .move { animation: develop 1.1s cubic-bezier(.2,.7,.2,1) both; }
.afterimage.arrive::before { animation: bloom 1.6s ease-out both; }
@keyframes develop { from { opacity: 0; filter: blur(14px); transform: scale(1.06); } to { opacity: 1; filter: blur(0); transform: none; } }
@keyframes bloom { 0% { opacity: 0; transform: translate(-50%, -50%) scale(0.7); } 45% { opacity: 1; } 100% { opacity: 1; transform: translate(-50%, -50%) scale(1); } }

.turn { text-align: center; font-weight: 600; margin: 0 0 1.5rem; color: var(--faded); }
.turn.mine { color: var(--ember); }

.offer { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.25rem; }
.offer p { flex: 1; margin: 0; }
.offer button { padding: 0.65rem 1rem; }

.play { display: grid; grid-template-columns: 1fr auto; gap: 0.75rem; }
.play input {
  font: 400 1.375rem/1.2 var(--display); text-align: center; padding: 0.75rem 1rem;
  border-radius: 16px;
}
.play input::placeholder { color: #6d6590; font-family: var(--ui); font-size: 1.0625rem; }
.play button { padding-inline: 1.5rem; }
.hint { text-align: center; color: var(--faded); font-size: 0.875rem; margin-top: 0.6rem; max-width: 26rem; margin-inline: auto; }
.play-msg { text-align: center; }
.shake { animation: shake 0.36s; }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }

.tally { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.25rem 1.5rem; color: var(--faded); font-size: 0.9375rem; margin-top: 1.75rem; }
.tally b { color: var(--lavender); font-weight: 600; }
.side-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 0.25rem 1.75rem; margin-top: 2rem; }

/* ---------- Finished game ---------- */
.verdict { text-align: center; margin: -0.5rem 0 0.25rem; font-size: 1.75rem; }
.board {
  display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr);
  aspect-ratio: 1; border-radius: 14px; overflow: hidden; margin-top: 0.5rem;
  box-shadow: 0 0 0 1px var(--haze), 0 20px 60px -20px rgba(255, 174, 122, 0.25);
}
.board.reveal { animation: open-eyes 1.4s cubic-bezier(.2,.7,.2,1) both; }
@keyframes open-eyes { from { opacity: 0; filter: blur(18px) saturate(0.4); } to { opacity: 1; filter: none; } }
.board > * { aspect-ratio: 1; display: grid; place-items: center; font-size: min(9.2vw, 2.6rem); line-height: 1; }
.board button { all: unset; aspect-ratio: 1; display: grid; place-items: center; cursor: pointer; font-size: min(9.2vw, 2.6rem); line-height: 1; }
.board button:focus-visible { outline: 3px solid var(--ember); outline-offset: -3px; }
.board .last { box-shadow: inset 0 0 0 100vmax rgba(255, 174, 122, 0.38); }
.board .sel { box-shadow: inset 0 0 0 4px var(--tide), inset 0 0 0 100vmax rgba(134, 217, 207, 0.3); }
.board.live { margin-bottom: 0.25rem; }
.board + .hint { margin-bottom: 1.25rem; }
.board .l { background: #cfc7e6; }
.board .d { background: #8a80b0; }
.board .pw { color: #fff8ef; text-shadow: 0 0 1px #1c1730, 0 1px 1px #1c1730, 0 0 3px rgba(28, 23, 48, 0.8); }
.board .pb { color: #1c1730; }

.moves { columns: 2; column-gap: 2rem; list-style: none; padding: 0; margin: 0; font-size: 1rem; }
.moves li { display: grid; grid-template-columns: 2.25rem 1fr 1fr; padding: 0.2rem 0; break-inside: avoid; }
.moves .n { color: var(--faded); }

.toast {
  position: fixed; left: 50%; bottom: calc(1.5rem + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--dusk); border: 1px solid var(--haze); color: var(--lavender);
  padding: 0.7rem 1.2rem; border-radius: 999px; font-size: 0.9375rem; z-index: 10;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; transition: none !important; }
}
.board + form { margin-top: 1.25rem; }
.trio select { padding-right: 2rem; }
.trio { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; margin-top: 1rem; }
@media (max-width: 380px) { .trio { grid-template-columns: 1fr 1fr; } }
.handsfree p { margin: 0.4rem 0; }
.handsfree .actions { justify-content: flex-start; }
.handsfree .actions > button { flex: 0 0 auto; }

/* ---------- Privacy note ---------- */
.privacy h1 { margin-top: 1.5rem; }
.privacy ul { padding-left: 1.2rem; }
.privacy li { margin: 0.5rem 0; }
