/* ==========================================================
   Crosscut — styles.css (clean + de-duplicated)
   Goal: preserve current behaviour + selectors, reduce overrides
   ========================================================== */

/* -------------------------
   Theme / tokens
   ------------------------- */
:root{
  /* Environment */
  --bg:#0f172a;                 /* deep slate */
  --header:#020617;

  /* Surfaces */
  --card:#f8fafc;               /* off-white */
  --card-muted:#f1f5f9;         /* slightly darker paper */

  /* Text */
  --text:#0f172a;
  --muted:#475569;

  /* Lines */
  --border:#e2e8f0;
  --gridline:#334155;

  /* Grid */
  --block: color-mix(in srgb, var(--gridline) 70%, black);

  /* Accents */
  --focus:#2563eb;
  --word:#e0f2fe;
  --wordActive:#fde68a;

  /* Sizing */
  --cell: clamp(56px, 7.2vw, 78px);
  --gap:  clamp(3px, 0.5vw, 5px);

  /* Radius */
  --r-sm: 12px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 22px;
}

/* -------------------------
   Base / reset
   ------------------------- */
*{ box-sizing:border-box; }

body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 18px;
}

.hidden{ display:none !important; }

/* -------------------------
   Buttons (global base)
   ------------------------- */
button{
  border: 1px solid var(--border);
  background: #fff;
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font-size: 15px;
  cursor: pointer;
  color: var(--text);
  -webkit-text-fill-color: var(--text); /* iOS Safari */
  appearance: none;
  -webkit-appearance: none;
}
button:hover{ background:#f6f6f6; }
button:disabled{ cursor: default; opacity: .7; }

/* -------------------------
   Header / topbar
   ------------------------- */
.topbar{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:14px 16px;
  background: linear-gradient(180deg, #020617 0%, #0f172a 100%);
  border-bottom:1px solid #1e293b;
  color:#e5e7eb;

  position:sticky;
  top:0;
  z-index:10;
}

.brand{
  display:flex;
  gap:10px;
  align-items:center;
}

.logo{ display:flex; align-items:center; }
.logo-svg{ width:28px; height:auto; display:block; }

.title{ font-weight:800; letter-spacing:.2px; }
.subtitle{ font-size:12px; color:#94a3b8; margin-top:2px; }

.actions{
  display:flex;
  gap:8px;
  align-items:center;
}
#gameActions.hidden{ display:none; }


.site-footer {
  margin-top: 2rem;
  padding: 1rem 0;
  text-align: center;
  font-size: 0.75rem;
  color: #fff;
}

.site-footer p {
  margin: 0;
}


/* -------------------------
   Shared “cut” chip (logo mask)
   ------------------------- */
.cut-chip{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:1.1em;
  height:1.1em;
  margin:0 0.25em;
  background:#0f172a;
  border-radius:50%;
}
.cut-icon{
  display:block;
  width:0.7em;
  height:0.7em;
  background-color:#fde68a;
  -webkit-mask: url("assets/crosscut-logo.svg") no-repeat center / contain;
  mask: url("assets/crosscut-logo.svg") no-repeat center / contain;
}

/* -------------------------
   Layout / cards
   ------------------------- */
.layout{
  display:flex;
  flex-direction:column;
  gap:24px;
  padding:16px;
  align-items:center;
}

.card{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding:14px;
  box-shadow: 0 2px 12px rgba(0,0,0,.04);
}

/* Grid “card” is a wrapper (transparent) */
.grid-card,
.card.grid-card{
  width:100%;
  display:flex;
  flex-direction:column;
  align-items:center;
  background: transparent;
  border:none;
  box-shadow:none;
  padding:8px 0;
}

/* -------------------------
   Meta pills (desktop)
   ------------------------- */
.meta{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-bottom:14px;
  justify-content:center;
}

.pill{
  font-size:15px;
  border:1px solid rgba(148,163,184,.25);
  background: rgba(2,6,23,.35);
  padding:6px 10px;
  border-radius:999px;
  color:#e5e7eb;
  backdrop-filter: blur(6px);
}
.pill-mode{ font-weight:800; }
.pill-mode.is-notes{
  background: rgba(253,230,138,.85);
  color:#0f172a;
  border-color: rgba(15,23,42,.15);
}
#pillMode{ cursor:pointer; }

/* -------------------------
   Mobile active clue card
   ------------------------- */
.activeClueCard{
  display:none; /* desktop default */
  width:100%;
  max-width:520px;
  border:1px solid rgba(148,163,184,.25);
  background: rgba(2,6,23,.35);
  color:#e5e7eb;
  backdrop-filter: blur(6px);
  border-radius:16px;
  padding:10px 12px;
  margin:0 0 10px;
}

.activeClueTop{
  display:flex;
  justify-content:space-between;
  gap:10px;
  align-items:baseline;
}

.activeClueLabel{
  font-weight:900;
  letter-spacing:.2px;
  font-size:14px;
  white-space:nowrap;
}
.activeClueMeta{
  font-size:12px;
  color: rgba(226,232,240,.85);
  white-space:nowrap;
}

.activeClueText{
  margin-top:6px;
  font-size:15px;
  line-height:1.25;
  min-height: calc(2 * 1.25em);

  display:-webkit-box;
  -webkit-box-orient:vertical;
  -webkit-line-clamp:2;

  overflow:hidden;

  /* iOS fix: avoid right-edge clipping */
  text-overflow: clip;
  padding-right: 2px;
  max-width: 100%;
}


/* iOS Safari / iOS WebKit only */
@supports (-webkit-touch-callout: none){
  .activeClueText{
    /* bypass iOS's buggy -webkit-line-clamp rendering */
    display: block !important;
    -webkit-line-clamp: unset !important;
    -webkit-box-orient: unset !important;

    /* clamp by height instead (2 lines) */
    line-height: 1.25;
    max-height: calc(2 * 1.25em + 2px); /* +2px avoids rounding clipping */
    overflow: hidden;
    min-width: 0;

    /* prevents right-edge clipping on iOS */
    padding-right: 3px;
  }
  .activeClueCard{
    min-width: 0;
  }
}


.activeClueRight{
  display:flex;
  align-items:center;
  gap:10px;
}

/* reveal button is a scaled .clue-reveal */
.activeClueReveal{
  width:28px;
  height:28px;
  font-size:14px;
}

.activeClueAnswer{
  margin-top:8px;
  padding-top:8px;
  border-top:1px solid rgba(226,232,240,.18);
  font-weight:900;
  letter-spacing:.08em;
  color:#e5e7eb;
  opacity:.95;
  min-height:1.3em; /* reserve height */
}
.activeClueCard:not(.has-answer) .activeClueAnswer{
  visibility:hidden;
  border-top-color: transparent;
}

/* Mobile-only: hide pills, show active clue card */
@media (hover:none), (pointer:coarse), (max-width:700px){
  .meta{ display:none; }
  .activeClueCard{ display:block; }
}
@media (hover:none), (pointer:coarse){
  #activeClueCard{ cursor:pointer; }
}

/* -------------------------
   Grid
   ------------------------- */
.grid-wrap{
  position:relative;
  display:flex;
  justify-content:center;
  margin:12px 0;
}

.grid{
  --n:5;
  display:grid;
  grid-template-columns: repeat(var(--n), var(--cell));
  gap: var(--gap);

  background:#0b1220;
  padding: var(--gap);
  border-radius:18px;
  box-shadow: 0 22px 60px rgba(0,0,0,.35);
  width: fit-content;
}

.cell{
  width: var(--cell);
  height: var(--cell);
  background:#f6f8fc;
  position:relative;
  display:flex;
  align-items:center;
  justify-content:center;
  border:1px solid rgba(15,23,42,.06);
}

.cell.block{
  background: var(--block);
  border-radius:6px;
}

.cell.inWord{ background: var(--word); }
.cell.inWord.active{ background: var(--wordActive); }
.cell.active{ box-shadow: 0 0 0 2px var(--focus) inset; }

.cell input{
  width:100%;
  height:100%;
  border:none;
  outline:none;
  background:transparent;
  text-align:center;
  font-size:30px;
  font-weight:700;
  text-transform:uppercase;
  caret-color: transparent;
}

/* Brand selection styling (instead of system blue) */
.cell input::selection{
  background: rgba(253,230,138,.85);
  color:#0f172a;
}
.cell input::-moz-selection{
  background: rgba(253,230,138,.85);
  color:#0f172a;
}

.num{
  position:absolute;
  top:4px;
  left:6px;
  font-size:11px;
  font-weight:700;
  color:#222;
  opacity:.9;
  pointer-events:none;
}

/* Notes overlay */
.notes{
  position:absolute;
  inset:4px;
  pointer-events:none;
  display:grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  font-size:11px;
  font-weight:800;
  color: rgba(15,23,42,.65);
  line-height:1;
}
.note{
  display:flex;
  align-items:center;
  justify-content:center;
  transform: translateY(-1px);
}
.note.center,
.note.tl{ display:none; } /* unused */

.note.tm{ grid-column:2; grid-row:1; align-items:flex-start; }
.note.tr{ grid-column:3; grid-row:1; justify-content:flex-end; align-items:flex-start; }
.note.ml{ grid-column:1; grid-row:2; justify-content:flex-start; }
.note.mr{ grid-column:3; grid-row:2; justify-content:flex-end; }
.note.bl{ grid-column:1; grid-row:3; justify-content:flex-start; align-items:flex-end; }
.note.bm{ grid-column:2; grid-row:3; align-items:flex-end; }
.note.br{ grid-column:3; grid-row:3; justify-content:flex-end; align-items:flex-end; }

.cell.filled .notes{ opacity:.25; }

/* Optional notes mode button styling */
#btnMode[aria-pressed="true"]{
  border-color: rgba(37,99,235,.35);
  box-shadow: 0 0 0 2px rgba(37,99,235,.15) inset;
}

.cell.is-wrong-pulse {
  animation: wrongPulse 450ms ease;
}
@keyframes wrongPulse {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.04); }
  100% { transform: scale(1); }
}
.cell.is-wrong-pulse input {
  background: rgba(239, 68, 68, 0.22);
}


