/* Colour carries meaning on the strip: a tile's colour says which of your words it
   went into. So unplayed tiles are all one cream "card" colour, the selection is a
   pink no word uses, and the liveliness comes from everything around them. */
:root {
  --bg: #f6f0e4;
  --glow-a: rgb(59 111 216 / .16); --glow-b: rgb(236 72 153 / .14); --glow-c: rgb(231 180 35 / .18);
  --surface: #fffaf2;
  --ink: #1f1c24;
  --muted: #6a6274;
  --line: #ddd3c4;
  --tile: #fffdf8;
  --tile-ink: #1f1c24;
  --tile-edge: #d6c8b2;
  --pop: linear-gradient(135deg, #ff5fa2, #d6257a);
  --pop-edge: #a8155c;
  --pop-ink: #fff;
  --c0: #3b6fd8; --c1: #e0533d; --c2: #e7b423; --c3: #2f9e5b; --c4: #8a55c9; --c5: #ec8a2c;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1430; --surface: #261e40; --ink: #f3eefb; --muted: #a99fbe; --line: #3a3156;
    --glow-a: rgb(91 140 240 / .30); --glow-b: rgb(236 72 153 / .26); --glow-c: rgb(240 197 62 / .18);
    --tile: #fbf5ea; --tile-ink: #1f1c24; --tile-edge: #b9ab95;
    --c0: #5b8cf0; --c1: #f06b54; --c2: #f0c53e; --c3: #46b874; --c4: #a874e0; --c5: #f5a04f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1a1430; --surface: #261e40; --ink: #f3eefb; --muted: #a99fbe; --line: #3a3156;
  --glow-a: rgb(91 140 240 / .30); --glow-b: rgb(236 72 153 / .26); --glow-c: rgb(240 197 62 / .18);
  --tile: #fbf5ea; --tile-ink: #1f1c24; --tile-edge: #b9ab95;
  --c0: #5b8cf0; --c1: #f06b54; --c2: #f0c53e; --c3: #46b874; --c4: #a874e0; --c5: #f5a04f;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans);
  min-height: 100dvh; -webkit-tap-highlight-color: transparent; position: relative; isolation: isolate;
}
/* Soft coloured glows behind everything (a fixed layer, since iOS ignores fixed backgrounds). */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60vmax 45vmax at 0% 0%, var(--glow-a), transparent 70%),
    radial-gradient(55vmax 45vmax at 100% 18%, var(--glow-b), transparent 70%),
    radial-gradient(70vmax 50vmax at 50% 100%, var(--glow-c), transparent 70%);
}
button { font: inherit; color: inherit; cursor: pointer; }

/* Credit at the left, the tile title and tagline in the middle, buttons at the right. */
.top {
  display: grid; grid-template-columns: 1fr auto 1fr; grid-template-areas: "brand title actions";
  align-items: start; gap: 12px;
  padding: max(12px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px));
}
.brand-wrap { grid-area: brand; }
.title { grid-area: title; }
.actions { grid-area: actions; justify-self: end; }
.actions { display: flex; gap: 8px; align-items: center; flex: none; }
.lang {
  appearance: none; -webkit-appearance: none; height: 40px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23888' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 11px center / 9px;
  color: var(--ink); font: 700 .85rem var(--sans); letter-spacing: .04em; padding: 0 26px 0 13px; cursor: pointer;
}
/* Logo at the left with the credit and "All apps" beside it. */
.brand-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-wrap .logo { display: block; flex: none; width: 2.25rem; height: 2.25rem; border-radius: 8px; }
.credit { margin: 0; font-size: 0.72rem; line-height: 1.4; color: var(--muted); }
/* The title, spelled on little cards one per word colour, with the tagline under it. */
.title { display: grid; justify-items: center; text-align: center; }
.wordmark { display: flex; gap: 4px; margin: 2px 0 0; line-height: 1; }
.wordmark .L {
  display: grid; place-items: center; width: 1.9rem; height: 2.5rem; border-radius: 6px;
  font: 800 1.65rem/1 var(--serif); color: #fff; box-shadow: 0 2px 0 rgb(0 0 0 / .18);
  transform: rotate(var(--r, 0deg)) translateY(var(--y, 0));
}
.wordmark .L.c2 { color: #2a2205; }
.wordmark .L:nth-child(1) { --r: -8deg; --y: 1px; }  .wordmark .L:nth-child(2) { --r: 4deg; --y: -2px; }
.wordmark .L:nth-child(3) { --r: -3deg; }            .wordmark .L:nth-child(4) { --r: 6deg; --y: -1px; }
.wordmark .L:nth-child(5) { --r: -5deg; --y: 1px; }  .wordmark .L:nth-child(6) { --r: 7deg; }
.tagline { margin: 12px 0 0; max-width: 54ch; font-size: 0.95rem; color: var(--muted); text-wrap: balance; }
/* Narrower screens: credit and buttons share the top row, the title gets its own row below. */
@media (max-width: 640px) {
  .top { grid-template-columns: 1fr auto; grid-template-areas: "brand actions" "title title"; row-gap: 14px; padding-inline: 12px; }
  .wordmark .L { width: 1.7rem; height: 2.25rem; font-size: 1.45rem; }
}
/* The narrowest phones: drop the logo so the buttons keep their room. */
@media (max-width: 360px) {
  .brand-wrap .logo { display: none; }
}
.credit a { color: inherit; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface); font-weight: 700; display: grid; place-items: center;
}

