/* The colours of `Theme.swift`. The page sets data-theme once it knows the player's choice. */
:root {
  --key: #DDD5C8; --filled-border: #8E877C; --bg: #F3EEE6; --blue: #2F5DA8; --yellow: #E9B422;
  --card: #FBF8F2; --card-line: #D3CBBD; --muted: #5F594F; --faded: #B1AA9E;
  --marker-blue: #2F5DA8; --marker-grey: #A39C90; --marker-current: #2B2824; --ink: #22201C;
  --card-top: #FFFEFB; --card-bottom: #F2ECE1; --card-rim: rgba(255,255,255,.9); --card-shadow: rgba(90,74,48,.22);
  --panel: #EAE4D8; --text: #000; --secondary: rgba(60,60,67,.65); --accent: #2F5DA8; --bar-button: #FCFAF5;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --key: #6E6A65; --filled-border: #77726C; --bg: #171615; --blue: #7FA2E6; --yellow: #E2B53E;
  --card: #2A2826; --card-line: #47433E; --muted: #B0AAA0; --faded: #6E6A64;
  --marker-blue: #3D6CC0; --marker-grey: #5A5651; --marker-current: #EDE7DC; --ink: #22201C;
  --card-top: #3A3733; --card-bottom: #22201E; --card-rim: rgba(255,255,255,.16); --card-shadow: rgba(0,0,0,.85);
  --panel: #201F1D; --text: #fff; --secondary: rgba(235,235,245,.62); --accent: #6C97E4; --bar-button: #2C2B2A;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font: 17px/1.35 -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
a { color: var(--accent); }
.rounded, h1, .tile, .key, .marker, .answer, .round { font-family: ui-rounded, -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, sans-serif; }

/* The game sits in a centred column; the background runs to the screen's edges. */
.column { width: 100%; max-width: 500px; margin: 0 auto; }
#game {
  position: relative; display: flex; flex-direction: column; height: 100vh; height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  user-select: none; -webkit-user-select: none; overflow: hidden auto;
}
@media (pointer: coarse) {
  * { scrollbar-width: none; }
  *::-webkit-scrollbar { display: none; }
}

/* Header */
header { display: grid; grid-template-columns: 42px 1fr 42px; align-items: center; gap: 4px; padding: 6px 18px 0; }
.titles { text-align: center; min-width: 0; }
h1 { margin: 0; font-size: 30px; line-height: 1.2; font-weight: 800; letter-spacing: 1px; }
.titles p { margin: 0; font-size: 12px; line-height: 1.4; font-weight: 500; color: var(--muted); white-space: nowrap; overflow: hidden; font-variant-numeric: tabular-nums; }
.card-surface {
  background: linear-gradient(var(--card-top), var(--card-bottom));
  box-shadow: inset 0 1.5px 0 var(--card-rim), 0 calc(2.5px * var(--depth, 1)) calc(6px * var(--depth, 1)) var(--card-shadow);
}
.round {
  width: 42px; height: 42px; border-radius: 21px; border: 1px solid var(--card-line); padding: 0;
  display: grid; place-items: center; font-size: 20px; font-weight: 700;
  background: linear-gradient(var(--card-top), var(--card-bottom));
  box-shadow: inset 0 1.5px 0 var(--card-rim), 0 2.5px 6px var(--card-shadow);
}
.round:active { transform: scale(.92); opacity: .75; }
.round svg { width: 21px; height: 21px; }