/* -------------------------
   Locked state (start overlay)
   ------------------------- */
.is-locked .grid,
.is-locked .clues-row{
  filter: blur(6px);
  opacity:.55;
  pointer-events:none;
  user-select:none;
}

/* -------------------------
   Start overlay
   ------------------------- */
.startOverlay{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  flex-direction:column;
  gap:10px;
  background: rgba(2,6,23,.55);
  backdrop-filter: blur(4px);
  border-radius:18px;
  z-index:5;
}
.startOverlay.hidden{ display:none; }

.startBtn{
  border:none;
  border-radius:999px;
  background: var(--wordActive);
  padding:14px 22px;
  font-size:18px;
  font-weight:800;
  cursor:pointer;
  box-shadow: 0 18px 40px rgba(0,0,0,.35);
}
.startSub{
  color:#e5e7eb;
  font-size:13px;
  opacity:.9;
}

.startBtnSecondary{
  border: none;
  background: #0f172a;
  color: #ffffff;
  -webkit-text-fill-color: rgba(255,255,255,0.9); /* 👈 THIS fixes it */
  border-radius: 999px;
  padding: 10px 15px;
  font-weight: 800;
  font-size:18px;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0,0,0,0.35);
}

.startBtnSecondary:hover{
  background: #020617;
}

