/* Drug Scrabble — a word game dictionary that also accepts brand-name drugs.
   Warm board-game chrome: cream page, wooden letter tiles, and one accent —
   prescription-bottle amber, close to the GeorgeMike orange. */

:root {
  --bg: #f6f1e7;
  --surface: #fffdf8;
  --ink: #2a2118;
  --ink-soft: #6b5f52;
  --line: #e4dccd;
  --accent: #d9552e; /* amber/orange; darkened to clear AA on the cream bg */
  --accent-soft: rgba(217, 85, 46, 0.1);
  --valid: #1f7a4a;
  --valid-soft: rgba(31, 122, 74, 0.1);
  --phony: #b3261e;
  --phony-soft: rgba(179, 38, 30, 0.1);

  --tile-top: #f6e3b8;
  --tile-bottom: #e8c98a;
  --tile-edge: #b8925a;
  --tile-ink: #2a2118;
  --tile-blank-top: #fbf6ea;
  --tile-blank-bottom: #efe5cf;

  --radius: 12px;
  --shadow: 0 1px 2px rgba(42, 33, 24, 0.06), 0 4px 16px rgba(42, 33, 24, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17130f;
    --surface: #221c16;
    --ink: #f3ebde;
    --ink-soft: #b3a796;
    --line: #3a3128;
    --accent: #ff8a5c;
    --accent-soft: rgba(255, 138, 92, 0.14);
    --valid: #5fd08f;
    --valid-soft: rgba(95, 208, 143, 0.12);
    --phony: #ff7a70;
    --phony-soft: rgba(255, 122, 112, 0.12);
    --tile-blank-top: #3a3128;
    --tile-blank-bottom: #2e261f;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.3);
  }
}

* {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Nunito", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px calc(32px + env(safe-area-inset-bottom));
}

/* ---------- Masthead ---------- */
.masthead {
  text-align: center;
  margin: 8px 0 20px;
}
.wordmark {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 14px;
  margin-bottom: 12px;
}
.tagline {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}
.fineprint {
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

/* ---------- Tiles ---------- */
.tiles {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 3px;
  --t: 34px;
}
.tiles-sm {
  --t: 26px;
}
.tiles-lg {
  --t: 46px;
}
.tiles-xl {
  --t: clamp(30px, 9vw, 48px);
}
.tile {
  position: relative;
  width: var(--t);
  height: var(--t);
  border-radius: calc(var(--t) * 0.14);
  background: linear-gradient(180deg, var(--tile-top), var(--tile-bottom));
  box-shadow: inset 0 -2px 0 var(--tile-edge), 0 1px 2px rgba(0, 0, 0, 0.18);
  color: var(--tile-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.tile-letter {
  font-weight: 900;
  font-size: calc(var(--t) * 0.56);
  line-height: 1;
  margin-top: -2px;
}
.tile-value {
  position: absolute;
  right: calc(var(--t) * 0.09);
  bottom: calc(var(--t) * 0.07);
  font-size: calc(var(--t) * 0.24);
  font-weight: 800;
  line-height: 1;
}
.tile.is-blank {
  background: linear-gradient(180deg, var(--tile-blank-top), var(--tile-blank-bottom));
  color: var(--accent);
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  margin-bottom: 16px;
}
.tab {
  flex: 1;
  border: 0;
  background: none;
  color: var(--ink-soft);
  font: inherit;
  font-weight: 800;
  font-size: 0.95rem;
  padding: 9px 6px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.tab.is-active {
  background: var(--ink);
  color: var(--bg);
}

/* ---------- Inputs ---------- */
.text-input {
  width: 100%;
  font: inherit;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  outline: none;
}
#check-input,
#rack-input {
  text-transform: uppercase;
}
#check-input::placeholder,
#rack-input::placeholder {
  text-transform: none;
}
.text-input::placeholder {
  color: var(--ink-soft);
  font-weight: 400;
  letter-spacing: 0;
}
.text-input:focus {
  border-color: var(--accent);
}
.text-input:disabled {
  opacity: 0.6;
}

.rack-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 2px;
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.toggle,
.select-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-weight: 700;
}
.toggle input {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}
.select-label select {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px 6px;
}
.summary {
  font-weight: 700;
}

/* ---------- Shared bits ---------- */
.loading,
.load-error,
.hint {
  text-align: center;
  color: var(--ink-soft);
  padding: 16px 8px;
}
.load-error {
  color: var(--phony);
}
.link-button {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}
.chip {
  display: inline-block;
  font: inherit;
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 0.03em;
  padding: 4px 10px;
  margin: 3px 2px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.chip:hover {
  border-color: var(--accent);
}
.chip-inline {
  margin: 0 1px;
  padding: 1px 8px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-top: 12px;
}
.points {
  font-weight: 900;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.rx-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
  font-size: 0.85rem;
  flex: none;
}
.rx-line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 12px;
}
.rx-text {
  padding-top: 1px;
}
.aside {
  margin-top: 8px;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

/* ---------- Check ---------- */
.check-results {
  margin-top: 4px;
}
.check-card.is-valid {
  border-left: 5px solid var(--valid);
}
.check-card.is-phony {
  border-left: 5px solid var(--phony);
}
.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-top: 12px;
}
.verdict {
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.85rem;
  padding: 3px 10px;
  border-radius: 999px;
}
.is-valid .verdict {
  color: var(--valid);
  background: var(--valid-soft);
}
.is-phony .verdict {
  color: var(--phony);
  background: var(--phony-soft);
}
.note {
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.challenge {
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-weight: 800;
}
.challenge.is-valid {
  color: var(--valid);
  background: var(--valid-soft);
}
.challenge.is-phony {
  color: var(--phony);
  background: var(--phony-soft);
}

/* ---------- Rack ---------- */
.callout {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  font-size: 0.95rem;
}
.play-row,
.drug-row {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.play-row:hover,
.drug-row:hover {
  background: var(--surface);
}
.play-row.is-drug {
  background: var(--accent-soft);
}
.play-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: none;
}
.play-meta .points {
  min-width: 2.2em;
  text-align: right;
}
.bingo {
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--valid);
}

/* ---------- Pharmacy ---------- */
.rx-of-the-day {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}
.eyebrow {
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 10px;
}
.drug-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.drug-brand {
  font-weight: 900;
}
.drug-generic {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

/* ---------- Rules + footer ---------- */
.rules {
  margin-top: 32px;
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.rules h2 {
  margin: 0 0 8px;
  font-size: 1rem;
  font-weight: 900;
}
.rules ul {
  margin: 0;
  padding-left: 20px;
}
.rules li {
  margin: 4px 0;
}
.footer {
  margin-top: 24px;
  text-align: center;
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.footer p {
  margin: 4px 0;
}

@media (max-width: 420px) {
  .tab {
    font-size: 0.82rem;
  }
  .tiles-lg {
    --t: 38px;
  }
}