/* Word markers */
.picker { display: flex; justify-content: center; gap: 12px; padding: 10px; }
.pick { border: 0; background: none; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.marker {
  position: relative; width: 38px; height: 38px; border-radius: 10.6px; display: grid; place-items: center;
  font-size: 17px; font-weight: 700; background: var(--key); color: var(--text);
  box-shadow: inset 0 1.5px 0 var(--card-rim), 0 2.5px 6px var(--card-shadow); transition: transform .25s;
}
.marker::before { content: ""; position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(rgba(255,255,255,.22), transparent, rgba(0,0,0,.14)); }
.marker > * { position: relative; }
.marker svg { width: 20px; height: 20px; }
.pick.won .marker { background: var(--marker-blue); color: #fff; }
.pick.lost .marker { background: var(--marker-grey); color: #fff; }
.pick.started .marker { background: var(--yellow); color: var(--ink); }
.pick.selected .marker { transform: scale(1.1); }
.pick.selected .marker::after { content: ""; position: absolute; inset: -5px; border: 2.5px solid var(--marker-current); border-radius: 14.6px; }
.pick small { font-size: 10px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.pick.selected small { font-weight: 700; color: var(--text); }

/* Board */
#board-area { flex: 1 0 0; min-height: 136px; padding: 0 24px 10px; display: flex; align-items: center; justify-content: center; touch-action: none; }
#board { display: flex; flex-direction: column; gap: 6px; }
.row { display: flex; gap: 6px; }
.row.shake { animation: shake .4s linear; }
@keyframes shake {
  0%, 50%, 100% { transform: translateX(0); }
  12.5%, 62.5% { transform: translateX(8px); }
  37.5%, 87.5% { transform: translateX(-8px); }
}
.tile {
  --side: 52px; --depth: 1; position: relative; flex: none; overflow: hidden; display: grid; place-items: center;
  width: var(--side); height: var(--side); border-radius: calc(var(--side) * .21);
  font-size: calc(var(--side) * .5); line-height: 1; font-weight: 700; text-transform: uppercase;
  border: 1px solid var(--card-line);
  background: linear-gradient(var(--card-top), var(--card-bottom));
  box-shadow: inset 0 1.5px 0 var(--card-rim), 0 calc(2.5px * var(--depth)) calc(6px * var(--depth)) var(--card-shadow);
}
.tile.filled { border: 2px solid var(--filled-border); }
.tile.correct { border: max(2.5px, calc(var(--side) / 14)) solid var(--blue); }
.tile.present::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: max(4px, calc(var(--side) / 9)); background: var(--yellow); }
.tile.absent { border: 1px dashed var(--faded); background: none; box-shadow: none; color: var(--faded); }
.tile.reveal { animation: flip .3s ease-out both; }
@keyframes flip { from { transform: perspective(200px) rotateX(90deg); } to { transform: perspective(200px) rotateX(0); } }
.row.pending .tile { animation: wait 1s ease-in-out infinite alternate; }
@keyframes wait { to { opacity: .6; } }

/* Keyboard */
#bottom { padding: 0 4px 6px; }
#keyboard { position: relative; height: 214px; touch-action: none; }
.key {
  position: absolute; padding: 0; height: 46px; border-radius: 9px; display: grid; place-items: center; overflow: hidden;
  font-size: 19px; font-weight: 600; text-transform: uppercase; border: 1px solid var(--card-line);
  background: linear-gradient(var(--card-top), var(--card-bottom));
  box-shadow: inset 0 1.5px 0 var(--card-rim), 0 2.5px 6px var(--card-shadow);
  touch-action: none; -webkit-touch-callout: none;
}
.key.enter { text-transform: none; }
.key svg { width: 24px; height: 24px; }
.key.pressed { opacity: .55; transform: scale(.95); }
.key.correct { border: 2.5px solid var(--blue); }
.key.present::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--yellow); }
.key.absent { border: 1px dashed var(--faded); background: none; box-shadow: none; color: var(--faded); }
.bubble {
  position: absolute; z-index: 3; height: 54px; border-radius: 12px; display: grid; place-items: center; pointer-events: none;
  background: var(--card); border: 1px solid var(--card-line); box-shadow: 0 2px 12px rgba(0,0,0,.18);
  font-size: 30px; font-weight: 600; text-transform: uppercase;
}

/* A finished word */
#result { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 12px 0; text-align: center; }
#result p { margin: 0; }
.result-title { font-size: 15px; color: var(--secondary); }
.answer { font-size: 30px; font-weight: 800; letter-spacing: 4px; text-transform: uppercase; user-select: text; -webkit-user-select: text; }
.goroh { display: inline-flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 500; text-decoration: none; }
.goroh svg { width: 18px; height: 18px; }
.meow { font-size: 20px; font-weight: 600; }
.stack { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; }
.button {
  width: 100%; max-width: 260px; min-height: 46px; border: 0; border-radius: 999px; padding: 10px 18px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 600; text-decoration: none;
  background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent);
}
.button svg { width: 19px; height: 19px; }
.button.prominent { background: var(--marker-blue); color: #fff; }
.button:disabled { opacity: .45; cursor: default; }
.button:active:not(:disabled) { opacity: .7; }
.offer { font-size: 13px; color: var(--muted); }

#toast {
  position: absolute; z-index: 4; left: 50%; top: calc(110px + env(safe-area-inset-top)); transform: translateX(-50%);
  max-width: calc(100% - 32px); width: max-content; padding: 10px 16px; border-radius: 999px; text-align: center;
  background: var(--text); color: var(--bg); font-weight: 600; pointer-events: none; animation: appear .2s ease-out;
}
@keyframes appear { from { opacity: 0; transform: translateX(-50%) scale(.9); } }

