:root {
  --tabbar: calc(62px + env(safe-area-inset-bottom));
  --frame1: #8a6a3f;
  --frame2: #5a4128;
  --bg1: #17152f;
  --bg2: #3a2d6e;
  --tile: #fff6e4;
  --ink: #2a2150;
  --accent: #ffb547;
  --accent2: #ff6f61;
  --good: #4fd39a;
  --empty: rgba(255, 255, 255, 0.13);
  --glass: rgba(255, 255, 255, 0.11);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(130% 90% at 50% 0%, var(--bg2), var(--bg1));
  background-color: var(--bg1);
  color: #fff;
  font-family: Fredoka, ui-rounded, "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}

#app {
  position: relative; z-index: 1;
  display: flex;
  flex-direction: column;
  height: calc(100dvh - var(--tabbar));
  max-width: 520px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
}

.hud { display: flex; justify-content: space-between; align-items: center; }
.chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--glass);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 18px; font-weight: 600;
}
.tap-chip {
  border: 0; color: inherit; font: inherit; cursor: pointer;
  padding: 5px 14px 5px 6px; border-radius: 14px;
}
#tapThumb { border-radius: 4px; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.18); }
#tapThumb.pulse { animation: weave-pulse 0.6s ease-out; }
@keyframes weave-pulse { 30% { transform: scale(1.18); box-shadow: 0 0 0 2px var(--accent), 0 0 12px var(--accent); } }
.tap-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.1; }
.tap-text small { font-size: 12px; font-weight: 500; opacity: 0.65; }
.coin {
  width: 18px; height: 18px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffe28a, #f0a020);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.2);
}

/* Board */
#board { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 8px 0; }
#grid { position: relative; }
.cell {
  position: absolute;
  display: flex; align-items: center; justify-content: center;
  border-radius: 22%;
  background: var(--empty);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  color: var(--ink);
  font-weight: 700;
  text-transform: uppercase;
  transition: background 0.2s;
}
.cell.filled { background: var(--tile); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25); }
.cell.pop { animation: pop 0.38s ease-out backwards; }
.cell.flash { animation: flash 0.55s; }
@keyframes pop { 0% { transform: scale(0.3); } 70% { transform: scale(1.14); } 100% { transform: scale(1); } }
@keyframes flash { 40% { background: var(--accent); transform: scale(1.08); } }

/* Current word */
.preview { height: 52px; display: flex; align-items: center; justify-content: center; }
.preview span {
  background: var(--tile); color: var(--ink);
  padding: 4px 16px; border-radius: 12px;
  font-size: 26px; font-weight: 700; letter-spacing: 3px;
  text-transform: uppercase;
}
.preview span.good { background: var(--good); color: #0f3a28; animation: rise 0.6s ease-out forwards; }
.preview span.bonus { background: var(--accent); animation: rise 0.6s ease-out forwards; }
.preview span.dup { background: #c9c3e6; animation: fade 0.6s forwards; }
.preview span.bad { background: var(--accent2); color: #fff; animation: shake 0.4s, fade 0.6s 0.1s forwards; }
.preview em { font-style: normal; opacity: 0.6; font-size: 16px; }
@keyframes rise { to { transform: translateY(-14px); opacity: 0; } }
@keyframes fade { to { opacity: 0; } }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }

/* Wheel */
.dock { position: relative; display: flex; justify-content: center; }
#wheel {
  position: relative;
  width: min(74vw, 300px, 40dvh);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--glass);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.06);
  touch-action: none;
}
#wheel svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
#line { fill: none; stroke: var(--accent); stroke-width: 10; stroke-linecap: round; stroke-linejoin: round; opacity: 0.9; }
.letter {
  position: absolute;
  display: flex; align-items: center; justify-content: center;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  font-weight: 700; text-transform: uppercase;
  pointer-events: none;
  transition: background 0.12s, color 0.12s, transform 0.12s;
}
.letter.on { background: var(--accent); color: var(--ink); transform: translate(-50%, -50%) scale(1.08); }
.letter.spin { animation: spin-in 0.35s ease-out; }
@keyframes spin-in { from { opacity: 0; transform: translate(-50%, -50%) scale(0.4) rotate(-90deg); } }

