/* ── tokens ───────────────────────────────────────────── */
:root {
  --bg:            #0a0f0f;
  --bg-raised:     #141b1b;
  --card:          #0f5f5a;
  --card-hi:       #14746d;
  --card-done:     #101919;
  --ink:           #f2f7f6;
  --ink-dim:       #9fb3b0;
  --ink-faint:     #6d817e;
  --accent:        #7fe3d8;
  --accent-deep:   #0d3f3b;
  --danger:        #ff8f7a;
  --line:          #223030;

  --r-card:  14px;
  --r-pill:  999px;
  --pad:     20px;

  --serif: ui-serif, Georgia, "Times New Roman", serif;
  --sans:  -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ── reset ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  overflow-x: hidden;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  padding-bottom: env(safe-area-inset-bottom);
}

.hidden { display: none !important; }

/* ── top bar ──────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px var(--pad);
  padding-top: calc(14px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}
.topbar-title {
  flex: 1;
  margin: 0;
  text-align: center;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.2px;
}
.topbar-spacer { width: 40px; flex: none; }

.iconbtn {
  width: 40px; height: 40px;
  flex: none;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--ink);
  color: var(--bg);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: transform .12s ease, opacity .12s ease;
}
.iconbtn:active { transform: scale(.92); }

/* ── layout ───────────────────────────────────────────── */
.pad { padding: var(--pad); padding-bottom: 48px; }

.lede {
  font-family: var(--serif);
  font-size: 27px;
  line-height: 1.18;
  font-weight: 700;
  margin: 8px 0 6px;
  letter-spacing: -0.4px;
}
.sub    { margin: 0 0 22px; color: var(--ink-dim); font-size: 15.5px; }
.center { text-align: center; }

.rule { border: 0; border-top: 1px solid var(--line); margin: 28px 0 20px; }

.section-h {
  font-family: var(--serif);
  font-size: 19px;
  margin: 0 0 16px;
}