.startBtnSecondary:focus-visible{
  outline: 3px solid rgba(253,230,138,0.95);
  outline-offset: 3px;
}


.startActionsPad{
  display: flex;
  flex-direction: column;
  gap: 25px; /* ← this is the “tad” */
}


.view-tutorial{
  border: 1px solid rgba(37,99,235,0.35);
  background: #0f172a;
  color: #ffffff;
  -webkit-text-fill-color: rgba(255,255,255,0.9); /* 👈 THIS fixes it */
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0,0,0,0.35);
}

.view-tutorial:hover{
  background: #020617;
}

.view-tutorial:focus-visible{
  outline: 3px solid rgba(253,230,138,0.95);
  outline-offset: 3px;
}




/* Global focus style: use brand gold instead of default blue */
:focus { outline: none; }

:focus-visible{
  outline: 3px solid rgba(253, 230, 138, 0.95);
  outline-offset: 3px;
}


/* -------------------------
   Modals (help + clues + solved)
   ------------------------- */
.modal{
  position:fixed;
  inset:0;
  z-index:100;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:16px;
  overflow:auto;
  -webkit-overflow-scrolling: touch;
}
.modal.hidden{ display:none; }

.modal-backdrop{
  position:absolute;
  inset:0;
  background: rgba(2,6,23,.65);
  backdrop-filter: blur(4px);
}