.round {
  position: absolute;
  width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%;
  background: var(--glass); color: #fff;
  font: inherit; font-size: 24px; font-weight: 700;
  cursor: pointer;
}
.round:active { transform: scale(0.94); }
.round b {
  position: absolute; right: -6px; bottom: -6px;
  background: var(--accent2);
  border-radius: 999px; padding: 1px 7px;
  font-size: 12px;
}
.round.disabled { opacity: 0.5; }
#bonusBtn { left: 0; top: 0; color: var(--accent); }
#bonusBtn b { background: var(--accent); color: var(--ink); }
#bonusBtn .ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg, .ring-fg { fill: none; stroke-width: 4; }
.ring-bg { stroke: rgba(255, 255, 255, 0.12); }
.ring-fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 0.4s ease-out; }
#bonusBtn.bump { animation: bump 0.35s ease-out; }
#bonusBtn.burst { animation: burst 0.8s ease-out; }
@keyframes bump { 40% { transform: scale(1.15); } }
@keyframes burst {
  25% { transform: scale(1.35); box-shadow: 0 0 0 6px rgba(242, 201, 76, 0.5), 0 0 28px #f2c94c; }
}
.tcard .gold { color: #f2c94c; opacity: 1; font-weight: 600; }
#scatterBtn { left: 0; bottom: 0; }
#targetBtn { right: 0; top: 0; }
#hintBtn { right: 0; bottom: 0; }
.round.center {
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 46px; height: 46px; font-size: 20px;
  background: rgba(255, 255, 255, 0.08);
}
.round.center:active { transform: translate(-50%, -50%) scale(0.94); }
.icon { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.icon .dot { fill: currentColor; stroke: none; }
#targetBtn.armed { background: var(--accent); color: var(--ink); box-shadow: 0 0 16px var(--accent); }

/* Targeting: empty squares glow and can be tapped. */
#grid.picking .cell:not(.filled) {
  cursor: pointer;
  box-shadow: 0 0 0 2px var(--accent);
  animation: glow 0.9s ease-in-out infinite alternate;
}
@keyframes glow { to { background: rgba(255, 181, 71, 0.35); } }

/* Word being built by tapping: tap it to submit. */
.preview span.typing { cursor: pointer; box-shadow: 0 0 0 2px var(--accent); }
.preview span.typing::after { content: ' ✓'; color: var(--good); }

/* Toast & win dialog */
#toast {
  position: fixed; left: 50%; top: 64px;
  max-width: calc(100% - 32px);
  transform: translate(-50%, -10px);
  background: rgba(20, 16, 44, 0.92);
  padding: 8px 16px; border-radius: 12px;
  font-size: 15px; text-align: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 5;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

#win {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10, 8, 26, 0.6);
  backdrop-filter: blur(4px);
  z-index: 10;
}
#win[hidden] { display: none; }
#win .card {
  background: var(--tile); color: var(--ink);
  border-radius: 24px; padding: 28px 32px;
  text-align: center;
  animation: pop 0.4s ease-out;
}
#win h2 { margin: 0 0 14px; font-size: 26px; }
#win p { margin: 0 0 4px; font-size: 17px; opacity: 0.75; }
#win #winText { margin: 10px 0 20px; }
#win .tname { font-weight: 700; opacity: 1; margin-top: 12px; }
#win .muted { font-size: 14px; }
#win .card { max-width: min(340px, calc(100vw - 32px)); max-height: 92dvh; overflow-y: auto; }
#win .story { font-style: italic; font-size: 15px; margin: 10px 0 0; opacity: 0.85; line-height: 1.35; }
.word-of-level {
  margin: 12px 0 0; padding: 10px 12px;
  background: rgba(42, 33, 80, 0.07); border-radius: 12px;
  display: flex; flex-direction: column; gap: 2px; text-align: left;
}
.word-of-level[hidden] { display: none; }
.word-of-level small { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; opacity: 0.6; }
.word-of-level b { font-size: 18px; letter-spacing: 2px; }
.word-of-level span { font-size: 14px; line-height: 1.3; }
.word-of-level i { font-style: normal; font-size: 11px; text-transform: uppercase; color: var(--accent2); margin-right: 6px; }