/* ── buttons ──────────────────────────────────────────── */
.btn {
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  padding: 15px 22px;
  border-radius: var(--r-pill);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: transform .12s ease, filter .12s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active   { transform: scale(.97); }
.btn-block    { display: block; width: 100%; margin-top: 12px; }
.btn-primary  { background: var(--accent); color: #06201e; }
.btn-primary:hover { filter: brightness(1.07); }
.btn-ghost    { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-ghost:hover { background: rgba(127,227,216,.09); }
.btn-quiet    { background: transparent; color: var(--ink-faint); border-color: transparent; }
.btn-quiet:hover { color: var(--ink-dim); }

.btnrow {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

/* ── forms ────────────────────────────────────────────── */
.field { margin-bottom: 20px; }
.field > label {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 7px;
}
.req, .opt {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--ink-faint);
}
.cost {
  margin-left: auto;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-deep);
  padding: 2px 9px;
  border-radius: var(--r-pill);
}
.cost-big { background: #5a1f18; color: #ffb3a2; }

input[type="text"] {
  width: 100%;
  padding: 14px 15px;
  font-family: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--bg-raised);
  border: 1.5px solid var(--line);
  border-radius: 11px;
  outline: none;
  transition: border-color .15s ease;
}
input[type="text"]:focus { border-color: var(--accent); }
input::placeholder { color: var(--ink-faint); }

select {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  padding: 14px 42px 14px 15px;
  font-family: inherit;
  font-size: 16px;
  color: var(--ink);
  background-color: var(--bg-raised);
  /* chevron, inlined so there's nothing to fetch */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%237fe3d8' stroke-width='2'%3E%3Cpath d='M3 6l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 15px center;
  background-size: 15px;
  border: 1.5px solid var(--line);
  border-radius: 11px;
  outline: none;
  cursor: pointer;
  transition: border-color .15s ease;
}
select:focus { border-color: var(--accent); }
select:invalid { color: var(--ink-faint); }   /* placeholder option still selected */
select option { background: var(--bg-raised); color: var(--ink); }

.hint { margin: 7px 0 0; font-size: 13.5px; color: var(--ink-faint); line-height: 1.4; }
.formerror { color: var(--danger); font-size: 14.5px; margin: 0 0 8px; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg {
  padding: 14px;
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 700;
  color: var(--ink-dim);
  background: var(--bg-raised);
  border: 1.5px solid var(--line);
  border-radius: 11px;
  cursor: pointer;
  transition: all .15s ease;
}
.seg[aria-pressed="true"] {
  background: var(--accent-deep);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── photo picker ─────────────────────────────────────── */
.photo-editor {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 13px;
  margin-bottom: 15px;
}

.photo-circle {
  position: relative;
  width: 170px; height: 170px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg-raised);
  border: 2.5px solid var(--accent);
  cursor: grab;
  touch-action: none;              /* we handle the drag ourselves */
  user-select: none;
  -webkit-user-select: none;
}
.photo-circle:active { cursor: grabbing; }
.photo-circle img {
  position: absolute;
  transform-origin: 0 0;
  max-width: none;                 /* the img is sized in JS, not by layout */
  pointer-events: none;
  user-select: none;
}

/* faint crosshair so it's obvious the image moves, not the frame */
.photo-circle::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to right, transparent calc(50% - .5px), rgba(255,255,255,.16) calc(50% - .5px) calc(50% + .5px), transparent calc(50% + .5px)),
    linear-gradient(to bottom, transparent calc(50% - .5px), rgba(255,255,255,.16) calc(50% - .5px) calc(50% + .5px), transparent calc(50% + .5px));
  opacity: 0;
  transition: opacity .18s ease;
}
.photo-circle.dragging::after { opacity: 1; }

.photo-zoom {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  max-width: 230px;
}
.photo-zoom input[type="range"] { flex: 1; }
.photo-zoom-icon {
  color: var(--ink-faint);
  font-size: 17px;
  width: 12px;
  text-align: center;
  flex: none;
}

.photo-tip { margin: 0; font-size: 13px; color: var(--ink-faint); }

.photo-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.btn-small { padding: 10px 17px; font-size: 14.5px; }
label.btn { display: inline-block; }

.rating-row { display: flex; align-items: center; gap: 14px; }
input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  height: 28px;
}
.rating-out {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 700;
  min-width: 34px;
  text-align: right;
  color: var(--accent);
}
.rating-max { color: var(--ink-faint); font-size: 14px; }

/* ── score bar ────────────────────────────────────────── */
.scorebar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 15px 18px;
  margin-bottom: 20px;
  font-size: 15.5px;
}
.score-cell { display: flex; align-items: center; gap: 9px; }
.score-cell strong { font-variant-numeric: tabular-nums; }
.score-icon {
  color: var(--accent);
  font-size: 15px;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border: 1.5px solid var(--accent);
  border-radius: 5px;
  flex: none;
}
.score-cell:first-child .score-icon { border: 0; font-size: 20px; }

.points-bump { animation: bump .35s ease; }
@keyframes bump {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.28); color: var(--danger); }
  100% { transform: scale(1); }
}

/* ── clue grid ────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 11px;
}
.clue {
  position: relative;
  aspect-ratio: 1 / 1.05;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: left;
  padding: 13px;
  background: var(--card);
  border: 0;
  border-radius: var(--r-card);
  color: var(--ink);
  font-family: inherit;
  cursor: pointer;
  overflow: hidden;
  transition: transform .15s ease, background .2s ease;
  -webkit-tap-highlight-color: transparent;
}
.clue:hover:not(.revealed) { background: var(--card-hi); }
.clue:active:not(.revealed) { transform: scale(.96); }

.clue-label {
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.1px;
}
.clue-cost {
  font-size: 12.5px;
  color: rgba(255,255,255,.75);
}

.clue.revealed {
  background: var(--card-done);
  border: 1.5px solid var(--card-hi);
  cursor: default;
}

/* Only the card you actually pressed turns over. */
.clue.flipping { animation: flip .36s ease; }
.clue.revealed .clue-label { color: var(--ink-faint); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.clue.revealed .clue-cost  { display: none; }

.clue-value {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--accent);
  word-break: break-word;
  margin-top: auto;
  padding-bottom: 2px;
}
.clue-value.long { font-size: 16px; }