.modal-card{
  position:relative;
  z-index:1;
  width: min(420px, 100%);
  margin:0;

  background: var(--card);
  border-radius: var(--r-lg);
  padding:22px;
  box-shadow: 0 30px 80px rgba(0,0,0,.45);

  max-height: calc(100dvh - 32px);
  overflow:auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: max(22px, env(safe-area-inset-bottom));
}
@supports not (height: 100dvh) {
  .modal-card{ max-height: calc(100vh - 32px); }
}

.modal-card h2{
  margin-top:0;
  text-align:center;
}
.modal-card h3{
  margin-top:18px;
  font-size:14px;
  color: var(--muted);
}

/* Help modal content */
.howto{ padding-left:18px; line-height:1.5; }
.howto li{ margin-bottom:6px; }

#helpModal .modal-card button{
  display:block;
  margin:18px auto 0;
  padding:8px 14px;
  border-radius:999px;
}

/* Help: desktop/mobile swap */
.howto-mobile{ display:none; }
.howto-desktop{ display:block; }
@media (hover:none), (pointer:coarse), (max-width:700px){
  .howto-mobile{ display:block; }
  .howto-desktop{ display:none; }
}

/* Wider help modal on desktop */
@media (hover:hover) and (pointer:fine){
  #helpModal .modal-card{ width: min(640px, 100%); }
}

/* -------------------------
   Solved modal (decorated card)
   ------------------------- */
.modal-card.solved-card{
  text-align:center;
  position:relative;
  overflow:hidden;
  border-radius:22px;

  background:
    radial-gradient(1200px 520px at -10% -20%, rgba(253,230,138,.42), transparent 55%),
    radial-gradient(900px 500px at 110% 0%, rgba(37,99,235,.12), transparent 55%),
    radial-gradient(circle at 16px 18px, rgba(15,23,42,.05) 2px, transparent 2.5px),
    radial-gradient(circle at 40px 44px, rgba(15,23,42,.04) 2px, transparent 2.5px),
    radial-gradient(circle at 70px 26px, rgba(15,23,42,.035) 2px, transparent 2.5px),
    radial-gradient(circle at 92px 60px, rgba(15,23,42,.03) 2px, transparent 2.5px),
    color-mix(in srgb, var(--wordActive) 10%, var(--card));

  background-size: auto, auto, 120px 120px, 120px 120px, 120px 120px, 120px 120px, auto;
  background-repeat: no-repeat, no-repeat, repeat, repeat, repeat, repeat, no-repeat;

  border: 1px solid rgba(15,23,42,.10);
  box-shadow: 0 36px 90px rgba(0,0,0,.50);
}

.modal-card.solved-card h2{
  margin:6px 0 8px;
  font-size:26px;
  font-weight:1000;
  letter-spacing:.2px;
}
.modal-card.solved-card h2::after{
  content:"";
  display:block;
  width:110px;
  height:8px;
  margin:10px auto 0;
  border-radius:999px;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--wordActive) 88%, white),
    rgba(37,99,235,.18),
    color-mix(in srgb, var(--wordActive) 88%, white)
  );
  border:1px solid rgba(15,23,42,.10);
}

/* Optional stripe + watermark elements */
.solved-topstripe{
  position:absolute;
  left:0; right:0; top:0;
  height:10px;
  background: linear-gradient(90deg, #0f172a, #fde68a, #0f172a);
  opacity:.95;
  pointer-events:none;
}
.solved-watermark{
  position:absolute;
  right:-20px;
  top:18px;
  width:210px;
  height:210px;
  opacity:.08;
  transform: rotate(-12deg);
  background-color:#0f172a;
  -webkit-mask: url("assets/crosscut-logo.svg") no-repeat center / contain;
  mask: url("assets/crosscut-logo.svg") no-repeat center / contain;
  pointer-events:none;
}

/* Solved modal action buttons */
.solved-actions{
  display:none;
  gap:10px;
  justify-content:center;
  margin-top:14px;
}
.solved-actions button{
  border-radius:999px;
  padding:10px 14px;
  font-weight:950;
  border:1px solid rgba(15,23,42,.12);
  box-shadow: 0 10px 20px rgba(0,0,0,.10);
}

/* Desktop: Share perfectly centered */
@media (hover:hover) and (pointer:fine){
  .solved-actions{
    grid-template-columns: 1fr auto 1fr;
    align-items:center;
    column-gap:10px;
  }
  #btnSolvedClose{ justify-self:start; }
  #btnShare{ justify-self:center; }
  #btnSolvedClear{ justify-self:end; }
}


/* Mobile: stacked */
@media (max-width:520px){
  .solved-actions{
    flex-direction:column;
    align-items:stretch;
  }
}


/* Turn on when done (base = flex for mobile; desktop media query will override to grid) */
#feedWrap[data-feed-state="done"] ~ .solved-actions {
  display: flex;
}
@media (hover:hover) and (pointer:fine){
  #feedWrap[data-feed-state="done"] ~ .solved-actions {
    display: grid;
  }
}