/* Tapestry viewer */
.viewer-body { overflow-y: auto; display: flex; flex-direction: column; align-items: center; padding: 8px 4px 4px; }
.viewer-body .note { margin: 16px 0 4px; }
/* Keep the tapestry its full size in the scrolling sheet (flex items would otherwise shrink), with room for the frame. */
.viewer-body > * { flex-shrink: 0; }
.viewer-body .framed { margin: 8px auto; }
#viewerMeta { margin: 14px 0 4px; text-align: center; }
.story-lines { width: 100%; }
.story-lines p { margin: 8px 0; font-size: 15px; line-height: 1.4; font-style: italic; }
.story-lines p.locked { opacity: 0.3; font-style: normal; text-align: center; }
/* Settings & statistics */
.settings-body { overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding-bottom: 4px; }
.settings-body h3 { margin: 6px 0 0; font-size: 14px; text-transform: uppercase; letter-spacing: 1px; opacity: 0.6; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--glass); border-radius: 12px; padding: 10px 6px; text-align: center; display: flex; flex-direction: column; gap: 2px; }
.stat b { font-size: 18px; overflow-wrap: anywhere; }
.stat span { font-size: 11px; opacity: 0.7; }
.toggle-list { display: flex; flex-direction: column; gap: 6px; }
.toggle {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--glass); border: 0; border-radius: 12px; padding: 12px 14px;
  color: inherit; font: inherit; font-size: 16px; cursor: pointer; text-align: left;
}
.toggle i { width: 44px; height: 26px; border-radius: 13px; background: rgba(255, 255, 255, 0.2); position: relative; transition: background 0.2s; flex: none; }
.toggle i::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; transition: transform 0.2s;
}
.toggle[aria-checked="true"] i { background: var(--good); }
.toggle[aria-checked="true"] i::after { transform: translateX(18px); }
.danger {
  align-self: flex-start; margin-top: 4px;
  background: none; border: 2px solid var(--accent2); border-radius: 999px;
  color: var(--accent2); font: inherit; font-weight: 600; padding: 8px 18px; cursor: pointer;
}
.danger.armed { background: var(--accent2); color: #fff; }

/* Tutorial spotlight */
#coach { position: fixed; inset: 0; z-index: 20; }
#coach[hidden] { display: none; }
#coach .hole {
  position: fixed; border-radius: 18px;
  box-shadow: 0 0 0 9999px rgba(10, 8, 26, 0.78), 0 0 0 3px var(--accent);
  transition: all 0.3s ease;
}
#coach .bubble {
  position: fixed; left: 16px; right: 16px; max-width: 420px; margin: 0 auto;
  background: var(--tile); color: var(--ink);
  border-radius: 18px; padding: 14px 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
#coach .bubble small { font-size: 12px; opacity: 0.55; }
#coach .bubble p { margin: 4px 0 12px; font-size: 16px; line-height: 1.4; }
.coach-actions { display: flex; justify-content: space-between; }
.coach-skip { background: none; border: 0; color: var(--ink); opacity: 0.6; font: inherit; cursor: pointer; padding: 8px; }
.coach-next {
  border: 0; border-radius: 999px; padding: 9px 22px; cursor: pointer;
  background: var(--accent2); color: #fff; font: inherit; font-weight: 600;
}

/* Accessibility */
body { touch-action: manipulation; transition: background-color 0.6s; }
button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
body.large-text .overlay .sheet, body.large-text .page .sheet, body.large-text .tabbar, body.large-text #toast, body.large-text .preview,
body.large-text #win .card, body.large-text #coach .bubble { zoom: 1.15; }
body.large-text .hud .tap-text { zoom: 1.12; }
body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after {
  animation-duration: 1ms !important;
  animation-delay: 0ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 1ms !important;
}

/* Narrow phones: tighter top bar. */
@media (max-width: 380px) {
  .hud-right { gap: 5px; }
  .icon-chip { padding: 7px; }
  .coins-chip { padding: 6px 10px; gap: 6px; }
  .tap-chip { padding-right: 10px; }
}