@keyframes flip {
  0%   { transform: rotateY(0deg);   }
  50%  { transform: rotateY(90deg);  }
  100% { transform: rotateY(0deg);   }
}

/* Two columns on a phone: the clue labels here are long, and three
   columns squeezes "Year they left Ashmole" into four lines. Shorter
   cards keep all six on screen without scrolling. */
@media (max-width: 430px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .clue { aspect-ratio: 1 / 0.66; }
}

/* ── guessing ─────────────────────────────────────────── */
.guessrow { margin-top: 20px; }
.feedback {
  min-height: 22px;
  margin: 9px 2px 0;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink-faint);
}
.feedback.miss  { color: var(--danger); }
.feedback.close { color: #ffd479; }

.shake { animation: shake .35s ease; }
@keyframes shake {
  0%,100%   { transform: translateX(0); }
  20%, 60%  { transform: translateX(-7px); }
  40%, 80%  { transform: translateX(7px); }
}

/* ── share ────────────────────────────────────────────── */
.bigtick { font-size: 54px; line-height: 1.3; text-align: center; margin: 18px 0 4px; }

.linkbox {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 14px;
  margin: 18px 0 6px;
  max-height: 130px;
  overflow-y: auto;
}
.linkbox code {
  font-size: 12.5px;
  color: var(--ink-dim);
  word-break: break-all;
  line-height: 1.5;
}

/* ── result ───────────────────────────────────────────── */
.answercard {
  position: relative;
  overflow: hidden;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 22px;
  text-align: center;
  margin: 22px 0 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.confetti {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.answercard-photo {
  width: 116px;
  height: 116px;
  object-fit: cover;
  border-radius: 50%;
  align-self: center;
  margin-bottom: 10px;
  border: 2.5px solid var(--accent);
  animation: pop .45s cubic-bezier(.2, 1.5, .4, 1);
}
@keyframes pop {
  from { transform: scale(.4); opacity: 0; }
  to   { transform: scale(1);  opacity: 1; }
}

.answercard-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--ink-faint);
}
.answercard-name {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
}
.answercard-by { font-size: 14px; color: var(--ink-faint); }

.scoreline {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 9px;
  margin-bottom: 20px;
}
.scoreline-num  { font-family: var(--serif); font-size: 52px; font-weight: 700; line-height: 1; }
.scoreline-unit { color: var(--ink-dim); font-size: 16px; }

.breakdown { list-style: none; margin: 0 0 26px; padding: 0; }
.breakdown li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 2px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}
.breakdown li:last-child { border-bottom: 0; }
.breakdown .bd-cost { color: var(--danger); font-variant-numeric: tabular-nums; flex: none; }
.breakdown .bd-start .bd-cost { color: var(--ink-dim); }
.breakdown .bd-total { font-weight: 700; }
.breakdown .bd-total .bd-cost { color: var(--accent); }