#btnShare{
  background: var(--wordActive);
  border-color: rgba(15,23,42,.18);
}
#btnShare:hover{
  background: color-mix(in srgb, var(--wordActive) 80%, white);
}

#solvedTime{
  margin:0 0 10px;
  font-size:16px;
  font-weight:700;
  color: var(--muted);
}

/* -------------------------
   Feed section (Solved modal) — CALM MODE (final)
   ------------------------- */
.feed-wrap{
  margin-top:14px;
  text-align:left;
  position:relative;
  overflow:hidden;

  /* base shape (desktop + any future reuse), overridden in solved scope below */
  border-radius:18px;
  padding:14px;
}

/* CALM MODE scoped to solved modal (prevents accidental global overrides) */
.modal-card.solved-card .feed-wrap{
  position: relative;
  background:#0f172a;
  border:none;
  box-shadow: 0 18px 50px rgba(0,0,0,.28);
  border-radius:18px;
  padding:14px;
  padding-top: 44px;
}

/* little tab */
.modal-card.solved-card .feed-wrap::before{
  content:"Feed the critters";
  position:absolute;
  left:12px;
  top:10px;
  font-size:12px;
  font-weight:800;
  letter-spacing:.02em;
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.92);
  border: 1px solid rgba(255,255,255,.10);
  border-radius:999px;
  padding:6px 10px;
  box-shadow:none;
}

/* keep content above tab */
.feed-intro,
.feed-sub,
.feed-grid,
.feed-none,
.feed-toast{
  position:relative;
  z-index:1;
}

.modal-card.solved-card .feed-intro{
  margin:30px 0 10px;
  color: rgba(255,255,255,.90);
  font-size:14px;
  line-height:1.35;
  font-weight:500;
}

.modal-card.solved-card .feed-sub{
  display:block;
  margin:0 0 12px;
  padding:0;
  background:transparent;
  border:none;
  border-radius:0;
  font-size:13px;
  font-weight:600;
  letter-spacing:0;
  color: rgba(255,255,255,.75);
}

.feed-grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:12px;
}
@media (max-width:520px){
  .feed-grid{ grid-template-columns:1fr; }
}

.modal-card.solved-card .feed-card{
  display:grid;
  place-items:center;
  min-height:132px;

  background: rgba(255,255,255,.06);
  border:none;
  box-shadow:none;
  border-radius:16px;
  padding:12px;

  cursor:pointer;
  transition: background .10s ease, transform .08s ease;
  color: rgba(255,255,255,.92);
  -webkit-text-fill-color: rgba(255,255,255,.92);
}
.modal-card.solved-card .feed-card:hover{
  background: rgba(255,255,255,.08);
}
.modal-card.solved-card .feed-card:active{
  transform: translateY(1px);
}

/* Inner badge */
.feed-badge{
  width:120px;
  height:120px;
  border-radius:22px;
  display:grid;
  place-items:center;
  gap:6px;
  padding:10px;
  text-align:center;
}
.modal-card.solved-card .feed-badge{
  background: rgba(255,255,255,.94);
  border:none;
  box-shadow: 0 10px 26px rgba(0,0,0,.22);
}

.feed-emoji{ font-size:40px; line-height:1; }

.feed-name{
  /* “assume 10 letters” sizing */
  font-size:13px;
  line-height:1.05;
  max-width:10ch;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.modal-card.solved-card .feed-name{
  font-weight:700;
  letter-spacing:0;
  color:#0f172a;
  -webkit-text-fill-color:#0f172a;
}

/* Selected = one intentional brand yellow cue */
.modal-card.solved-card .feed-card.is-selected{
  background: rgba(253,230,138,.18);
  box-shadow: 0 0 0 2px rgba(253,230,138,.55) inset;
  transform:none;
}

.modal-card.solved-card .feed-none{
  margin-top:12px;
  width:100%;
  border-radius:16px;
  border:none;
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.88);
  -webkit-text-fill-color: rgba(255,255,255,.88);
  box-shadow:none;
  font-weight:650;
  padding:10px 12px;
}
.modal-card.solved-card .feed-none:hover{
  background: rgba(255,255,255,.08);
}
.modal-card.solved-card .feed-none.is-selected{
  background: rgba(253,230,138,.18);
  box-shadow: 0 0 0 2px rgba(253,230,138,.55) inset;
}

