/* Duetle: Bauhaus. Primary colours on paper, black rules, pure geometry (squares, circles, triangles), no rounded
   corners and no shadows. Jost (a Futura-style geometric sans) throughout, lowercase headings.
   Word 1 is blue, word 2 is red, a letter in the wrong spot is yellow: the same as the share grid's 🟦 🟥 🟨. */
:root {
  --bg: #f2eee5;
  --panel: #fbf9f4;
  --ink: #141414;
  --muted: #5f5a52;
  --rule: #141414;
  --faint: #cdc6b8;
  --left: #1f4fb0;
  --right: #d93a22;
  --gold: #f2b705;
  --on-gold: #141414;
  --out: #bdb6a8;
  --key: #fbf9f4;
  --key-out: #e2ddd2;
  --key-out-ink: #aaa397;
  --tile-text: #ffffff;
  --dead-text: #4a463f;
  --font: "Jost", "Futura", "Century Gothic", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131313;
    --panel: #1c1c1c;
    --ink: #f2eee5;
    --muted: #a39d92;
    --rule: #f2eee5;
    --faint: #3a3a3a;
    --left: #3d6ee0;
    --right: #ec4a2e;
    --gold: #f5c21b;
    --out: #3b3b3b;
    --key: #1c1c1c;
    --key-out: #161616;
    --key-out-ink: #4d4d4d;
    --dead-text: #cfc9bd;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; border-radius: 0; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* Sizes follow the screen: --u is a unit from the viewport's height, so short phones get a tighter layout and
   tablets a roomier one. The board's tiles size themselves from the space actually left for them. */
.app {
  --u: clamp(0.82, calc(100dvh / 860px), 1.18);
  --gap: calc(10px * var(--u));
  height: 100dvh;
  width: min(100%, 560px);
  margin: 0 auto;
  display: grid;
  grid-template: "top" auto "field" auto "board" minmax(0, 1fr) "toast" auto "kb" auto / minmax(0, 1fr);
  gap: var(--gap);
  padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}
.top { grid-area: top; } .field { grid-area: field; justify-self: center; width: 100%; max-width: 480px; } .board { grid-area: board; } .toast { grid-area: toast; } .kb { grid-area: kb; }
/* Phones held sideways (and other short, wide screens): board on the left, everything else on the right. */
@media (orientation: landscape) and (max-height: 560px) {
  .app {
    width: min(100%, 980px);
    --u: clamp(0.72, calc(100dvh / 520px), 1);
    grid-template: "board top" auto "board field" auto "board toast" minmax(0, 1fr) "board kb" auto / minmax(0, 1fr) minmax(0, 1.15fr);
    column-gap: 24px;
  }
  .toast { align-self: center; }
}
/* Tablets and big screens: a wider column with bigger tiles and keys. */
@media (min-width: 700px) and (min-height: 860px) {
  .app { width: min(100%, 680px); --u: clamp(1, calc(100dvh / 860px), 1.35); --tile-max: 96px; }
  .k { max-width: 60px; }
  .k.wide { max-width: 92px; }
}

/* header: logo, number, three square buttons, over a thick black rule */
.top { display: flex; align-items: center; gap: 8px; padding-bottom: calc(8px * var(--u)); border-bottom: 3px solid var(--rule); }
.mark { margin: 0; display: flex; align-items: center; gap: calc(10px * var(--u)); font: 700 calc(30px * var(--u))/1 var(--font); letter-spacing: -0.02em; text-transform: lowercase; }
.mark-tile { width: calc(36px * var(--u)); height: calc(36px * var(--u)); flex: none; }
.num { font: 500 13px var(--font); color: var(--muted); letter-spacing: 0.14em; text-transform: uppercase; margin-left: 4px; }
.spacer { flex: 1; }
.icon {
  width: calc(40px * var(--u)); height: calc(40px * var(--u)); display: grid; place-items: center;
  background: transparent; border: 3px solid var(--rule); font: 700 18px var(--font);
}
.icon:hover { background: var(--gold); color: var(--on-gold); }

/* the two word plates: flat blocks of colour */
.field { position: relative; }
.plates { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.plate { border: 3px solid var(--rule); padding: 7px 8px 9px; position: relative; }
.plate-l { background: var(--left); }
.plate-r { background: var(--right); }
.plate-name { font: 600 11px var(--font); letter-spacing: 0.2em; text-transform: uppercase; color: #fff; margin: 0 2px 6px; }
.plate-r .plate-name { text-align: right; }
.slots { display: flex; gap: 4px; }
.slot {
  flex: 1; aspect-ratio: 1; display: grid; place-items: center;
  font: 700 clamp(14px, calc(min(4.6vw, 2.3dvh) * var(--u) * 1.05), 24px)/1 var(--font); text-transform: uppercase; color: var(--ink);
  background: rgba(0, 0, 0, 0.18); border: 2px solid rgba(255, 255, 255, 0.4);
}
.slot.on { background: #fff; color: #141414; border: 2px solid #141414; animation: drop 0.3s ease-out; }
/* A found word gets a yellow circle, on the side of the plate away from its label. */
.plate.solved::after {
  content: "✓"; position: absolute; top: -15px; right: 12px; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; background: var(--gold); color: #141414; border: 3px solid var(--rule); font: 700 15px var(--font);
  animation: drop 0.35s ease-out;
}
.plate-r.solved::after { right: auto; left: 12px; }

/* the board: square tiles, black rules */
.board { min-height: 0; display: flex; flex-direction: column; justify-content: center; gap: 6px; container-type: size; }
.row { display: flex; gap: 6px; justify-content: center; }
.tile {
  /* The biggest tile that fits the board's own width and height (7 rows of 5), up to 78px. */
  --size: min(var(--tile-max, 78px), calc((100cqw - 24px) / 5), calc((100cqh - 36px) / 7));
  width: var(--size); height: var(--size); position: relative; overflow: hidden;
  display: grid; place-items: center; border: 2px solid var(--faint);
  font: 700 calc(var(--size) * 0.5)/1 var(--font); text-transform: uppercase; background: transparent;
}
.tile.typed { border: 3px solid var(--rule); background: var(--panel); animation: pop 0.12s ease-out; }
.tile.next { border: 2px solid var(--muted); }
.tile.done { border: 3px solid var(--rule); color: var(--tile-text); }
.tile .a, .tile .b { position: absolute; inset: 0; }
.tile .a { clip-path: polygon(0 0, 100% 0, 0 100%); }
.tile .b { clip-path: polygon(100% 0, 100% 100%, 0 100%); }
.tile span { position: relative; }
.c2a { background: var(--left); } .c2b { background: var(--right); } .c1 { background: var(--gold); } .c0 { background: var(--out); }
.tile.dead span { color: var(--dead-text); }
.tile.warm span { color: var(--on-gold); }
.flip { animation: flip 0.45s ease-out both; }
.shake { animation: shake 0.4s; }

/* message */
.toast { min-height: 22px; text-align: center; font: 500 14px var(--font); letter-spacing: 0.02em; color: var(--muted); }
.toast.err { color: var(--right); font-weight: 600; }

/* keyboard: flat squares */
@supports not (container-type: size) {
  .tile { --size: min(60px, calc((100vw - 60px) / 5), calc((100dvh - 410px) / 7)); }
}
.kb { display: flex; flex-direction: column; gap: calc(6px * var(--u)); user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.kr { display: flex; gap: 5px; justify-content: center; }
.k {
  flex: 1; max-width: 50px; height: calc(52px * var(--u)); border: 2px solid var(--rule); background: var(--key);
  font: 600 calc(18px * var(--u)) var(--font); text-transform: uppercase; padding: 0;
}
.k:active { background: var(--ink); color: var(--bg); }
.k.wide { max-width: 76px; flex: 1.6; font: 600 12px var(--font); letter-spacing: 0.12em; }
.k.in { background: var(--gold); color: var(--on-gold); }
/* Ruled-out keys fade back: no border, faint letter. */
.k.out { background: var(--key-out); color: var(--key-out-ink); border-color: transparent; }

/* sheets: a square panel with a red-yellow-blue band across the top */
.ov { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; background: rgba(20, 20, 20, 0.55); }
.ov[hidden] { display: none; }
.sheet {
  width: 100%; max-width: 500px; max-height: 92dvh; overflow-y: auto; background: var(--panel); color: var(--ink);
  border: 3px solid var(--rule); border-bottom: 0; padding: 0 20px max(22px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 16px; animation: rise 0.25s ease-out;
}
.sheet::before {
  content: ""; display: block; height: 10px; margin: 0 -20px 6px; flex: none;
  background: linear-gradient(90deg, var(--right) 0 33.3%, var(--gold) 33.3% 66.6%, var(--left) 66.6%);
}
@media (min-width: 640px) { .ov { align-items: center; } .sheet { border-bottom: 3px solid var(--rule); } }
.sheet h2 { margin: 0; font: 700 32px/1.05 var(--font); letter-spacing: -0.02em; text-transform: lowercase; }
.sheet p { margin: 0; line-height: 1.5; }
.sheet .sub { color: var(--muted); font-size: 14px; }
.legend { display: grid; grid-template-columns: 30px 1fr; gap: 8px 12px; align-items: center; font-size: 15px; }
.sw { width: 30px; height: 30px; border: 2px solid var(--rule); position: relative; overflow: hidden; }
.examples { display: flex; flex-direction: column; gap: 6px; }
.examples .tile { --size: 44px; }
.examples .row { justify-content: flex-start; }
.answers { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chip { font: 700 26px/1 var(--font); padding: 8px 12px 10px; border: 3px solid var(--rule); color: #fff; letter-spacing: 0.08em; }
.chip-l { background: var(--left); } .chip-r { background: var(--right); }
.vs { width: 14px; height: 14px; border-radius: 50%; background: var(--gold); font-size: 0; border: 2px solid var(--rule); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); border: 3px solid var(--rule); }
.stat { padding: 10px 4px; text-align: center; }
.stat + .stat { border-left: 3px solid var(--rule); }
.stat b { display: block; font: 700 28px/1.05 var(--font); font-variant-numeric: tabular-nums; }
.stat span { font: 500 10px var(--font); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.dist { display: flex; flex-direction: column; gap: 4px; }
.bar { display: grid; grid-template-columns: 16px 1fr; gap: 8px; align-items: center; font: 600 13px var(--font); }
.bar i { display: block; font-style: normal; text-align: right; padding: 2px 8px; background: var(--faint); min-width: 26px; }
.bar i.me { background: var(--left); color: #fff; }
.grid-share { font: 18px/1.2 ui-monospace, monospace; letter-spacing: 1px; word-spacing: 10px; white-space: pre; text-align: center; }
.btn {
  border: 3px solid var(--rule); padding: 14px 16px; font: 600 17px var(--font); letter-spacing: 0.02em;
  background: var(--ink); color: var(--bg); width: 100%;
}
.btn:hover { background: var(--right); color: #fff; }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover { background: var(--gold); color: var(--on-gold); }
a.btn { display: block; text-align: center; text-decoration: none; }
.btn[disabled] { opacity: 0.5; cursor: default; }
.btn.small { width: auto; padding: 10px 16px; font-size: 15px; }
.pair-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pair-btns .btn { font-size: 15px; padding: 12px 10px; }

/* archive */
.days { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; max-height: 46dvh; overflow-y: auto; padding: 2px; }
.day {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; padding: 10px 12px;
  border: 2px solid var(--rule); background: var(--bg); color: var(--ink); text-decoration: none;
}
.day:hover { background: var(--gold); color: var(--on-gold); }
.day b { font: 700 16px var(--font); }
.day span { font-size: 13px; color: var(--muted); }
.day i { font-style: normal; font-weight: 700; }
.day.won i { color: var(--left); } .day.lost i { color: var(--right); } .day.started i { color: var(--muted); }
.restore { display: grid; gap: 8px; border-top: 3px solid var(--rule); padding-top: 14px; }
.restore label { font: 500 13px var(--font); color: var(--muted); }
.restore div { display: flex; gap: 8px; }
.restore input {
  flex: 1; min-width: 0; font: 600 16px ui-monospace, monospace; letter-spacing: 0.06em; text-transform: uppercase; padding: 10px 12px;
  border: 2px solid var(--rule); border-radius: 0; background: var(--bg); color: var(--ink);
}
.restore .err { color: var(--right); font-size: 14px; min-height: 1em; }
.code { font: 600 15px ui-monospace, monospace; letter-spacing: 0.06em; }
.code.big { font-size: 26px; text-align: center; padding: 12px; border: 3px solid var(--rule); user-select: all; }
.next { text-align: center; font: 500 13px var(--font); color: var(--muted); letter-spacing: 0.06em; }
.next b { font: 700 17px var(--font); color: var(--ink); font-variant-numeric: tabular-nums; }
.crowd { margin: -4px 0 0; text-align: center; font: 500 13px var(--font); color: var(--muted); letter-spacing: 0.02em; }
.legal { text-align: center; font-size: 12px; color: var(--muted); }
.legal a, .sheet p a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.noscript { text-align: center; padding: 40px; }

/* privacy, terms and refund pages */
.legal-page { max-width: 680px; margin: 0 auto; padding: 28px 18px 48px; line-height: 1.6; }
.legal-page .back { color: var(--muted); font-size: 14px; }
.legal-page h1 { font: 700 40px/1.05 var(--font); text-transform: lowercase; margin: 18px 0 4px; padding-bottom: 12px; border-bottom: 3px solid var(--rule); }
.legal-page .updated { color: var(--muted); font-size: 14px; margin: 0 0 18px; }
.legal-page h2 { font: 700 20px var(--font); margin: 28px 0 6px; }
.legal-page ul { padding-left: 20px; }
.legal-page li { margin: 6px 0; }
.legal-page a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.legal-nav { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 40px; padding-top: 14px; border-top: 3px solid var(--rule); font-size: 14px; }
.legal-nav a { color: var(--muted); }

/* pre-launch and error screens */
.soon { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; grid-row: 2 / -1; }
.soon h2 { margin: 0; font: 700 36px/1.05 var(--font); text-transform: lowercase; }
.soon .clock { font: 700 46px var(--font); font-variant-numeric: tabular-nums; }

@keyframes flip { 0% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
@keyframes pop { 50% { transform: scale(1.08); } }
@keyframes drop { 0% { transform: scale(0.4); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes shake { 20% { transform: translateX(-7px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