/* ── recent / howto ───────────────────────────────────── */
.recent { margin-top: 30px; }
.recent-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.1px;
  color: var(--ink-faint);
  margin: 0 0 12px;
}
.recent-list { list-style: none; margin: 0; padding: 0; }
.recent-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 11px;
  margin-bottom: 9px;
}
.recent-text {
  flex: 1;
  min-width: 0;            /* let long names ellipsis rather than shove the button */
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.recent-name {
  font-weight: 600;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.recent-date {
  font-size: 12.5px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.recent-copy {
  border: 0;
  background: var(--accent-deep);
  color: var(--accent);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 13px;
  border-radius: var(--r-pill);
  cursor: pointer;
}

.howto { margin-top: 34px; }
.howto-list { margin: 0; padding-left: 20px; color: var(--ink-dim); font-size: 15px; }
.howto-list li { margin-bottom: 8px; }
.howto-list strong { color: var(--ink); }

/* ── loading ──────────────────────────────────────────── */
.loading-pad {
  min-height: 55vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.spinner {
  width: 34px; height: 34px;
  margin-bottom: 18px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── the advert ───────────────────────────────────────
   Deliberately tacky. It is meant to look like it wandered in
   from a worse website, so it ignores the tokens above. */

.ad {
  margin: 8px var(--pad) 34px;
  display: block;
}

.ad-flag {
  display: block;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 1.6px;
  color: #4a5a58;
  margin-bottom: 6px;
  text-align: center;
}

.ad-body {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: 100%;
  padding: 18px 16px 14px;
  overflow: hidden;
  cursor: pointer;
  font-family: var(--sans);
  border: 3px ridge #f0c14b;
  border-radius: 6px;
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.05) 0 10px, transparent 10px 20px),
    linear-gradient(160deg, #6d2f8f 0%, #a3238e 45%, #d4145a 100%);
  box-shadow: 0 0 0 1px #2a0f38, 0 6px 22px rgba(163,35,142,.28);
  animation: adpulse 2.6s ease-in-out infinite;
}
@keyframes adpulse {
  0%, 100% { box-shadow: 0 0 0 1px #2a0f38, 0 6px 22px rgba(163,35,142,.28); }
  50%      { box-shadow: 0 0 0 1px #2a0f38, 0 6px 30px rgba(240,193,75,.42); }
}

/* the sweep of shine that every bad banner ad has */
.ad-shine {
  position: absolute;
  top: 0; bottom: 0;
  width: 45%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.32), transparent);
  animation: adshine 3.4s ease-in-out infinite;
}
@keyframes adshine {
  0%       { left: -50%; }
  60%,100% { left: 115%; }
}

.ad-star {
  position: absolute;
  color: #ffe27a;
  font-size: 15px;
  animation: adtwinkle 1.8s ease-in-out infinite;
}
.ad-star-1 { top: 9px;  left: 13px; }
.ad-star-2 { bottom: 9px; right: 15px; animation-delay: .7s; }
@keyframes adtwinkle {
  0%, 100% { opacity: .35; transform: scale(.8) rotate(0deg); }
  50%      { opacity: 1;   transform: scale(1.25) rotate(20deg); }
}

.ad-name {
  font-family: var(--serif);
  font-size: 25px;
  font-weight: 700;
  color: #fff8dc;
  letter-spacing: -0.3px;
  text-shadow: 0 2px 0 #6d1147, 0 0 18px rgba(255,226,122,.5);
  z-index: 1;
}

.ad-slogan {
  font-size: 13.5px;
  font-weight: 700;
  font-style: italic;
  color: #ffe27a;
  text-align: center;
  min-height: 19px;
  z-index: 1;
}

.ad-cta {
  margin-top: 4px;
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 1.3px;
  color: #4a0d2e;
  background: linear-gradient(#ffe27a, #f0c14b);
  padding: 7px 20px;
  border-radius: 4px;
  border: 1px solid #fff3c4;
  z-index: 1;
}

.ad-small {
  font-size: 9.5px;
  color: rgba(255,255,255,.62);
  letter-spacing: .3px;
  text-align: center;
  z-index: 1;
}

.ad-body:active { transform: scale(.985); }

@media (prefers-reduced-motion: reduce) {
  .ad-shine { display: none; }
}

/* ── toast ────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(26px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--accent);
  color: #06201e;
  font-weight: 700;
  font-size: 14.5px;
  padding: 12px 22px;
  border-radius: var(--r-pill);
  z-index: 100;
  animation: toastin .25s ease;
  box-shadow: 0 8px 30px rgba(0,0,0,.45);
}
@keyframes toastin {
  from { opacity: 0; transform: translate(-50%, 14px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

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