@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/bricolage.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --navy: #004687;
  --navy-deep: #00325f;
  --lime: #97be0d;
  --lime-deep: #86a90b;
  --ink: #111722;
  --muted: #586273;
  --paper: #eef1f5;
  --card: #ffffff;
  --field: #f4f6f9;
  --bad: #b3261e;
  /* host screen */
  --night: #0a1626;
  --night-bar: #060f1b;
  --night-tile: #13243a;
  --night-ink: #e9eef4;
  --night-muted: #93a3b6;
  --check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
  font-family: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { line-height: 1.45; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1, h2 { line-height: 1.05; margin: 0 0 0.35em; letter-spacing: -0.03em; font-weight: 700; text-wrap: balance; }
p { margin: 0 0 1em; }
::selection { background: var(--lime); color: var(--ink); }
:focus-visible { outline: 3px solid var(--lime); outline-offset: 3px; }

button, .button {
  font: inherit;
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  border: 0;
  border-radius: 999px;
  padding: 0 1.5em;
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, transform 0.12s cubic-bezier(0.2, 0.8, 0.2, 1);
}
button:hover:not(:disabled), .button:hover { background: var(--navy-deep); }
button:active:not(:disabled) { transform: scale(0.97); }
button:disabled { cursor: not-allowed; background: #d6dce4; color: #7d8796; }
button.go { background: var(--lime); color: var(--ink); }
button.go:hover:not(:disabled) { background: var(--lime-deep); }
button.secondary { background: var(--field); color: var(--navy); }
button.secondary:hover:not(:disabled) { background: #e3e8ef; }

input[type="text"] {
  font: inherit;
  font-size: 1.2rem;
  width: 100%;
  padding: 0 0.9em;
  min-height: 56px;
  border: 2px solid transparent;
  border-radius: 14px;
  background: var(--field);
  color: var(--ink);
  caret-color: var(--navy);
  transition: border-color 0.15s, background-color 0.15s;
}
input[type="text"]::placeholder { color: #6b7584; }
input[type="text"]:focus { border-color: var(--navy); background: #fff; outline: none; }
label { display: block; font-weight: 600; margin-bottom: 0.5em; }

.error { color: var(--bad); font-weight: 600; margin: 0.7em 0 0; }
.error:empty { display: none; }
#upload-error { margin: 0 0 14px; }
.brand { font-weight: 700; letter-spacing: -0.02em; color: var(--navy); white-space: nowrap; }
.brand::before { content: ""; display: inline-block; width: 0.62em; height: 0.62em; border-radius: 3px; background: var(--lime); margin-right: 0.45em; vertical-align: 0.04em; }

/* The tick used for "Sent", drawn once and tinted per place */
.status.sent::before, .sent .state::before {
  content: "";
  display: inline-block;
  width: 1em;
  height: 1em;
  margin-right: 0.35em;
  vertical-align: -0.14em;
  background: currentColor;
  -webkit-mask: var(--check) center / contain no-repeat;
  mask: var(--check) center / contain no-repeat;
}

/* Home and player pages: one narrow column */
.narrow { max-width: 480px; margin: 0 auto; padding: 28px 20px 56px; }
.narrow header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 36px; font-size: 1.15rem; }
.narrow header .hint { font-weight: 600; }
.panel { background: var(--card); border-radius: 24px; padding: 26px 24px; margin-bottom: 16px; }
.panel h2 { font-size: 1.6rem; }
.row { display: flex; gap: 10px; }
.row input { flex: 1; min-width: 0; }
.hint { color: var(--muted); }
.wide { width: 100%; margin-top: 1.25rem; }
#picture-step h1 { font-size: 2.4rem; margin-bottom: 0.5em; }

#code-input { letter-spacing: 0.32em; font-weight: 700; text-align: center; font-size: 1.6rem; padding-left: 1.2em; }

.drop {
  border: 2px dashed #b9c4d1;
  border-radius: 24px;
  background: var(--card);
  padding: 22px 20px;
  text-align: center;
  transition: border-color 0.15s, background-color 0.15s;
}
.drop.over { border-color: var(--lime); background: #f5f9e8; }
.drop p { margin: 0 0 16px; font-size: 1.05rem; color: var(--muted); }
.steps { text-align: left; margin: 2px 0 20px; padding-left: 1.4em; font-size: 1.05rem; line-height: 1.5; }
.steps li { margin-bottom: 0.45em; padding-left: 0.2em; }
.steps li::marker { color: var(--navy); font-weight: 700; }
.clock { display: inline-block; margin: 0 0 14px; padding: 0.2em 0.75em; border-radius: 999px; background: var(--ink); color: #fff; font-size: 1.25rem; font-weight: 700; }
.drop .actions { display: flex; flex-direction: column; gap: 10px; }
.drop .actions button { width: 100%; }
.target { display: block; width: 100%; max-height: 40vh; object-fit: contain; background: #fff; border-radius: 18px; padding: 16px; margin-bottom: 16px; }
.preview { display: block; width: 100%; max-height: 45vh; object-fit: contain; border-radius: 14px; margin-bottom: 16px; }
.status { font-size: 1.2rem; font-weight: 700; margin: 0 0 14px; }
.status:empty { display: none; }
.status.sent { color: #3f5900; }
.notice { background: var(--navy); color: #fff; border-radius: 18px; padding: 16px 20px; font-size: 1.1rem; font-weight: 600; margin-bottom: 16px; }

/* Host screen: a projector at the front of a room */
body.host { height: 100vh; overflow: hidden; background: var(--night); color: var(--night-ink); }
.host .bar { display: flex; align-items: center; gap: 20px; height: 84px; padding: 0 28px; background: var(--night-bar); }
.host .bar .brand { color: #fff; font-size: 1.35rem; }
.host .bar .code-small { font-size: 1.35rem; font-weight: 700; letter-spacing: 0.1em; color: var(--lime); }
.host .bar .counts { font-size: 1.35rem; color: var(--night-muted); }
.host .bar .counts strong { color: #fff; font-weight: 700; }
.host .bar .hint { margin-right: auto; font-size: 1.05rem; color: var(--night-muted); }
.host .bar button { font-size: 1.15rem; min-height: 56px; padding: 0 1.7em; }
.host button:disabled { background: #18283d; color: #5f7088; }
.host button.ghost { background: #1b2d45; color: #fff; }
.host button.ghost:hover:not(:disabled) { background: #253b58; }
.host main { display: flex; height: calc(100vh - 84px); padding: 28px; gap: 28px; }

.join {
  flex: 0 0 clamp(360px, 34vw, 600px);
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  background: var(--card);
  color: var(--ink);
  border-radius: 32px;
  padding: 32px;
}
.join .label { font-size: clamp(1rem, 4.2cqi, 1.5rem); color: var(--muted); margin: 0; }
.join .url { font-size: min(2.6rem, 7.4cqi); font-weight: 700; letter-spacing: -0.02em; color: var(--navy); white-space: nowrap; margin: 0.05em 0 0.55em; }
.join .code { font-size: min(10rem, 31cqi); font-weight: 800; letter-spacing: 0.06em; line-height: 0.9; margin: 0.08em 0 0.3em; }
.join img { width: min(62cqi, 30vh); aspect-ratio: 1; image-rendering: pixelated; margin-bottom: 0.4em; }
.stage { flex: 1; min-width: 0; position: relative; display: flex; align-items: center; justify-content: center; background: #fff; border-radius: 32px; padding: 32px; }
.stage img { width: 100%; height: 100%; object-fit: contain; }
.timer { position: absolute; top: 24px; right: 24px; margin: 0; padding: 0.15em 0.6em; border-radius: 999px; background: var(--night-bar); color: #fff; font-size: clamp(2rem, 4.4vw, 4.6rem); font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.timer.low { background: #e8603c; }

/* The three phases: join, draw, reveal */
body:not([data-phase="lobby"]) .join, body:not([data-phase="drawing"]) .stage { display: none; }
[data-phase="drawing"] .tiles { flex: 0 0 clamp(200px, 17vw, 320px); }

.tiles {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows, 3), minmax(0, 1fr));
  gap: 16px;
  min-width: 0;
  min-height: 0;
}
.tiles .empty { grid-column: 1 / -1; grid-row: 1 / -1; align-self: center; justify-self: center; text-align: center; max-width: 22ch; font-size: clamp(1.4rem, 2.4vw, 2.4rem); font-weight: 600; letter-spacing: -0.02em; color: var(--night-muted); }

.tile { perspective: 1400px; min-width: 0; min-height: 0; animation: pop 0.45s cubic-bezier(0.16, 1, 0.3, 1); }
[data-phase="revealed"] .tile { cursor: zoom-in; }
.original .back .caption { background: var(--lime); }
.card { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1); }
.flipped .card { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 20px; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 14px; text-align: center; }
.front { background: var(--night-tile); color: var(--night-ink); transition: background-color 0.3s; }
.sent .front { background: var(--navy); }
.front .name { font-size: clamp(1.1rem, 2.3vw, 2.4rem); font-weight: 700; letter-spacing: -0.02em; overflow-wrap: anywhere; line-height: 1.1; }
.front .state { margin-top: 0.45em; font-size: clamp(0.9rem, 1.3vw, 1.3rem); font-weight: 600; color: var(--night-muted); }
.sent .front .state { color: var(--lime); }
.back { transform: rotateY(180deg); background: #fff; padding: 0; }
.back img { flex: 1; min-height: 0; width: 100%; object-fit: contain; }
.back .caption { width: 100%; padding: 8px 12px 10px; font-size: clamp(0.95rem, 1.5vw, 1.5rem); font-weight: 700; letter-spacing: -0.01em; color: var(--ink); background: var(--field); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@keyframes pop { from { transform: translateY(14px) scale(0.96); opacity: 0; } }

.lightbox { width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; border: 0; padding: 28px 104px; background: transparent; color: #fff; }
.lightbox[open] { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.lightbox::backdrop { background: rgba(4, 9, 16, 0.96); }
.lightbox img { max-width: 100%; max-height: calc(100vh - 150px); object-fit: contain; border-radius: 14px; background: #fff; }
.lightbox .caption { font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; margin: 18px 0 0; }
.lightbox .nav { position: absolute; top: 50%; translate: 0 -50%; width: 68px; height: 68px; padding: 0; }
.lightbox .nav svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.lightbox .prev { left: 20px; }
.lightbox .next { right: 20px; }
.lightbox .close { position: absolute; top: 20px; right: 20px; }

@media (max-width: 900px) {
  body.host { height: auto; overflow: auto; }
  .host .bar { flex-wrap: wrap; height: auto; padding: 14px 20px; gap: 10px 16px; }
  .host .bar .hint { flex-basis: 100%; order: 9; }
  .host main { flex-direction: column; height: auto; padding: 20px; }
  .join { flex: none; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: none; grid-auto-rows: 180px; }
}

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

/* The game code reads better in the proportional digits; tabular ones give the 1 a typewriter foot */
.join .code, .host .bar .code-small { font-variant-numeric: proportional-nums; }

/* Home page: a splash for the projector and a quick way in for phones */
body.home { min-height: 100vh; background: var(--navy); color: #fff; }
.home-bar { padding: 28px clamp(20px, 4vw, 56px) 0; font-size: 1.25rem; }
.home .brand { color: #fff; }
.splash { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: clamp(28px, 5vw, 80px); align-items: center; min-height: calc(100vh - 80px); padding: clamp(28px, 5vw, 64px) clamp(20px, 4vw, 56px) 56px; max-width: 1440px; margin: 0 auto; }
.pitch h1 span { display: inline-block; }
.pitch h1 { font-size: clamp(2.4rem, 5.6vw, 5.4rem); line-height: 0.95; letter-spacing: -0.045em; font-weight: 800; margin: 0 0 0.35em; }
.lede { font-size: clamp(1.1rem, 1.5vw, 1.35rem); line-height: 1.45; max-width: 34ch; margin-bottom: 1.6em; color: #dbe6f3; }
.joinbox { background: var(--card); color: var(--ink); border-radius: 28px; padding: 24px; max-width: 460px; }
.joinbox label { font-size: 1.1rem; }
.joinbox .go { padding: 0 1.8em; }
.runbox { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-top: 22px; color: #dbe6f3; }
.runbox p { margin: 0; font-size: 1.05rem; }
.runbox .error { flex-basis: 100%; color: #ffb4a8; }
.home button.ghost { background: #1c5d9c; color: #fff; }
.home button.ghost:hover:not(:disabled) { background: #2a6db0; }

.scene { margin: 0; }
.scene svg { display: block; width: 100%; height: auto; background: #fff; border-radius: 32px; }
.scene figcaption { position: relative; height: 2.6em; margin-top: 18px; font-size: clamp(1rem, 1.4vw, 1.25rem); font-weight: 700; }
.scene figcaption span { position: absolute; left: 0; padding: 0.35em 0.95em; border-radius: 999px; }
.c-meant { background: #fff; color: var(--navy); animation: meant 10s infinite; }
.c-drew { background: var(--lime); color: var(--ink); opacity: 0; animation: drew 10s infinite; }

.s-tri, .s-sun, .s-dia, .s-wave { transform-box: fill-box; transform-origin: center; animation-duration: 10s; animation-iteration-count: infinite; animation-timing-function: cubic-bezier(0.65, 0, 0.35, 1); }
.s-tri { fill: none; stroke: var(--navy); stroke-width: 10; stroke-linejoin: round; stroke-linecap: round; stroke-dasharray: 100; animation-name: tri; }
.s-sun { fill: var(--lime); animation-name: sun; }
.s-dia { fill: var(--navy); animation-name: dia; }
.s-wave { fill: none; stroke: #5b6475; stroke-width: 7; stroke-linecap: round; stroke-dasharray: 100; animation-name: wave; }

/* 0 to 35%: the picture draws itself. 45 to 85%: it goes wrong, the way a description does. Then back. */
@keyframes tri { 0% { stroke-dashoffset: 100; transform: none; } 18%, 42% { stroke-dashoffset: 0; transform: none; } 52%, 84% { stroke-dashoffset: 0; transform: rotate(180deg) scale(0.8); } 95%, 100% { stroke-dashoffset: 0; transform: none; } }
@keyframes sun { 0%, 10% { transform: scale(0); } 18%, 42% { transform: none; } 52%, 84% { transform: translate(300px, 10px) scale(0.45); } 95%, 100% { transform: none; } }
@keyframes dia { 0%, 18% { transform: scale(0); } 25%, 42% { transform: none; } 52%, 84% { transform: translate(-200px, -140px) scale(1.9) rotate(20deg); } 95%, 100% { transform: none; } }
@keyframes wave { 0%, 20% { stroke-dashoffset: 100; transform: none; } 35%, 42% { stroke-dashoffset: 0; transform: none; } 52%, 84% { stroke-dashoffset: 0; transform: scaleY(-1) scaleX(0.7); } 95%, 100% { stroke-dashoffset: 0; transform: none; } }
@keyframes meant { 0%, 44% { opacity: 1; } 50%, 86% { opacity: 0; } 92%, 100% { opacity: 1; } }
@keyframes drew { 0%, 44% { opacity: 0; } 50%, 86% { opacity: 1; } 92%, 100% { opacity: 0; } }

@media (max-width: 820px) {
  .splash { grid-template-columns: 1fr; min-height: 0; padding-top: 24px; }
  .scene { order: 2; }
  .scene svg { border-radius: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  .s-tri, .s-sun, .s-dia, .s-wave, .c-meant, .c-drew { animation: none; }
}