/* Toast (subtle) */
.feed-toast{
  margin-top:12px;
  padding:10px 12px;
  border-radius:14px;
  text-align:center;
  font-size:14px;
  font-weight:650;
}
.modal-card.solved-card .feed-toast{
  background: rgba(255,255,255,.06);
  border:none;
  box-shadow:none;
  color: rgba(255,255,255,.85);
  -webkit-text-fill-color: rgba(255,255,255,.85);
}
.modal-card.solved-card .feed-toast::before{
  content:"";
  display:inline-block;
  width:10px;
  height:10px;
  border-radius:999px;
  margin-right:8px;
  vertical-align:middle;
  background:#fde68a;
}

/* Kill shimmer/float (keeps current calm behaviour) */
@media {
  .modal-card.solved-card .feed-wrap::after{ display:none; }
  .modal-card.solved-card .feed-card.is-selected .feed-badge{ animation:none; }
}


/* ===== Feed state machine ===== */

/* Stage overlays the feed card area */
.modal-card.solved-card .feed-wrap{
  position: relative; /* important for the stage */
}

.feed-anim-stage{
  position:absolute;
  inset:0;
  pointer-events:none;
  overflow:hidden;
  z-index: 3; /* above most things; selected card still visible due to its own z */
}

/* Each flying letter */
.feed-letter{
  position:absolute;
  font-weight: 950;
  font-size: 18px;
  line-height: 1;
  letter-spacing: .02em;
  color: rgba(255,255,255,.92);
  text-shadow: 0 6px 18px rgba(0,0,0,.35);
  will-change: transform, opacity;
  user-select:none;
}

/* “Eating” wobble on the emoji while letters are flying */
.feed-badge.is-eating .feed-emoji{
  animation: feedWobble 260ms ease-in-out infinite;
  transform-origin: 50% 70%;
}

@keyframes feedWobble{
  0%   { transform: translateY(0) rotate(0deg) scale(1); }
  25%  { transform: translateY(-1px) rotate(-6deg) scale(1.03); }
  50%  { transform: translateY(0px) rotate(6deg) scale(1.05); }
  75%  { transform: translateY(-1px) rotate(-4deg) scale(1.03); }
  100% { transform: translateY(0) rotate(0deg) scale(1); }
}

/*@media (prefers-reduced-motion: reduce){
  .feed-badge.is-eating .feed-emoji{ animation: none; }
}*/


/* Default: choose view */
#feedWrap .feed-copy { display: block; }
#feedWrap .feed-grid { display: grid; }   /* IMPORTANT: grid stays grid */
#feedWrap .feed-none { display: block; }
#feedWrap .feed-anim-stage {
  display: none;
}
#feedWrap #feedThanks { display: none; }

/* Animating: hide copy + none, show stage, keep ONLY selected card visible */
#feedWrap[data-feed-state="animating"] .feed-card.is-selected{
  position: relative;
  z-index: 4;
}

#feedWrap[data-feed-state="animating"] .feed-copy,
#feedWrap[data-feed-state="animating"] .feed-none {
  display: none;
}



/* Keep grid alive so selected card can be shown */
#feedWrap[data-feed-state="animating"] .feed-grid{
  grid-template-columns: 1fr;
  justify-items: center;
}

/* Hide all cards, then re-show the selected one */
#feedWrap[data-feed-state="animating"] .feed-card { display: none; }
#feedWrap[data-feed-state="animating"] .feed-card.is-selected{
  display: grid;
  margin: 6px auto 0;
}

#feedWrap[data-feed-state="animating"] .feed-anim-stage {
  display: block;
}


/* Done */
#feedWrap[data-feed-state="done"] .feed-copy,
#feedWrap[data-feed-state="done"] .feed-none {
  display: none;
}
#feedWrap[data-feed-state="done"] #feedThanks {
  display: block;
}
#feedWrap[data-feed-state="done"] .feed-grid{
  grid-template-columns: 1fr;
  justify-items: center;
}