/* The iPhone app, offered on top */
#appbar { display: flex; align-items: center; gap: 10px; margin: 6px 12px 0; padding: 6px 8px 6px 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--card-line); }
#appbar p { margin: 0; flex: 1; min-width: 0; font-size: 12px; line-height: 1.3; color: var(--muted); }
#appbar a { flex: none; border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 700; text-decoration: none; background: var(--marker-blue); color: #fff; }
#appbar button { flex: none; border: 0; background: none; padding: 4px 6px; color: var(--muted); font-size: 20px; line-height: 1; }

/* Help and settings */
.sheet { position: fixed; inset: 0; z-index: 10; background: var(--bg); overflow-y: auto; overscroll-behavior: contain; animation: rise .3s ease-out; }
@keyframes rise { from { transform: translateY(100%); } }
.sheet:focus { outline: none; }
.sheet .column { padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: center; min-height: 64px; padding: env(safe-area-inset-top) 16px 0; background: var(--bg); }
.bar h2 { margin: 0; font-size: 17px; font-weight: 600; }
.bar-button { position: absolute; right: 16px; bottom: 12px; border: 0; border-radius: 999px; padding: 9px 16px; font-weight: 600; background: var(--bar-button); box-shadow: 0 2px 12px rgba(0,0,0,.14); }
.content { padding: 8px 16px 32px; display: flex; flex-direction: column; gap: 16px; }
.content p, .content h3 { margin: 0; }
.content h3 { font-size: 17px; margin-top: 4px; }
.small { font-size: 15px; }
.secondary { color: var(--secondary); }
.muted { color: var(--muted); }
.example { display: flex; flex-direction: column; gap: 6px; }
.tiles { display: flex; gap: 5px; }
.tiles .tile { --side: 44px; }
.panel { background: var(--panel); border-radius: 14px; }
.panel .picker { padding: 22px 10px; pointer-events: none; }
.share-example { display: block; width: 100%; max-width: 300px; height: auto; margin: 0 auto; border-radius: 12px; border: 1px solid var(--card-line); }
.about { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; font-size: 13px; color: var(--secondary); }
.about h3 { color: var(--text); }
.links { display: flex; flex-wrap: wrap; gap: 6px 16px; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; }
input[role="switch"] { appearance: none; -webkit-appearance: none; flex: none; position: relative; width: 51px; height: 31px; margin: 0; border-radius: 16px; background: rgba(120,120,128,.32); cursor: pointer; transition: background .2s; }
input[role="switch"]::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,.25); transition: transform .2s; }
input[role="switch"]:checked { background: var(--marker-blue); }
input[role="switch"]:checked::after { transform: translateX(20px); }
#preview-caption { font-weight: 500; margin-top: 4px; }
#key-preview { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 16px; border: 1px solid var(--card-line); }
#key-preview .row { gap: 5px; }
#key-preview .key { position: relative; flex: 1; }
.badge-block { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.badge-title { display: flex; align-items: center; gap: 8px; }
.badge-title svg { width: 20px; height: 20px; color: var(--accent); display: block; }
hr { width: 100%; border: 0; border-top: 1px solid var(--card-line); margin: 4px 0; }
.theme { padding: 14px; border-radius: 12px; }
.theme-button { width: 100%; display: flex; justify-content: space-between; align-items: center; border: 0; background: none; padding: 0; }
.theme-button span { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); }
.theme-button svg { width: 14px; height: 14px; transition: transform .2s; }
.theme-button[aria-expanded="true"] svg { transform: rotate(180deg); }
#theme-options { margin-top: 10px; border-radius: 12px; background: var(--card); border: 1px solid var(--card-line); overflow: hidden; }
#theme-options button { width: 100%; height: 44px; display: flex; justify-content: space-between; align-items: center; padding: 0 14px; border: 0; background: none; }
#theme-options button + button { border-top: 1px solid var(--card-line); }
#theme-options svg { width: 16px; height: 16px; color: var(--accent); }