main { max-width: 560px; margin: 0 auto; padding: 0 16px 48px; }
.meta { text-align: center; color: var(--muted); font-size: 0.9rem; margin: 28px 0 16px; }
.meta b { color: var(--ink); }
.meta #label {
  display: inline-block; padding: 3px 11px; border-radius: 999px; font-weight: 700; font-size: .85rem;
  color: var(--pop-ink); background: var(--pop); box-shadow: 0 2px 0 var(--pop-edge);
}
.dot { margin: 0 6px; }

.strip {
  --cols: 9;
  display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: 6px;
  container-type: inline-size;
}
@media (max-width: 440px) { .strip { --cols: 6; } }
.t {
  aspect-ratio: 3 / 4; border-radius: 9px; border: 1.5px solid var(--tile-edge);
  background: var(--tile); color: var(--tile-ink);
  font-family: var(--serif); font-weight: 600; font-size: clamp(1.3rem, 5vw, 1.7rem);
  text-transform: uppercase; display: grid; place-items: center; padding: 0;
  box-shadow: 0 3px 0 var(--tile-edge), 0 6px 14px rgb(0 0 0 / .10); position: relative; user-select: none;
  transition: transform .12s, background-color .25s, color .25s, opacity .2s, box-shadow .12s;
}
.t:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--tile-edge); }
.t.sel {
  background: var(--pop) border-box; color: var(--pop-ink); border-color: transparent;
  box-shadow: 0 3px 0 var(--pop-edge), 0 8px 18px rgb(214 37 122 / .35); transform: translateY(-4px);
}
/* Dealt in like cards when a puzzle opens. */
.t.deal { animation: deal .42s cubic-bezier(.2, .8, .3, 1.2) both; }
@keyframes deal { from { opacity: 0; transform: translateY(-18px) rotate(-8deg) scale(.85); } }
.t.behind { opacity: .45; }
.t.used { color: #fff; border-color: transparent; box-shadow: none; cursor: default; }
.t.used.c2 { color: #2a2205; }
.t.flip { animation: flip .45s both; }
@keyframes flip { 0% { transform: rotateY(0) } 50% { transform: rotateY(90deg) } 100% { transform: rotateY(0) } }
.t.hint::after {
  content: attr(data-len); position: absolute; top: -7px; right: -7px; min-width: 20px; height: 20px;
  border-radius: 10px; background: var(--c2); color: #2a2205; font: 700 .7rem/20px var(--sans); padding: 0 5px;
}
.t.hint:not(.used) { border-color: var(--c2); border-style: dashed; }
.c0 { background: var(--c0); } .c1 { background: var(--c1); } .c2 { background: var(--c2); }
.c3 { background: var(--c3); } .c4 { background: var(--c4); } .c5 { background: var(--c5); }

.entry { text-align: center; margin: 22px 0 8px; min-height: 76px; }
.word {
  font-family: var(--serif); font-weight: 800; font-size: 2.2rem; letter-spacing: .08em;
  text-transform: uppercase; min-height: 2.8rem; line-height: 2.8rem;
}
.word:empty::before { content: attr(data-placeholder); font-family: var(--sans); font-weight: 400; font-size: 1rem; letter-spacing: 0; text-transform: none; color: var(--muted); }
.word.shake { animation: shake .4s; }
@keyframes shake { 20%,60% { transform: translateX(-8px) } 40%,80% { transform: translateX(8px) } }
.msg { color: var(--muted); font-size: .9rem; min-height: 1.3rem; }

.controls { display: flex; gap: 10px; justify-content: center; }
.btn {
  border: 1.5px solid var(--ink); background: transparent; border-radius: 999px;
  padding: 11px 20px; font-weight: 600; min-width: 64px;
}
/* background-origin: border-box stops the gradient repeating into the transparent border as a seam. */
.btn.primary { background: var(--pop) border-box; color: var(--pop-ink); border-color: transparent; box-shadow: 0 3px 0 var(--pop-edge); }
.btn.wide { width: 100%; margin-top: 8px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary:disabled { opacity: .6; box-shadow: none; }

.found { list-style: none; padding: 0; margin: 22px 0 0; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.found li {
  display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 5px 6px 5px 14px;
  color: #fff; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; font-size: .95rem;
  animation: pop .3s;
}
.found li.c2 { color: #2a2205; }
/* Before you find them: where your first three words will land, in their colours. */
.found li.slot {
  width: 5.2rem; height: 34px; padding: 0; background: transparent; animation: none; justify-content: center;
  border: 2px dashed var(--slot); background-color: color-mix(in srgb, var(--slot) 14%, transparent);
  color: color-mix(in srgb, var(--slot) 70%, var(--ink)); font-size: .78rem; letter-spacing: .04em; text-transform: none;
}
.found li.slot.c0 { --slot: var(--c0); } .found li.slot.c1 { --slot: var(--c1); } .found li.slot.c2 { --slot: var(--c2); }
.found li.slot.c3 { --slot: var(--c3); } .found li.slot.c4 { --slot: var(--c4); } .found li.slot.c5 { --slot: var(--c5); }
.found li button { border: 0; background: rgb(0 0 0 / .18); color: inherit; width: 24px; height: 24px; border-radius: 50%; line-height: 1; font-size: 1rem; }
@keyframes pop { from { transform: scale(.6); opacity: 0 } }

.aux { display: flex; justify-content: center; gap: 22px; margin-top: 22px; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; padding: 6px; font-size: .9rem; }
.link:disabled { opacity: .4; text-decoration: none; cursor: default; }

.done { margin-top: 26px; padding: 22px 18px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); text-align: center; animation: pop .4s; }
.done h2 { font-family: var(--serif); font-weight: 800; font-size: 1.8rem; margin: 0 0 4px; }
.done p { margin: 0; color: var(--muted); }
.secret { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 16px 0; }
.secret span { font-family: var(--serif); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; padding: 4px 10px; border: 1px solid var(--line); border-radius: 8px; }
.share-text { font-family: var(--sans); white-space: pre-wrap; font-size: 1.05rem; margin: 0 0 16px; line-height: 1.4; }
.done-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.next-daily { margin-top: 14px !important; font-size: .85rem; }

dialog.sheet {
  border: 0; border-radius: 20px; padding: 24px 22px; max-width: min(440px, calc(100vw - 32px));
  background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgb(0 0 0 / .3);
}
dialog::backdrop { background: rgb(10 8 16 / .45); }
.sheet h2 { font-family: var(--serif); font-weight: 800; margin: 0 0 10px; font-size: 1.6rem; }
.sheet h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 20px 0 8px; }
.sheet ul { padding-left: 20px; } .sheet li { margin-bottom: 6px; }
.sheet p, .sheet li { line-height: 1.45; }
.close { position: absolute; top: 10px; right: 12px; border: 0; background: none; font-size: 1.6rem; color: var(--muted); }
.example { display: flex; gap: 6px; justify-content: center; margin: 14px 0 4px; }
.example .t { width: 40px; color: #fff; border-color: transparent; box-shadow: none; font-size: 1.3rem; }
.caption { text-align: center; color: var(--muted); font-size: .85rem; margin-top: 2px; }

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; gap: 6px; }
.stat-row b { display: block; font-family: var(--serif); font-size: 1.8rem; }
.stat-row span { font-size: .75rem; color: var(--muted); }
.dist { display: grid; gap: 5px; }
.dist .r { display: grid; grid-template-columns: 2.4rem 1fr; align-items: center; gap: 8px; font-size: .85rem; }
.dist .bar { background: var(--line); color: var(--ink); border-radius: 4px; padding: 2px 8px; text-align: right; font-weight: 700; min-width: 26px; }
.dist .bar.on { background: var(--c3); color: #fff; }

.toast {
  position: fixed; left: 50%; top: 18px; transform: translate(-50%, -20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 600;
  transition: opacity .2s, transform .2s; z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Copyright notice at the foot of the page. */
.copyright { margin: 0; padding: 1.5rem 1rem calc(1.5rem + env(safe-area-inset-bottom, 0px)); text-align: center; font-size: 0.8rem; color: var(--muted); }

/* Back to the list of all of Marc's apps, on its own line under the credit. */
.apps-link { display: block; inline-size: fit-content; margin-block-start: 0.15rem; white-space: nowrap; }
.apps-link svg { display: inline; inline-size: 1.05em; block-size: 1.05em; margin-inline-end: 0.25em; vertical-align: -0.18em; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* Settings: the language picker fills the row; Appearance is a three-way switch. */
#settings .lang { inline-size: 100%; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: 999px; background: var(--bg); }
.segmented label { position: relative; display: grid; }
.segmented input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.segmented span { display: grid; place-items: center; min-block-size: 2.5rem; padding: 0 .4rem; border-radius: 999px; font-weight: 700; font-size: .92rem; color: var(--muted); }
.segmented input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgb(0 0 0 / .15); }
.segmented input:focus-visible + span { outline: 3px solid var(--c0); outline-offset: 1px; }