/* Done: show only selected animal */
#feedWrap[data-feed-state="done"] .feed-card { display: none; }
#feedWrap[data-feed-state="done"] .feed-card.is-selected {
  display: grid;          /* matches your feed-card styling */
  margin: 0 auto;
}



/* -------------------------
   Clues (desktop list)
   ------------------------- */
.clues-row{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:20px;
  width:100%;
  max-width:1100px;
  align-items:stretch;
}
@media (max-width:700px){
  .clues-row{ grid-template-columns:1fr; }
}

.clues-row .card{
  background: var(--card-muted);
  border-radius: var(--r-xl);
  box-shadow: 0 16px 34px rgba(0,0,0,.22);
  height:100%;
}

h2{
  margin:0 0 10px;
  font-size:17px;
}
.clues-row h2{
  text-align:center;
  font-weight:700;
  letter-spacing:.4px;
  padding-bottom:6px;
  border-bottom:1px solid var(--border);
}

.clueList{
  list-style:none;
  margin:0;
  padding:0;
}
@media (hover:hover) and (pointer:fine){
  .clues-row .clueList{ padding-left:10px; }
}

.clue{
  padding:8px 10px;
  border-radius:10px;
  cursor:pointer;
  line-height:1.25;
  margin-bottom:4px;
}
.clue:hover{ background:#f4f4f4; }
.clue.active{ background: var(--wordActive); }
.clue small{ color: var(--muted); }

.clue-row{
  display:flex;
  gap:8px;
  align-items:center;
}
.clue-main{ flex:1; min-width:0; }
.clue-line{ display:inline; }

.clue-meta{
  margin-left:6px;
  color: var(--muted);
  font-size:12px;
  white-space:nowrap;
  opacity:.85;
}

.clue-answer{
  margin-left:10px;
  font-weight:900;
  letter-spacing:.08em;
  color: var(--text);
  opacity:.95;
}
.clue:not(.is-revealed) .clue-answer{ display:none; }

/* reveal button (also reused by active clue reveal) */
.clue-reveal{
  width:30px;
  height:30px;
  padding:0;
  border-radius:999px;
  display:grid;
  place-items:center;
  font-size:16px;
  line-height:0;
  overflow:hidden;
}
.clue-reveal .eye{
  display:block;
  font-size:16px;
  line-height:1;
  transform: translateY(-0.5px);
}
.clue-reveal:disabled{ opacity:.55; }


/* Hide “Controls” section on small screens (matches current) */
@media (max-width:700px){
  .controls-heading,
  .controls-list{ display:none; }
}

/* -------------------------
   Mobile clues modal
   ------------------------- */
@media (hover:none), (pointer:coarse){
  .clues-row{ display:none; }

  .clues-modal-card{
    width: min(720px, 100%);
    max-height: calc(100dvh - 32px);
    padding:12px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    display:flex;
    flex-direction:column;
    gap:10px;
  }

  .clues-modal-header{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:10px;
    padding:4px 2px 6px;
  }

  .clues-tabs{
    display:inline-flex;
    gap:8px;
  }

  .clues-tab{
    border:1px solid var(--border);
    background:#fff;
    border-radius:999px;
    padding:8px 12px;
    font-size:14px;
    font-weight:800;
  }
  .clues-tab.is-active{
    background: var(--wordActive);
    border-color: rgba(15,23,42,.15);
  }

  .clues-close{
    border-radius:999px;
    padding:8px 12px;
    font-size:14px;
    font-weight:800;
  }

  .clues-modal-body{
    flex:1;
    overflow:auto;
    -webkit-overflow-scrolling: touch;
    padding:0 2px 2px;
  }

  #cluesAcrossModal,
  #cluesDownModal{ margin:0; }
}

/* -------------------------
   On-screen keypad (mobile)
   ------------------------- */
.keypad{
  width:100%;
  max-width:520px;
  margin:10px auto 0;
  padding:10px;
  border-radius:16px;
  background: rgba(2,6,23,.35);
  border:1px solid rgba(148,163,184,.25);
  backdrop-filter: blur(6px);
  display:grid;
  gap:8px;
}
.keypad.hidden{ display:none; }

.keypad-row{ display:grid; gap:6px; }
.keypad-row.row1{ grid-template-columns: repeat(10, minmax(0, 1fr)); }
.keypad-row.row2{
  grid-template-columns: repeat(9, minmax(0, 1fr));
  padding-inline: clamp(12px, 4vw, 26px);
}
.keypad-row.row3{
  grid-template-columns: 0.7fr repeat(7, minmax(0, 1fr)) 1.3fr 0.7fr;
}

.keypad-key{
  border:1px solid rgba(226,232,240,.9);
  background:#fff;
  border-radius:12px;
  padding:10px 0;
  font-weight:900;
  height: clamp(48px, 10vw, 62px);
  width:100%;
  min-width:0;
  font-size: clamp(16px, 4vw, 20px);
  text-align:center;
  user-select:none;
  -webkit-user-select:none;
  touch-action: manipulation;
  color:#0f172a;
  -webkit-text-fill-color:#0f172a;
  appearance:none;
  -webkit-appearance:none;
}
.keypad-key:active{ transform: translateY(1px); }
.keypad-key.key-wide{ font-size: clamp(16px, 4vw, 20px); }

.keypad-spacer{ visibility:hidden; }

/* Only show keypad on touch/coarse pointers */
@media (hover:hover) and (pointer:fine){
  .keypad{ display:none !important; }
}

/* Edge-to-edge keypad on mobile */
@media (hover:none), (pointer:coarse){
  .keypad{
    max-width:none;
    width:100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }
}


/* =========================
   Tutorial overlay
   ========================= */

.tutorial{
  position: fixed;
  inset: 0;
  z-index: 9999;
}

.tutorial.hidden{ display:none; }

.tutorial-scrim{
  position:absolute;
  inset:0;
  background: rgba(2, 6, 23, 0.15);
  backdrop-filter: none;
}


.tutorial-card {
  position: relative;
  z-index: 2;
  width: min(460px, 92vw);
  background: rgba(15, 23, 42, 0.96);
  color: rgba(255,255,255,0.92);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 18px;
  box-shadow: 0 18px 40px rgba(0,0,0,0.35);
  padding: 14px 14px 12px;
  max-height: min(60vh, 520px);
  overflow: auto;
}

/* DESKTOP: default to top-right “floating” */
@media (min-width: 820px) {
  #tutorialOverlay {
    align-items: start;
    justify-items: end;
    padding: 18px;
  }
}