/* The coins open the shop */
.coins-chip { border: 0; color: inherit; font: inherit; font-size: 18px; font-weight: 600; cursor: pointer; }
.coins-plus { display: none; }
.coins-chip.shop .coins-plus {
  display: grid; place-items: center; width: 20px; height: 20px; margin-right: -6px; border-radius: 50%;
  background: var(--accent); color: var(--ink); font-size: 16px; line-height: 1; font-weight: 700;
}
.offer-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.offer-actions .today-btn, .offer-actions .share { margin: 0; }
.offer-actions .share { color: #fff; border-color: var(--accent); }
#profileShopBtn { align-self: flex-start; margin: 0; color: #fff; border-color: var(--accent); }

/* Today, daily gift, daily result */
#todayBtn, #settingsBtn, #coinsBtn { position: relative; }
#todayBtn.badge::after, #settingsBtn.badge::after, #coinsBtn.badge::after {
  content: ''; position: absolute; top: 4px; right: 4px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent2); box-shadow: 0 0 0 2px var(--bg1);
}
.today-list { overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding-bottom: 4px; }
.today-card {
  background: var(--glass); border-radius: 16px; padding: 14px;
  display: flex; flex-direction: column; gap: 4px;
}
.today-card b { font-size: 17px; }
.today-card span { font-size: 14px; opacity: 0.75; line-height: 1.35; }
.today-btn {
  align-self: flex-start; margin-top: 8px;
  border: 0; border-radius: 999px; padding: 9px 20px; cursor: pointer;
  background: var(--accent); color: var(--ink); font: inherit; font-weight: 700;
}
.gift-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.gift-day {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 2px; border-radius: 12px; background: var(--glass);
}
.gift-day small { font-size: 10px; opacity: 0.7; }
.gift-day b { font-size: 15px; }
.gift-day.past { opacity: 0.4; }
.gift-day.now { background: var(--accent); color: var(--ink); box-shadow: 0 0 14px var(--accent); }
#gift .note { margin: 14px 0 4px; text-align: center; }
#gift .today-btn { align-self: center; }
#win .result {
  margin: 12px 0 0; padding: 10px 12px; border-radius: 12px;
  background: rgba(42, 33, 80, 0.07);
  font: inherit; font-size: 15px; line-height: 1.5; white-space: pre-wrap; text-align: left;
}
#win .result[hidden], #win [hidden] { display: none; }
.share {
  margin-top: 10px; border: 2px solid var(--accent2); border-radius: 999px;
  background: none; color: var(--accent2); font: inherit; font-weight: 600;
  padding: 8px 20px; cursor: pointer;
}
.tcard.weekly canvas { box-shadow: 0 0 0 3px #f2c94c, 0 0 14px rgba(242, 201, 76, 0.6); }

/* Lexicon */
.hud-right { display: flex; gap: 8px; align-items: center; }
.icon-chip { border: 0; color: inherit; cursor: pointer; padding: 8px 10px; }
.icon-chip .icon { width: 22px; height: 22px; }
.lex-body { overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding-bottom: 4px; }
.rarity-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.rarity {
  border: 0; border-radius: 12px; padding: 8px 4px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font: inherit; color: var(--ink);
}
.rarity b { font-size: 20px; }
.rarity span { font-size: 11px; font-weight: 600; }
.rarity.r0 { background: #d9d3f0; }
.rarity.r1 { background: #9fe0c2; }
.rarity.r2 { background: #9cc8ff; }
.rarity.r3 { background: linear-gradient(135deg, #ffe08a, #f2a93b); }
.lex-sets { display: flex; flex-direction: column; gap: 8px; }
.lex-set {
  display: flex; align-items: center; gap: 12px;
  background: var(--glass); border-radius: 14px; padding: 10px 12px; cursor: pointer;
}
.lex-info { flex: 1; display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; align-items: center; }
.lex-info span { font-size: 13px; opacity: 0.7; }
.lex-info .bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.lex-info .bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.claim {
  border: 0; border-radius: 999px; padding: 8px 12px; cursor: pointer;
  background: var(--accent); color: var(--ink); font: inherit; font-weight: 700;
  animation: bump 1.2s ease-in-out infinite;
}

.tcard { background: none; border: 0; color: inherit; font: inherit; cursor: pointer; padding: 0; }
.framed {
  display: block; margin: 0 auto;
  border-radius: 6px;
  box-shadow: 0 0 0 4px var(--frame1), 0 0 0 7px var(--frame2), 0 8px 18px rgba(0, 0, 0, 0.3);
}

.overlay {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(10, 8, 26, 0.6);
}
.overlay[hidden] { display: none; }
.overlay .sheet {
  width: 100%; max-width: 520px; max-height: 85dvh;
  display: flex; flex-direction: column;
  background: var(--bg1);
  border-radius: 24px 24px 0 0;
  padding: 16px 16px max(16px, env(safe-area-inset-bottom));
  animation: slide-up 0.25s ease-out;
}
:is(.overlay, .page) header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
:is(.overlay, .page) h2 { margin: 0; font-size: 22px; }
.overlay .close {
  width: 40px; height: 40px; border: 0; border-radius: 50%;
  background: var(--glass); color: #fff; font-size: 24px; cursor: pointer;
}
.gallery-list {
  overflow-y: auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 16px;
  padding: 8px 4px;
}
.tcard { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.tcard canvas { border-radius: 4px; box-shadow: 0 0 0 3px var(--frame1), 0 0 0 5px var(--frame2), 0 6px 14px rgba(0, 0, 0, 0.35); margin-bottom: 6px; }
.tcard b { font-size: 15px; }
.tcard span { font-size: 13px; opacity: 0.65; }
@keyframes slide-up { from { transform: translateY(100%); } }

/* Definitions */
:is(.overlay, .page) .note { margin: -4px 0 8px; font-size: 14px; opacity: 0.7; }
:is(.overlay, .page) .note:empty { display: none; }
.defs-list { overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding-bottom: 4px; }
.def { background: var(--glass); border-radius: 14px; padding: 12px 14px; }
.def-word { font-size: 20px; font-weight: 700; letter-spacing: 2px; }
.def-word small { margin-left: 8px; font-size: 13px; font-weight: 500; letter-spacing: 0; opacity: 0.65; }
.def ol { margin: 6px 0 0; padding-left: 20px; }
.def li { margin: 4px 0; font-size: 15px; line-height: 1.35; }
.def li i { color: var(--accent); font-style: normal; font-size: 12px; margin-right: 6px; text-transform: uppercase; }
.def p, .defs-list > p { margin: 6px 0 0; font-size: 14px; opacity: 0.65; }
.credit { margin: 10px 0 0; font-size: 11px; opacity: 0.45; text-align: center; }
.cell.filled { cursor: pointer; }
#nextBtn {
  border: 0; border-radius: 999px;
  background: var(--accent2); color: #fff;
  font: inherit; font-size: 18px; font-weight: 600;
  padding: 12px 28px; cursor: pointer;
}

/* Achievements & frames */
.settings-body h3 small { text-transform: none; letter-spacing: 0; font-weight: 500; margin-left: 6px; }
.achv-list { display: flex; flex-direction: column; gap: 8px; }
.achv { display: flex; align-items: center; gap: 12px; background: var(--glass); border-radius: 14px; padding: 10px 12px; }
.achv.done { opacity: 0.6; }
.achv-info { flex: 1; display: grid; grid-template-columns: 1fr auto; gap: 3px 8px; align-items: center; min-width: 0; }
.achv-info b { font-size: 15px; }
.achv-count { font-size: 13px; opacity: 0.75; }
.achv-desc { grid-column: 1 / -1; font-size: 13px; opacity: 0.7; }
.achv-info .bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.achv-info .bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.pips { grid-column: 1 / -1; font-size: 11px; letter-spacing: 2px; color: var(--accent); }
.frame-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.frame-swatch {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--glass); border: 2px solid transparent; border-radius: 12px; padding: 10px 4px;
  color: inherit; font: inherit; font-size: 13px; cursor: pointer;
}
.frame-swatch i {
  width: 26px; height: 38px; border-radius: 3px; background: #231d38;
  box-shadow: 0 0 0 3px var(--a), 0 0 0 5px var(--b);
}
.frame-swatch.chosen { border-color: var(--accent); }
.frame-swatch.locked { opacity: 0.4; cursor: default; }

/* Social */
.name-field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; opacity: 0.9; }
.name-field input {
  background: var(--glass); border: 2px solid transparent; border-radius: 12px;
  padding: 10px 12px; color: #fff; font: inherit; font-size: 16px;
}
.name-field input:focus { outline: none; border-color: var(--accent); }
.challenge-text { font-size: 18px; line-height: 1.4; margin: 0 0 8px; }
#challenge .today-btn { margin-top: 12px; }
.viewer-body .share { margin: 4px 0 8px; color: #fff; border-color: var(--accent); }

/* Community */
.community-body { overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding-bottom: 4px; }
.community-body > .today-card { gap: 6px; }
.community-body > .today-card .share { align-self: flex-start; margin-top: 8px; color: #fff; border-color: var(--accent); }
.cm-kicker { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; opacity: 0.6; }
.cm-banner {
  display: flex; align-items: center; gap: 12px; border-radius: 16px; padding: 12px 14px;
  background: rgba(255, 181, 71, 0.22); box-shadow: inset 0 0 0 1px rgba(255, 181, 71, 0.5);
}
.cm-banner span { flex: 1; font-size: 15px; line-height: 1.35; }
.cm-banner .today-btn { margin: 0; }
.cm-avatars { display: flex; gap: 6px; margin: 2px 0; }
.cm-avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.16); font-weight: 700; font-size: 14px;
}
.cm-avatar.more { background: none; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3); font-size: 12px; }
.cm-back {
  align-self: flex-start; border: 0; background: none; color: var(--accent); cursor: pointer;
  font: inherit; font-weight: 600; padding: 4px 0;
}
.cm-title { margin: -8px 0 0; font-size: 20px; }
.cm-section { display: flex; flex-direction: column; gap: 8px; }
.cm-section h3 { margin: 0; font-size: 14px; text-transform: uppercase; letter-spacing: 1px; opacity: 0.6; }
.cm-section .note { margin: 0; }
.cm-code { display: flex; align-items: center; gap: 12px; background: var(--glass); border-radius: 14px; padding: 12px 14px; }
.cm-code span { font-size: 14px; opacity: 0.75; }
.cm-code b { font-size: 22px; letter-spacing: 3px; flex: 1; }
.cm-code .share { margin: 0; color: #fff; border-color: var(--accent); }
.cm-input { display: flex; gap: 8px; }
.cm-input input {
  flex: 1; min-width: 0; background: var(--glass); border: 2px solid transparent; border-radius: 12px;
  padding: 10px 12px; color: #fff; font: inherit; font-size: 16px; text-transform: none;
}
.cm-input input:focus { outline: none; border-color: var(--accent); }
.cm-input .today-btn { margin: 0; }
.cm-friends { display: flex; flex-direction: column; gap: 8px; }
.cm-friend { display: flex; align-items: center; gap: 10px; background: var(--glass); border-radius: 14px; padding: 10px 12px; }
.cm-friend > div:first-child { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cm-friend small { font-size: 12px; opacity: 0.7; }
.cm-actions { display: flex; gap: 6px; }
.cm-gift-btn {
  border: 0; border-radius: 999px; padding: 8px 12px; background: rgba(255, 255, 255, 0.14);
  color: #f2c94c; font: inherit; font-size: 14px; font-weight: 600; white-space: nowrap; cursor: pointer;
}
.cm-circle { display: flex; gap: 16px; align-items: center; background: var(--glass); border-radius: 14px; padding: 14px; }
.cm-circle canvas { flex: none; }
.cm-circle-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cm-circle-info small { font-size: 13px; opacity: 0.75; }
.cm-circle-info .share { align-self: flex-start; color: #fff; border-color: var(--accent); }
.cm-board { margin: 0; padding: 0; list-style: none; counter-reset: rank; display: flex; flex-direction: column; gap: 4px; }
.cm-board li {
  counter-increment: rank; display: flex; justify-content: space-between; gap: 8px;
  background: var(--glass); border-radius: 10px; padding: 8px 12px; font-size: 15px;
}
.cm-board li::before { content: counter(rank) '.'; opacity: 0.6; width: 24px; flex: none; }
.cm-board li span { flex: 1; }
.cm-board li small { opacity: 0.7; }
.cm-board li.me { background: rgba(255, 181, 71, 0.25); }

/* Account */
.account-box { display: flex; flex-direction: column; gap: 10px; background: var(--glass); border-radius: 14px; padding: 14px; }
.account-box .note { margin: 0; }
.account-who { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.account-or { margin: 0; text-align: center; font-size: 13px; opacity: 0.6; }
.account-form { display: flex; flex-direction: column; gap: 8px; }
.account-form input {
  background: rgba(0, 0, 0, 0.2); border: 2px solid transparent; border-radius: 12px;
  padding: 10px 12px; color: #fff; font: inherit; font-size: 16px;
}
.account-form input:focus { outline: none; border-color: var(--accent); }
.account-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.account-actions .today-btn, .account-actions .share, .account-actions .danger { margin: 0; }
.account-actions .share { color: #fff; border-color: var(--accent); }
.google-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: #fff; color: #1f1f1f; border: 0; border-radius: 999px; padding: 11px 18px;
  font: inherit; font-weight: 600; cursor: pointer;
}
.google-btn::before {
  content: 'G'; font-weight: 700; font-size: 18px;
  background: conic-gradient(#ea4335 0 25%, #fbbc05 0 50%, #34a853 0 75%, #4285f4 0);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.link-btn { align-self: flex-start; background: none; border: 0; color: inherit; opacity: 0.7; font: inherit; font-size: 14px; text-decoration: underline; cursor: pointer; padding: 0; }
button:disabled { opacity: 0.5; cursor: default; }
.save-options { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.save-option {
  display: flex; flex-direction: column; gap: 4px; align-items: flex-start; text-align: left;
  background: var(--glass); border: 2px solid transparent; border-radius: 14px; padding: 14px;
  color: inherit; font: inherit; cursor: pointer;
}
.save-option:hover, .save-option:focus-visible { border-color: var(--accent); }
.save-option span { font-size: 14px; opacity: 0.75; }

/* Tab bar and full-screen pages */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 8;
  height: var(--tabbar); padding-bottom: env(safe-area-inset-bottom);
  display: flex; justify-content: center;
  background: color-mix(in srgb, var(--bg1) 85%, #000);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.tab {
  position: relative; flex: 1; max-width: 104px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  background: none; border: 0; color: rgba(255, 255, 255, 0.55); font: inherit; font-size: 11px; font-weight: 600; cursor: pointer;
}
.tab .icon { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--accent); }
.tab.badge::after {
  content: ''; position: absolute; top: 8px; left: calc(50% + 8px);
  width: 9px; height: 9px; border-radius: 50%; background: var(--accent2);
}
.page {
  position: fixed; left: 0; right: 0; top: 0; bottom: var(--tabbar); z-index: 6;
  display: flex; flex-direction: column;
  background: radial-gradient(130% 90% at 50% 0%, var(--bg2), var(--bg1));
  background-color: var(--bg1);
  padding: max(16px, env(safe-area-inset-top)) 16px 8px;
}
.page[hidden] { display: none; }
.page .sheet { flex: 1; min-height: 0; width: 100%; max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; }
.page header { min-height: 40px; }
.page h2 { font-size: 26px; }
.circle-chip[hidden] { display: none; }
.circle-chip { border: 0; color: inherit; font: inherit; cursor: pointer; padding: 6px 12px; font-size: 15px; }
.win-social {
  margin: 12px 0 0 !important; padding: 10px 12px; border-radius: 12px;
  background: rgba(255, 181, 71, 0.18); opacity: 1 !important; font-size: 15px;
  display: flex; flex-direction: column; gap: 4px; align-items: center;
}
.win-social[hidden] { display: none; }
.win-social .link-btn { align-self: center; color: var(--accent2); opacity: 1; }

/* Compact win card: tapestry beside its name and story, buttons side by side. */
#win .card { padding: 22px 20px 18px; }
#win h2 { margin-bottom: 12px; }
.win-head { display: flex; gap: 14px; align-items: center; text-align: left; }
.win-head .framed { flex: none; margin: 4px 6px 4px 7px; }
.win-head canvas[hidden] + .win-info { text-align: center; }
.win-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
#win .win-info .tname { margin: 0; font-size: 17px; }
#win .win-info .muted { margin: 0; font-size: 13px; }
#win .win-info .story { margin: 6px 0 0; font-size: 14px; line-height: 1.3; }
#win .word-of-level { margin-top: 10px; padding: 8px 12px; }
#win .win-social { margin-top: 8px !important; padding: 8px 12px; font-size: 14px; }
#win #winText { margin: 10px 0 14px; font-size: 16px; }
.win-actions { display: flex; gap: 8px; justify-content: center; align-items: center; flex-wrap: wrap; }
.win-actions .share { margin: 0; padding: 10px 16px; }
.win-actions #nextBtn { padding: 12px 22px; }

.name-note { color: var(--accent2); font-size: 13px; min-height: 0; }
.name-note:empty { display: none; }
#nameInput[aria-invalid="true"] { border-color: var(--accent2); }

.delete-box { border-top: 1px solid rgba(255, 255, 255, 0.1); padding-top: 10px; }
.delete-confirm { display: flex; flex-direction: column; gap: 8px; }
.delete-confirm p { margin: 0; font-size: 14px; line-height: 1.35; }
.delete-confirm input { background: rgba(0, 0, 0, 0.2); border: 2px solid transparent; border-radius: 12px; padding: 10px 12px; color: #fff; font: inherit; font-size: 16px; }
.delete-confirm .danger { align-self: flex-start; }

.credit a { color: inherit; }

/* Tapestry backdrop: the tapestry being woven hangs behind the play screen, woven only as far
   as your progress. The shade fades its edges and keeps the middle calm behind the puzzle. */
#backdrop, #backdropGuide {
  position: fixed; top: 0; left: 50%; transform: translateX(-50%);
  z-index: 0; pointer-events: none; opacity: 0.2;
  transition: opacity 0.6s;
}
#backdropShade {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(ellipse 75% 60% at 50% 45%, transparent 30%, var(--bg1) 100%);
}
/* The guide is the whole design, very faint, like the cartoon a weaver hangs behind the loom. */
#backdropGuide { opacity: 0.06; }
#backdrop[hidden], #backdropGuide[hidden], #backdropShade[hidden] { display: none; }
/* Over the backdrop, empty squares and the wheel get a darker backing so they stay readable. */
body.with-backdrop { --empty: color-mix(in srgb, var(--bg1) 82%, #fff 10%); }
body.with-backdrop .cell:not(.filled) { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16); }
body.with-backdrop #wheel { background: color-mix(in srgb, var(--bg1) 85%, transparent); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1); }
/* A soft pool of shade behind the grid, so the words sit on calm ground without a hard panel.
   It spreads only into the app's 16px side margin: any wider and Chrome widens the page to fit it,
   which pushes the fixed tab bar below the bottom of a full-screen phone. */
body.with-backdrop #board { position: relative; }
body.with-backdrop #board::before {
  content: ''; position: absolute; inset: -4% -16px; z-index: -1; pointer-events: none;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--bg1) 80%, transparent) 55%, transparent);
}
body.with-backdrop .round { background: color-mix(in srgb, var(--bg1) 70%, rgba(255, 255, 255, 0.2)); }
body.with-backdrop .preview em { opacity: 0.8; }

/* Language choice on first launch */
.lang-choice .sheet { max-width: 420px; margin: auto; border-radius: 24px; }
.lang-choice { align-items: center; padding: 16px; }
.lang-choice h2 { font-size: 20px; text-align: center; margin-bottom: 6px; }
.lang-choice .note { text-align: center; }
.lang-options { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.lang-option {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  background: var(--glass); border: 2px solid transparent; border-radius: 16px; padding: 14px 16px;
  color: inherit; font: inherit; cursor: pointer; text-align: left;
}
.lang-option b { font-size: 20px; }
.lang-option span { font-size: 14px; opacity: 0.7; }
.lang-option.preferred { border-color: var(--accent); }
.name-field select {
  background: var(--glass); border: 2px solid transparent; border-radius: 12px; padding: 10px 12px;
  color: #fff; font: inherit; font-size: 16px;
}
.name-field select option { color: #000; }

/* Greek: Fredoka has no Greek letters, so Greek mode uses Comfortaa, a rounded font with full Greek. */
html[lang="el"] body, html[lang="el"] button, html[lang="el"] input, html[lang="el"] select { font-family: Comfortaa, Fredoka, ui-rounded, "Segoe UI", system-ui, sans-serif; }

/* Supporter packs */
.shop-list { display: grid; gap: 10px; }
.pack { display: flex; flex-direction: column; gap: 8px; background: var(--glass); border-radius: 14px; padding: 14px; border: 2px solid transparent; }
.pack-big { border-color: var(--accent); box-shadow: 0 0 18px rgba(242, 201, 76, 0.18); }
.pack-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.pack-head b { font-size: 17px; }
.pack-price { font-weight: 700; color: var(--accent); white-space: nowrap; }
.pack-perks { margin: 0; padding-left: 18px; font-size: 14px; opacity: 0.85; display: grid; gap: 2px; }
.pack-frames { display: flex; gap: 12px; padding: 4px 4px 2px; flex-wrap: wrap; }
.pack-frames i {
  width: 16px; height: 24px; border-radius: 2px; background: #231d38;
  box-shadow: 0 0 0 3px var(--a), 0 0 0 5px var(--b);
}
.pack .today-btn { margin-top: 2px; }
#thanks .pack-perks { margin: 0 0 14px; }
.pack .today-btn:disabled { opacity: 0.5; cursor: default; }
.coin-shop { display: flex; flex-direction: column; gap: 8px; background: var(--glass); border-radius: 14px; padding: 14px; }
.coin-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 15px; }
.coin-row .today-btn, .coin-row .share { margin: 0; min-width: 84px; }
.coin-row .share { color: #fff; border-color: var(--accent); }
.coin-row button:disabled { opacity: 0.5; cursor: default; }

/* Placeholder rewarded ad (ads.js), shown until AdSense is set up */
.fake-ad {
  position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 24px; text-align: center; background: #0b0a14; color: #fff;
}
.fake-ad[hidden] { display: none; }
.fake-ad .close {
  position: absolute; top: max(16px, env(safe-area-inset-top)); right: 16px;
  width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--glass); color: #fff; font-size: 24px; cursor: pointer;
}
.fake-ad-label { margin: 0; font-size: 13px; letter-spacing: 2px; text-transform: uppercase; opacity: 0.5; }
.fake-ad-body { margin: 0; font-size: 18px; max-width: 320px; }
.fake-ad-count { margin: 0; font-size: 22px; font-weight: 700; color: var(--accent); }

/* Weekly board: Everyone / Friends */
.cm-scope { display: flex; gap: 4px; background: var(--glass); border-radius: 999px; padding: 3px; align-self: flex-start; }
.cm-scope button {
  border: 0; border-radius: 999px; padding: 6px 14px; background: transparent; color: inherit;
  font: inherit; font-size: 14px; cursor: pointer; opacity: 0.75;
}
.cm-scope button.on { background: var(--accent); color: var(--ink); font-weight: 700; opacity: 1; }
