/* Seven of Tiles
   Cobalt tiles on cool porcelain. The tiles are the one bold thing;
   everything around them stays flat and quiet. */

:root {
  --porcelain: #eceff3;
  --porcelain-deep: #dfe3ea;
  --ink: #232838;
  --ink-soft: #5a6072;
  --cobalt: #2442a8;
  --cobalt-edge: #16297a;
  --cobalt-pale: #c9d3f2;
  --frost: #f5f7fc;
  --kingfisher: #0b8f9c;
  --rosehip: #b8324a;

  --tile-font: "Futura PT", Futura, "Avenir Next", "URW Gothic", "Century Gothic", "Nunito", ui-rounded, system-ui, sans-serif;
  --text-font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --gap: 0.5rem;
  --edge: 4px;
  --quick: 80ms;
  --brief: 120ms;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--porcelain);
  color: var(--ink);
  font: 1rem/1.4 var(--text-font);
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }
.no-js .app { display: none; }

button, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--kingfisher); outline-offset: 2px; }

/* No-JS page */
.nojs { max-width: 34rem; margin: 0 auto; padding: 2rem 1.25rem; }
.nojs h1 { font: 800 2rem/1.1 var(--tile-font); color: var(--cobalt); margin: 0 0 1rem; }
.nojs p { max-width: 60ch; }

/* App column: full height on phones, centred column on desktop. */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 30rem;
  margin: 0 auto;
  padding: max(0.5rem, env(safe-area-inset-top)) max(0.25rem, env(safe-area-inset-right)) max(0.75rem, env(safe-area-inset-bottom)) max(0.25rem, env(safe-area-inset-left));
}

/* Header */
.bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 0.5rem;
}
.title {
  margin: 0;
  font: 800 1.25rem/2.75rem var(--tile-font);
  letter-spacing: 0.02em;
  color: var(--cobalt);
}
.settings { text-align: right; }
.settings summary {
  list-style: none;
  min-height: 2.75rem;
  padding: 0 0.25rem;
  line-height: 2.75rem;
  color: var(--ink-soft);
  cursor: pointer;
}
.settings summary::-webkit-details-marker { display: none; }
.settings[open] summary { color: var(--ink); }
.settings-body {
  display: grid;
  gap: 0.5rem;
  padding: 0.25rem 0 0.75rem;
  text-align: left;
}
.settings-body label {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink-soft);
  font-size: 0.9375rem;
}
.settings-body select {
  min-height: 2.75rem;
  padding: 0 0.5rem;
  border: 1px solid var(--porcelain-deep);
  border-radius: 6px;
  background: var(--frost);
}

.loading, .load-error { margin: auto; text-align: center; color: var(--ink-soft); }
.load-error p { margin: 0 0 0.75rem; color: var(--ink); }
.load-error button {
  min-height: 2.75rem;
  padding: 0 1.25rem;
  border: 0;
  border-radius: 6px;
  background: var(--cobalt);
  color: var(--frost);
}

/* Play area: words float at the top, the board sits in the thumb zone. */
.play {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-height: 0;
}

.status {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0 1rem;
  padding: 0 0.5rem;
  font-size: 0.9375rem;
}
.progress { margin: 0; font-weight: 600; }
.bag { margin: 0; color: var(--ink-soft); }

/* Found words (and the reveal): a flowing line of words, not cards. */
.words {
  flex: 1 1 auto;
  min-height: 2rem;
  max-height: 40dvh;
  overflow-y: auto;
  margin: 0;
  padding: 0 0.5rem;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 0.25rem 1rem;
  font: 700 1.0625rem/1.6 var(--tile-font);
  letter-spacing: 0.08em;
}
.words li.is-found { color: var(--ink); }
.words.is-revealed li.is-found { color: var(--kingfisher); }
.words.is-revealed li.is-missed { color: var(--ink-soft); font-weight: 500; }
.words .l.is-blank { text-decoration: underline dotted 2px; text-underline-offset: 3px; }

.hint {
  margin: 0;
  padding: 0 0.5rem;
  min-height: 1.75rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
  color: var(--ink-soft);
}
.hint b { font: 800 1.125rem/1 var(--tile-font); color: var(--cobalt); margin: 0 0.2em; }
.hint-pattern { display: inline-flex; gap: 3px; margin-right: 0.25rem; }
.hint-pattern .h {
  width: 1.5rem;
  height: 1.75rem;
  display: grid;
  place-items: center;
  border-bottom: 2px solid var(--cobalt);
  font: 800 1.0625rem/1 var(--tile-font);
  color: var(--cobalt);
}
.hint-pattern .h.is-hidden { border-bottom-color: var(--cobalt-pale); }