.dialog { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 24px; background: rgba(0,0,0,.35); }
.dialog-card { width: 100%; max-width: 300px; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 20px; border-radius: 26px; background: var(--card); text-align: center; }
.dialog-card h2 { margin: 0; font-size: 17px; }
.dialog-card p { margin: 0 0 6px; font-size: 15px; }

.noscript { position: fixed; inset: auto 0 0; text-align: center; padding: 16px; }

/* A phone's browser bars take height from the game: on short screens the top and the result get tighter, so the
   board keeps its size. */
@media (max-height: 620px) {
  header { padding-top: 2px; }
  h1 { font-size: 24px; }
  .round { width: 36px; height: 36px; }
  header { grid-template-columns: 36px 1fr 36px; }
  .picker { gap: 11px; padding: 6px 10px; }
  .pick { gap: 3px; }
  .marker { width: 32px; height: 32px; border-radius: 9px; font-size: 15px; }
  .pick.selected .marker::after { inset: -4px; border-radius: 12px; }
  #board-area { padding-bottom: 4px; }
  #bottom { padding-bottom: 2px; }
  #result { gap: 7px; padding: 4px 0; }
  #result .answer { font-size: 24px; }
  #result .button { min-height: 38px; padding: 6px 16px; }
  #result .stack { gap: 6px; }
  #appbar { margin-top: 3px; padding: 2px 6px 2px 10px; }
  #appbar p { font-size: 11px; line-height: 1.2; }
  #appbar a { padding: 4px 10px; font-size: 12px; }
  #appbar button { padding: 2px 4px; font-size: 18px; }
}

/* Text pages: privacy, terms, support, licences, rules. */
body.page { overflow: auto; }
.page main { max-width: 40rem; margin: 0 auto; padding: calc(24px + env(safe-area-inset-top)) 16px 48px; line-height: 1.55; }
.page h1 { font-size: 26px; letter-spacing: 0; line-height: 1.3; }
.page h2 { font-size: 20px; margin-top: 28px; }
.page .updated { color: var(--muted); font-size: 14px; }
.page footer { margin-top: 32px; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 15px; }
@media (prefers-color-scheme: dark) {
  /* The text pages have no scripts: they follow the phone. */
  body.page { --bg: #171615; --text: #fff; --muted: #B0AAA0; --accent: #6C97E4; --card-line: #47433E; background: var(--bg); color: var(--text); }
  html:has(body.page) { background: #171615; }
}