/* MOBILE: bottom sheet */
@media (max-width: 819px) {
  #tutorialOverlay {
    align-items: end;
    justify-items: center;
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  }

  .tutorial-card {
    width: min(520px, 96vw);
    max-height: 44vh;
    border-radius: 18px;
  }
}

.tutorial-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom: 10px;
}

.tutorial-title{
  font-weight: 800;
  letter-spacing: -0.02em;
  font-size: 16px;
}

.tutorial-skip{
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.7);
  color: rgba(255,255,255,0.92);
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 800;
  cursor: pointer;
}
.tutorial-skip:hover{
  outline: 3px solid rgba(253, 230, 138, 0.95);
  outline-offset: 3px;
}

.tutorial-text{
  font-size: 14px;
  line-height: 1.35;
  color: rgba(255,255,255,0.88);
  white-space: pre-line; /* your tutorial strings have \n\n */
}

.tutorial-actions{
  display:flex;
  justify-content:flex-end;
  gap:10px;
  margin-top: 12px;
}

.tutorial-btn{
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.7);
  color: rgba(255,255,255,0.92);
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 800;
  cursor: pointer;
}
.tutorial-btn:disabled{
  opacity: 0.55;
  cursor: not-allowed;
}
.tutorial-btn.primary{
  background: rgba(253, 230, 138, 0.95);  /* brand gold */
  color: #0f172a;
  border-color: rgba(15,23,42,0.18);
}

/* While tutorial is active, block interaction with the app UI */
body.in-tutorial #grid,
body.in-tutorial #cluesAcross,
body.in-tutorial #cluesDown,
body.in-tutorial #activeClueCard,
body.in-tutorial #keypad,
body.in-tutorial #gameActions,
body.in-tutorial #btnStart{
  pointer-events: none;
}

/* Optional: highlight targets */
.tut-highlight{
  outline: 3px solid rgba(245, 158, 11, 0.9); /* gold */
  outline-offset: 2px;
  border-radius: 8px;
}

#tutorialOverlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: grid;
  pointer-events: auto;
}

#tutorialOverlay.hidden { display: none; }


.tutorial button:focus-visible{
  outline: 3px solid rgba(253, 230, 138, 0.95);
  outline-offset: 3px;
}