.feedback {
  margin: 0;
  padding: 0 0.5rem;
  min-height: 1.4em;
  font-size: 0.9375rem;
  color: var(--ink-soft);
}
.feedback.good { color: var(--kingfisher); font-weight: 600; }
.feedback.bad { color: var(--rosehip); }

/* Rows of seven. Each button fills its whole column so the touch target
   stays at least 44px wide even on a 320px screen; the face is inset. */
.entry, .rack {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

/* Entry: a recessed tray the tiles drop into. */
.entry {
  padding: 2px;
  border-radius: 10px;
  background: var(--porcelain-deep);
  box-shadow: inset 0 2px 3px rgb(35 40 56 / 0.12);
}
.slot {
  min-height: 3rem;
  padding: 2px;
  border: 0;
  background: none;
}
.slot .face {
  display: grid;
  place-items: center;
  height: 100%;
  min-height: 2.75rem;
  border-radius: 6px;
  font: 800 1.5rem/1 var(--tile-font);
}
.slot.is-filled .face { background: var(--cobalt); color: var(--frost); }
.slot.is-blank .face { background: var(--cobalt-pale); color: var(--cobalt-edge); font-style: italic; }
.entry.shake { animation: shake var(--brief) linear; }
.entry.accept { animation: accept var(--brief) ease-out; }

/* The rack: chunky cobalt blocks with a real edge. */
.rack { padding: 0 0 var(--edge); }
.tile {
  min-height: 3.75rem;
  padding: 3px;
  border: 0;
  background: none;
}
.tile .face {
  display: grid;
  place-items: center;
  height: 100%;
  min-height: 3.25rem;
  border-radius: 8px;
  background: var(--cobalt);
  color: var(--frost);
  box-shadow: 0 var(--edge) 0 var(--cobalt-edge);
  font: 800 1.875rem/1 var(--tile-font);
  transition: transform var(--quick) ease-out, box-shadow var(--quick) ease-out, opacity var(--quick);
}
.tile:active .face { transform: translateY(3px); box-shadow: 0 1px 0 var(--cobalt-edge); }
.tile.is-blank .face { background: var(--frost); box-shadow: 0 var(--edge) 0 var(--cobalt-pale), inset 0 0 0 2px var(--cobalt-pale); }
.tile.is-choosing .face { box-shadow: 0 var(--edge) 0 var(--cobalt-pale), inset 0 0 0 3px var(--kingfisher); }
/* A used tile leaves its outline behind. */
.tile.is-used .face {
  background: transparent;
  color: transparent;
  box-shadow: inset 0 0 0 2px var(--cobalt-pale);
  transform: translateY(var(--edge));
}

/* Inline letter strip for a blank (never a modal). */
.blank-strip {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 3px;
}
.blank-strip button {
  min-height: 2.75rem;
  border: 0;
  border-radius: 6px;
  background: var(--frost);
  box-shadow: inset 0 0 0 1px var(--cobalt-pale);
  font: 800 1.125rem/1 var(--tile-font);
  color: var(--cobalt);
}
.blank-strip .pick-cancel { grid-column: span 1; font: 0.8125rem/1 var(--text-font); color: var(--ink-soft); }

/* Controls */
.controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.375rem;
}
.controls button {
  min-height: 2.75rem;
  border: 0;
  border-radius: 8px;
  background: var(--frost);
  box-shadow: inset 0 0 0 1px var(--porcelain-deep);
  font-size: 0.9375rem;
}
.controls button:active:not(:disabled) { background: var(--porcelain-deep); }
.controls button:disabled { color: var(--ink-soft); opacity: 0.5; }
.controls button.primary { background: var(--ink); color: var(--frost); box-shadow: none; font-weight: 600; }
.controls button.primary:disabled { background: var(--frost); color: var(--ink-soft); box-shadow: inset 0 0 0 1px var(--porcelain-deep); font-weight: 400; }

.countdown { display: flex; align-items: center; gap: 0.75rem; }
.countdown-bar {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--cobalt);
  transform-origin: left center;
}
.countdown button {
  min-height: 2.75rem;
  padding: 0 1rem;
  border: 0;
  background: none;
  color: var(--cobalt);
  font-weight: 600;
}

.notice { margin: 0; text-align: center; color: var(--cobalt); font-weight: 600; font-size: 0.9375rem; }

@keyframes shake {
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
@keyframes accept {
  from { background: rgb(11 143 156 / 0.35); }
}

/* Wider screens: six controls in a row, bigger tiles. */
@media (min-width: 30rem) {
  .controls { grid-template-columns: repeat(6, 1fr); }
  .tile { min-height: 4.25rem; }
  .tile .face { min-height: 3.75rem; font-size: 2.125rem; }
}
@media (min-width: 48rem) {
  .app { padding-top: 2rem; padding-bottom: 2rem; min-height: auto; }
  .play { flex: none; }
  .words { min-height: 6rem; }
}

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