/* ==========================================================
   Çengel — design system (light)
   Bright paper-white surfaces, ink text, one violet accent + teal secondary.
   Depth comes from soft layered shadows and a 1-2px "key" edge on tiles.
   ========================================================== */
:root {
  --bg: #f4f5fa;
  --surface: rgba(255, 255, 255, .82);
  --surface-solid: #ffffff;
  --surface-2: #f6f7fb;
  --surface-3: #e8eaf2;
  --line: #e3e6ef;
  --line-2: #d4d8e4;
  --text: #151826;
  --muted: #5d6478;
  --faint: #959bb0;
  --accent: #6d4aff;
  --accent-2: #5a36f0;
  --accent-soft: rgba(109, 74, 255, .1);
  --accent-tint: #efeaff;
  --cyan: #0e9fb8;
  --cyan-soft: #e3f6f9;
  --ok: #10b981;
  --ok-soft: #e3f8ef;
  --bad: #ef4444;
  --bad-soft: #fde8e8;
  --warn: #f59e0b;
  --flame: #f97316;
  --tile: #ffffff;
  --tile-edge: #d6dae6;
  --shadow-sm: 0 1px 2px rgba(20, 24, 40, .06), 0 2px 6px rgba(20, 24, 40, .05);
  --shadow: 0 1px 2px rgba(20, 24, 40, .05), 0 8px 24px -8px rgba(20, 24, 40, .12);
  --shadow-lg: 0 2px 4px rgba(20, 24, 40, .04), 0 24px 60px -20px rgba(20, 24, 40, .25);
  --radius: 16px;
  --radius-sm: 10px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.2, 1.5, .4, 1);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Space Grotesk', var(--font);
  --nav-w: 236px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font: 15px/1.5 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -.015em; margin: 0; }
.muted { color: var(--muted); }
.sm { font-size: .82rem; }
.i { width: 18px; height: 18px; flex: none; }
[hidden] { display: none !important; }

/* ---------- Ambient background ---------- */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: linear-gradient(180deg, #f7f7fc, var(--bg)); }
.aurora { position: absolute; width: 55vmax; height: 55vmax; border-radius: 50%; filter: blur(100px); opacity: .35; animation: drift 28s ease-in-out infinite alternate; }
.a1 { background: #c9bbff; top: -28vmax; left: -12vmax; }
.a2 { background: #b6ecf5; bottom: -32vmax; right: -18vmax; animation-delay: -9s; }
.a3 { background: #ffd9e8; top: 35%; left: 50%; width: 30vmax; height: 30vmax; opacity: .3; animation-delay: -17s; }
@keyframes drift { to { transform: translate(5vmax, 4vmax) scale(1.1); } }
.gridbg { position: absolute; inset: 0; background-image: radial-gradient(#d3d7e3 1px, transparent 1px); background-size: 22px 22px; mask-image: radial-gradient(ellipse at 50% 20%, #000 20%, transparent 75%); opacity: .6; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--nav-w) 1fr; min-height: 100vh; }
.nav { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 24px; padding: 20px 14px; border-right: 1px solid var(--line); background: rgba(255, 255, 255, .7); backdrop-filter: blur(20px); }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px; }
.mark { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font: 700 1.2rem var(--display); color: #fff; background: linear-gradient(135deg, #7c5cff, #4f46e5 60%, #0e9fb8); box-shadow: 0 6px 16px rgba(109, 74, 255, .35), inset 0 1px 0 rgba(255, 255, 255, .35); }
.brand-txt { display: flex; flex-direction: column; line-height: 1.15; }
.brand-txt b { font: 600 1.05rem var(--display); }
.brand-txt small { color: var(--muted); font-size: .74rem; }
.navlinks { display: flex; flex-direction: column; gap: 2px; }
.navlinks a { position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--muted); font-weight: 500; transition: color .2s, background .2s; }
.navlinks a:hover { color: var(--text); background: var(--surface-2); }
.navlinks a.active { color: var(--accent-2); background: var(--accent-tint); font-weight: 600; }
.navlinks a.active::before { content: ""; position: absolute; left: -14px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.navlinks a .count { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: grid; place-items: center; font: 600 .7rem var(--display); font-style: normal; color: #fff; background: var(--bad); }
.navfoot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.me { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-solid); box-shadow: var(--shadow-sm); }
.me span:last-child { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.me small { color: var(--muted); font-size: .75rem; }
.av { width: 34px; height: 34px; flex: none; border-radius: 50%; display: grid; place-items: center; font: 600 .95rem var(--display); background: linear-gradient(135deg, #7c5cff, #0e9fb8); color: #fff; }
.av.xl { width: 64px; height: 64px; font-size: 1.6rem; }

.main { min-width: 0; padding: 0 30px 48px; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 18px 0 14px; background: linear-gradient(var(--bg) 65%, rgba(244, 245, 250, 0)); }
.titles h1 { font-size: 1.65rem; font-weight: 600; }
.titles p { margin: 2px 0 0; color: var(--muted); font-size: .88rem; min-height: 1.3em; }
.stats { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; padding: 6px 12px; min-width: 64px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-solid); box-shadow: var(--shadow-sm); }
.stat .k { font-size: .64rem; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); font-weight: 600; }
.stat .v { font: 600 1.05rem var(--display); font-variant-numeric: tabular-nums; }
.stat.bump .v { animation: bump .35s var(--spring); }
#stCombo.hot { border-color: #fed7aa; background: #fff7ed; }
#stCombo.hot .v { color: var(--flame); }
@keyframes bump { 40% { transform: scale(1.2); color: var(--accent); } }
.chip-btn { display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-solid); color: var(--faint); cursor: pointer; transition: .2s; box-shadow: var(--shadow-sm); }
.chip-btn b { font: 600 1.05rem var(--display); color: var(--muted); }
.chip-btn.alive { color: var(--flame); border-color: #fed7aa; background: #fff7ed; }
.chip-btn.alive b { color: var(--text); }
.chip-btn.alive .i { animation: flicker 2.2s ease-in-out infinite; }
.chip-btn.risk { color: var(--bad); border-color: #fecaca; background: var(--bad-soft); animation: riskPulse 1.6s ease-in-out infinite; }
@keyframes riskPulse { 50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, .12); } }
@keyframes flicker { 50% { transform: scale(1.1) rotate(-4deg); } }

/* Progress ring (conic) */
.ring { --p: 0; position: relative; width: 44px; height: 44px; border-radius: 50%; border: none; padding: 0; cursor: pointer; display: grid; place-items: center; background: conic-gradient(var(--accent) calc(var(--p) * 1turn), var(--surface-3) 0); box-shadow: var(--shadow-sm); }
.ring::before { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: var(--surface-solid); }
.ring > * { position: relative; }
.ring b { font: 600 .7rem var(--display); }
.ring.full { background: conic-gradient(var(--ok) 1turn, var(--ok) 0); }
.ring.full b { color: var(--ok); font-size: .9rem; }
.ring.big { width: 136px; height: 136px; flex: none; display: flex; flex-direction: column; justify-content: center; box-shadow: none; }
.ring.big::before { inset: 11px; }
.ring.big b { font-size: 2rem; }
.ring.big small { color: var(--muted); font-size: .75rem; }

/* ---------- Views ---------- */
.view { display: none; }
.view.active { display: block; animation: viewIn .45s var(--ease); }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } }

.card { position: relative; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface-solid); padding: 18px; box-shadow: var(--shadow); }
.card h3 { display: flex; align-items: center; gap: 8px; font-size: 1rem; font-weight: 600; margin-bottom: 12px; }
.card h3 .i { color: var(--accent); }
.card h3 small { margin-left: auto; font-family: var(--font); font-weight: 500; }

/* ---------- Controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--surface-solid); color: var(--text); font-weight: 500; font-size: .9rem; cursor: pointer; white-space: nowrap; box-shadow: 0 1px 0 var(--line-2), var(--shadow-sm); transition: transform .15s var(--ease), background .2s, border-color .2s, box-shadow .2s; }
.btn:hover { background: var(--surface-2); transform: translateY(-1px); }
.btn:active { transform: translateY(1px) scale(.98); box-shadow: none; }
.btn .i { width: 16px; height: 16px; }
.btn.primary { color: #fff; border-color: transparent; background: linear-gradient(180deg, #7c5cff, #5a36f0); box-shadow: 0 2px 0 #4523d6, 0 8px 20px -6px rgba(109, 74, 255, .55); }
.btn.primary:hover { background: linear-gradient(180deg, #8b6eff, #6342f5); }
.btn.ghost { background: transparent; box-shadow: none; border-color: var(--line); }
.btn.ghost:hover { background: var(--surface-solid); }
.btn.block { width: 100%; }
.btn.sm { height: 32px; padding: 0 10px; font-size: .8rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.danger { color: var(--bad); }
.iconbtn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-solid); cursor: pointer; color: var(--muted); transition: .2s; box-shadow: var(--shadow-sm); }
.iconbtn:hover { color: var(--accent); }
.iconbtn.sm { width: 30px; height: 30px; border-radius: 8px; box-shadow: none; }
.iconbtn.sm .i { width: 15px; height: 15px; }
select, .input { height: 38px; padding: 0 34px 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--surface-solid) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%235d6478' stroke-width='2'%3E%3Cpath d='m3 4.5 3 3 3-3'/%3E%3C/svg%3E") no-repeat right 12px center; appearance: none; cursor: pointer; box-shadow: var(--shadow-sm); }
.input { background-image: none; padding: 0 12px; cursor: text; }
.input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 12px; background: var(--surface-3); border: 1px solid var(--line); }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 9px; color: var(--muted); font-weight: 500; font-size: .86rem; cursor: pointer; transition: .2s; display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
.seg button small { font-size: .7rem; color: var(--faint); }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface-solid); color: var(--text); box-shadow: var(--shadow-sm); }
.seg button.on small { color: var(--accent); }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: .86rem; color: var(--muted); }
.switch input { display: none; }
.switch span { position: relative; width: 36px; height: 20px; border-radius: 20px; background: var(--line-2); transition: .25s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: .25s var(--spring); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch em { font-style: normal; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: .8rem; font-weight: 500; border: 1px solid var(--line); background: var(--surface-2); }
.pill .i { width: 14px; height: 14px; }
.pill.ok { color: #047857; border-color: #a7f3d0; background: var(--ok-soft); }
.pbar-wrap { height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.pbar-wrap i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--cyan)); transition: width .6s var(--ease); }

/* ---------- Play ---------- */
.play { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 24px; align-items: start; }
.board { min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.toolbar .grow { flex: 1; }
.tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.cluebar { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 16px; border-radius: var(--radius); border: 1px solid #d9d0ff; background: linear-gradient(90deg, #f1ecff, #eafafc); box-shadow: var(--shadow); }
.cluebar.swap { animation: barIn .35s var(--ease); }
@keyframes barIn { from { opacity: .3; transform: translateY(-4px); } }
.cluebar .tag { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 8px; background: var(--accent); color: #fff; font: 600 .95rem var(--display); box-shadow: 0 4px 10px rgba(109, 74, 255, .35); }
.cluebar .tag i { font-style: normal; opacity: .85; }
.clue-text { font: 600 1.2rem var(--display); }
.cluebar .len { color: var(--muted); font-size: .82rem; }
.cluebar .extra { margin-left: auto; color: #047857; font-size: .9rem; animation: barIn .4s var(--ease); }

.stage3d { perspective: 1300px; display: flex; justify-content: center; padding: 16px 0 26px; }
.grid { --s: 44px; --rx: 7deg; --ry: 0deg; display: grid; gap: 4px; padding: 14px; border-radius: 22px; border: 1px solid var(--line); background: linear-gradient(180deg, #ffffff, #f3f4f9); box-shadow: 0 2px 0 var(--line-2), 0 30px 60px -24px rgba(40, 30, 90, .28), 0 10px 20px -10px rgba(20, 24, 40, .12); transform: rotateX(var(--rx)) rotateY(var(--ry)); transform-style: preserve-3d; transition: transform .35s var(--ease); user-select: none; touch-action: manipulation; }
.grid.intro { animation: gridIn .7s var(--ease); }
@keyframes gridIn { from { opacity: 0; transform: rotateX(35deg) translateY(24px) scale(.94); } }
.c { width: var(--s); height: var(--s); position: relative; display: grid; place-items: center; border-radius: 9px; transition: transform .16s var(--ease), background-color .2s, box-shadow .2s, border-color .2s, color .2s; }
.grid.intro .c { animation: tileIn .45s var(--ease) backwards; animation-delay: var(--delay); }
@keyframes tileIn { from { opacity: 0; transform: translateY(-12px) rotateX(70deg); } }
.c.blk { background: transparent; }
.c.let { cursor: pointer; font: 600 calc(var(--s) * .5) var(--display); color: var(--text); border: 1px solid var(--tile-edge); background: var(--tile); box-shadow: 0 2px 0 var(--tile-edge), 0 4px 10px -4px rgba(20, 24, 40, .15); }
.c.let:hover { transform: translateY(-2px); }
.c.let.word { background: #efeaff; border-color: #c9bcff; box-shadow: 0 2px 0 #c9bcff, 0 4px 10px -4px rgba(109, 74, 255, .25); }
.c.let.cur { z-index: 2; color: #fff; background: linear-gradient(180deg, #7c5cff, #5a36f0); border-color: #4a2bd9; transform: translateY(-3px) translateZ(12px); box-shadow: 0 3px 0 #3d22b5, 0 10px 22px -4px rgba(109, 74, 255, .55); }
.c.let.cur:empty::after { content: ""; position: absolute; bottom: 22%; width: 34%; height: 2px; border-radius: 2px; background: #fff; animation: caret 1s steps(2) infinite; }
@keyframes caret { 50% { opacity: 0; } }
.c.let.typed { animation: pop .26s var(--spring); }
@keyframes pop { from { transform: translateY(-3px) scale(.7); } }
.c.let.bad { color: var(--bad); background: var(--bad-soft); border-color: #fca5a5; box-shadow: 0 2px 0 #fca5a5; animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.c.let.rev { color: var(--cyan); }
.c.let.flip { animation: flip .55s var(--ease) both; animation-delay: calc(var(--i) * 55ms); }
@keyframes flip { 50% { transform: rotateX(180deg) translateZ(8px); background: var(--ok); color: #fff; } }
.c.let.ok { color: #065f46; background: var(--ok-soft); border-color: #6ee7b7; box-shadow: 0 2px 0 #6ee7b7; animation: wave 1.6s var(--ease) infinite; animation-delay: calc(var(--d) * 55ms); }
@keyframes wave { 50% { transform: translateY(-5px) translateZ(8px); } }
.c.clue { cursor: pointer; display: flex; flex-direction: column; justify-content: center; gap: 1px; color: var(--cyan); border: 1px solid #c6ecf2; background: var(--cyan-soft); font: 600 calc(var(--s) * .24) var(--display); line-height: 1; }
.c.clue em { font-style: normal; color: #0b6b7c; margin-right: 1px; }
.c.clue:hover { border-color: var(--cyan); }
.c.clue.hl { color: #fff; border-color: #0b8aa1; background: linear-gradient(180deg, #14b4cf, #0e9fb8); box-shadow: 0 2px 0 #0b7d91, 0 6px 14px -4px rgba(14, 159, 184, .5); }
.c.clue.hl em { color: #fff; }

.clues { position: sticky; top: 92px; max-height: calc(100vh - 110px); overflow: auto; padding: 16px; }
.clues .prog { margin-bottom: 14px; }
.clues .ph { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); margin-bottom: 6px; }
.clues h3 { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); margin: 14px 0 6px; }
.clues h3 span { color: var(--cyan); }
.clues ol { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 2px; }
.clues li { display: grid; grid-template-columns: 26px 1fr auto; gap: 8px; align-items: start; padding: 8px 10px; border-radius: 10px; cursor: pointer; font-size: .92rem; transition: background .2s, transform .2s var(--ease); }
.clues li:hover { background: var(--surface-2); }
.clues li b { font: 600 .8rem var(--display); color: var(--accent); padding-top: 2px; }
.clues li small { display: block; color: #047857; font-size: .78rem; }
.clues li em { font-style: normal; font-size: .75rem; color: var(--faint); padding-top: 2px; }
.clues li em .i { width: 15px; height: 15px; color: var(--ok); }
.clues li.act { background: var(--accent-tint); transform: translateX(3px); box-shadow: inset 3px 0 0 var(--accent); }
.clues li.done > span { color: var(--muted); }

/* On-screen keyboard (touch devices) */
.osk { display: none; flex-direction: column; gap: 6px; user-select: none; }
.osk .row { display: flex; justify-content: center; gap: 5px; }
.osk button { flex: 1; max-width: 42px; height: 46px; border-radius: 9px; border: 1px solid var(--tile-edge); background: var(--tile); box-shadow: 0 2px 0 var(--tile-edge); font: 600 1.05rem var(--display); cursor: pointer; display: grid; place-items: center; transition: transform .08s; touch-action: manipulation; }
.osk button.wide { max-width: 60px; flex: 1.5; color: var(--muted); background: var(--surface-3); }
.osk button.down { transform: translateY(2px); background: var(--accent); color: #fff; box-shadow: none; }
@media (pointer: coarse) { .osk { display: flex; } }

/* Floating points */
.float { position: fixed; z-index: 30; pointer-events: none; font: 700 1rem var(--display); transform: translate(-50%, -50%); animation: floatUp .9s var(--ease) forwards; }
.float.pos { color: var(--ok); }
.float.neg { color: var(--bad); }
@keyframes floatUp { to { transform: translate(-50%, -60px) scale(1.25); opacity: 0; } }

/* ---------- Today ---------- */
.today-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.today-grid .card { animation: viewIn .5s var(--ease) backwards; }
.today-grid .card:nth-child(2) { animation-delay: .06s; } .today-grid .card:nth-child(3) { animation-delay: .12s; } .today-grid .card:nth-child(4) { animation-delay: .18s; }
.goal-card { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
.goal-card > div:last-child { flex: 1; min-width: 220px; }
.goal-card p { margin: 4px 0 14px; }
.streak-card { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; }
.streak-card .flame { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; background: var(--surface-3); color: var(--faint); }
.streak-card .flame .i { width: 34px; height: 34px; }
.streak-card.alive .flame { color: #fff; background: linear-gradient(160deg, #fdba74, #f97316); box-shadow: 0 8px 20px -6px rgba(249, 115, 22, .6); }
.streak-card.alive .flame .i { animation: flicker 2s ease-in-out infinite; }
.streak-card p { margin: 4px 0 0; }
.week { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; height: 90px; align-items: end; }
.wd { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.wd i { width: 100%; max-width: 30px; height: var(--h); min-height: 4px; border-radius: 6px; background: var(--surface-3); transition: height .8s var(--ease); }
.wd.hit i { background: linear-gradient(180deg, #fdba74, var(--flame)); }
.wd small { color: var(--faint); font-size: .72rem; }
.shields { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); }
.shields > div:nth-child(2) { flex: 1; display: flex; flex-direction: column; }
.shields small { font-size: .76rem; }
.sh-icons { display: flex; gap: 4px; }
.sh-icons span { color: var(--line-2); }
.sh-icons span .i { width: 24px; height: 24px; }
.sh-icons span.on { color: var(--cyan); }
.daily-card { display: flex; flex-direction: column; justify-content: space-between; gap: 18px; background: linear-gradient(135deg, #f1ecff, #e8f9fb); border-color: #d9d0ff; }
.daily-head { display: flex; gap: 14px; }
.daily-head > .i { width: 42px; height: 42px; padding: 10px; border-radius: 12px; background: var(--accent); color: #fff; box-shadow: 0 8px 18px -6px rgba(109, 74, 255, .6); }
.daily-head p { margin: 4px 0 0; }
.daily-foot { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.quests { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.quests li { display: grid; grid-template-columns: 38px 1fr auto; grid-template-rows: auto auto; column-gap: 12px; align-items: center; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); }
.quests .qi { grid-row: 1 / 3; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-solid); color: var(--muted); border: 1px solid var(--line); }
.quests .qb span { font-weight: 500; font-size: .92rem; }
.qbar { height: 6px; border-radius: 6px; background: var(--surface-3); margin-top: 6px; overflow: hidden; }
.qbar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--warn), var(--flame)); transition: width .8s var(--ease); }
.quests em { font-style: normal; font: 600 .85rem var(--display); color: var(--muted); }
.quests small { grid-column: 3; color: #b45309; font-size: .74rem; text-align: right; }
.quests li.done { border-color: #a7f3d0; background: var(--ok-soft); }
.quests li.done .qi { background: var(--ok); color: #fff; border-color: transparent; }
.quests li.done em { color: #047857; }
.quests li.done .qbar i { background: var(--ok); }
.banner { display: flex; align-items: center; gap: 14px; padding: 14px 16px; margin-bottom: 18px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface-solid); box-shadow: var(--shadow); animation: viewIn .5s var(--ease); }
.banner > div { flex: 1; display: flex; flex-direction: column; }
.banner span { color: var(--muted); font-size: .88rem; }
.banner > .i { width: 40px; height: 40px; padding: 9px; border-radius: 12px; }
.banner.risk { border-color: #fecaca; background: linear-gradient(90deg, #fff1f1, #fff7ed); }
.banner.risk > .i { color: #fff; background: linear-gradient(135deg, var(--bad), var(--flame)); animation: flicker 1.6s infinite; }

/* ---------- Map ---------- */
.rank { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.rank-badge { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; color: #fff; background: linear-gradient(160deg, #fcd34d, #f59e0b); box-shadow: 0 8px 18px -6px rgba(245, 158, 11, .6); }
.rank-badge .i { width: 28px; height: 28px; }
.rank-body { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.rank-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.rank-top b { font: 600 1.2rem var(--display); }
.stages { display: flex; flex-direction: column; gap: 14px; }
.stage { position: relative; padding: 18px 20px 32px; border-radius: var(--radius); border: 1px solid var(--line); background: linear-gradient(120deg, color-mix(in srgb, var(--sc) 12%, #fff), #fff 65%); box-shadow: var(--shadow); overflow: hidden; animation: viewIn .5s var(--ease) backwards; animation-delay: var(--d); }
.stage::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--sc); }
.stage.locked { opacity: .55; filter: saturate(.2); }
.stage-head { display: flex; justify-content: space-between; align-items: center; }
.stage-head small { color: color-mix(in srgb, var(--sc) 70%, #000); font-weight: 600; font-size: .76rem; letter-spacing: .06em; text-transform: uppercase; }
.stage-head h3 { margin: 2px 0 0; font-size: 1.2rem; }
.path { position: relative; display: flex; justify-content: space-between; align-items: center; margin-top: 22px; padding: 0 4%; }
.track { position: absolute; left: 8%; right: 8%; top: 50%; height: 4px; transform: translateY(-50%); border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.track i { display: block; height: 100%; background: var(--sc); transition: width .8s var(--ease); }
.node { position: relative; z-index: 1; width: 52px; height: 52px; border-radius: 50%; border: 2px solid var(--line-2); background: #fff; display: grid; place-items: center; font: 600 1.05rem var(--display); cursor: pointer; box-shadow: 0 3px 0 var(--line-2); transition: transform .2s var(--spring), box-shadow .2s; }
.node:hover { transform: translateY(-4px) scale(1.06); }
.node.done { border-color: var(--sc); color: color-mix(in srgb, var(--sc) 70%, #000); background: color-mix(in srgb, var(--sc) 12%, #fff); box-shadow: 0 3px 0 color-mix(in srgb, var(--sc) 55%, #fff); }
.node.cur { border-color: transparent; color: #fff; background: var(--sc); box-shadow: 0 3px 0 color-mix(in srgb, var(--sc) 65%, #000), 0 0 0 6px color-mix(in srgb, var(--sc) 22%, transparent); animation: nodePulse 1.8s ease-in-out infinite; }
@keyframes nodePulse { 50% { box-shadow: 0 3px 0 color-mix(in srgb, var(--sc) 65%, #000), 0 0 0 12px color-mix(in srgb, var(--sc) 8%, transparent); } }
.node.lock { color: var(--faint); cursor: not-allowed; background: var(--surface-2); }
.node.lock:hover { transform: none; }
.node.boss { width: 62px; height: 62px; }
.node.boss .i { width: 24px; height: 24px; }
.node.shake { animation: shake .35s; }
.node .st { position: absolute; top: calc(100% + 7px); display: flex; gap: 1px; font: 600 .7rem var(--font); color: color-mix(in srgb, var(--sc) 70%, #000); white-space: nowrap; }
.node .st i .i { width: 11px; height: 11px; color: var(--line-2); fill: var(--line-2); }
.node .st i.on .i { color: var(--warn); fill: var(--warn); }

/* ---------- Leaderboard ---------- */
.league { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.league > div:nth-child(2) { display: flex; flex-direction: column; }
.league b { font: 600 1.1rem var(--display); }
.league .reset { margin-left: auto; font-size: .82rem; }
.league-badge { --lc: var(--muted); width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; color: #fff; background: var(--lc); box-shadow: 0 6px 16px -6px var(--lc); }
.league-badge .i { width: 26px; height: 26px; }
.lb-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.lb-head select { min-width: 170px; }
.lb { display: flex; flex-direction: column; gap: 4px; }
.lb-row { display: grid; grid-template-columns: 34px 36px 1fr auto auto; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 12px; border: 1px solid transparent; transition: background .2s; animation: viewIn .4s var(--ease) backwards; animation-delay: var(--d); }
.lb-row:hover { background: var(--surface-2); }
.lb-row.me { border-color: #d9d0ff; background: var(--accent-tint); }
.pos { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font: 600 .9rem var(--display); color: var(--muted); background: var(--surface-3); }
.pos.p1 { color: #78350f; background: linear-gradient(135deg, #fde68a, #f59e0b); }
.pos.p2 { color: #1f2937; background: linear-gradient(135deg, #f1f5f9, #cbd5e1); }
.pos.p3 { color: #7c2d12; background: linear-gradient(135deg, #fed7aa, #f97316); }
.lb-row .name { display: flex; flex-direction: column; min-width: 0; }
.lb-row .name small { color: var(--muted); font-size: .76rem; }
.pts { font: 600 1.05rem var(--display); text-align: right; }
.pts small { color: var(--faint); font-size: .7rem; margin-left: 4px; }
.lb-row .act { display: flex; gap: 4px; }
.empty { text-align: center; padding: 34px 10px; color: var(--muted); }
.empty .i { width: 40px; height: 40px; color: var(--faint); }
.skeleton { height: 54px; border-radius: 12px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Social (friends / classes) ---------- */
.social { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 18px; }
.form-row { display: flex; gap: 8px; margin-bottom: 12px; }
.form-row .input { flex: 1; min-width: 0; }
.list { display: flex; flex-direction: column; gap: 6px; }
.list-row { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); }
.list-row .name { display: flex; flex-direction: column; min-width: 0; }
.list-row .name small { color: var(--muted); font-size: .76rem; }
.code { font: 700 1.05rem var(--display); letter-spacing: .14em; padding: 4px 10px; border-radius: 8px; background: var(--accent-tint); color: var(--accent-2); }
.class-detail { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; }
.tbl th { text-align: left; font-weight: 600; color: var(--faint); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 8px; border-bottom: 1px solid var(--line); }
.tbl tr:last-child td { border-bottom: 0; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); margin-right: 6px; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }

/* ---------- Profile ---------- */
.profile { display: flex; flex-direction: column; gap: 18px; max-width: 980px; }
.profile-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.profile-head > div { flex: 1; }
.profile-head p { margin: 2px 0 0; }
.sync { font-size: .78rem; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.sync .i { width: 14px; height: 14px; color: var(--ok); }
.auth { max-width: 460px; }
.auth p { margin: 12px 0; }
.auth label { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; color: var(--muted); margin-bottom: 12px; }
.auth input { height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text); font-size: 1rem; transition: border-color .2s, box-shadow .2s; }
.auth input:focus { outline: none; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 4px var(--accent-soft); }
.err { color: var(--bad); min-height: 1.2em; font-size: .86rem; margin: 0 0 10px !important; }
.stat-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.stat-card { display: flex; flex-direction: column; gap: 2px; padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-solid); box-shadow: var(--shadow-sm); }
.stat-card .i { color: var(--accent); margin-bottom: 6px; }
.stat-card b { font: 600 1.35rem var(--display); }
.stat-card span { color: var(--muted); font-size: .8rem; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.badge { display: flex; flex-direction: column; gap: 4px; padding: 14px; border-radius: 14px; border: 1px dashed var(--line-2); color: var(--faint); transition: .2s; }
.badge .i { width: 28px; height: 28px; margin-bottom: 4px; }
.badge b { font-size: .9rem; }
.badge small { font-size: .74rem; }
.badge.on { border-style: solid; border-color: #fde68a; color: var(--text); background: linear-gradient(160deg, #fffbeb, #fff); }
.badge.on .i { color: var(--warn); }
.badge.on small { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line-2); background: var(--surface-solid); padding: 4px 10px; border-radius: 999px; font: 500 .8rem var(--display); letter-spacing: .03em; cursor: pointer; transition: .2s; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.bad { border-color: #fca5a5; color: #b91c1c; background: var(--bad-soft); }
.settings .set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--line); }
.settings .set-row:first-of-type { border-top: 0; }

/* ---------- Review ---------- */
.review { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.rv-top { display: flex; align-items: center; gap: 12px; }
.rv-top .pbar-wrap { flex: 1; }
.rv-card { text-align: center; padding: 32px 22px; display: flex; flex-direction: column; align-items: center; gap: 10px; transition: border-color .3s, box-shadow .3s; animation: viewIn .4s var(--ease); }
.rv-card.shake { animation: shake .35s; }
.rv-card.right { border-color: #6ee7b7; box-shadow: 0 0 0 4px var(--ok-soft), var(--shadow); }
.rv-card.wrong { border-color: #fca5a5; box-shadow: 0 0 0 4px var(--bad-soft), var(--shadow); }
.rv-tr { font-size: 2.3rem; font-weight: 600; }
.rv-tr::first-letter { text-transform: uppercase; }
.rv-hint { display: inline-flex; align-items: center; gap: 8px; border: 1px dashed var(--line-2); background: none; padding: 6px 12px; border-radius: 10px; color: var(--muted); cursor: pointer; font-size: .85rem; }
.rv-hint span { filter: blur(5px); transition: filter .3s; }
.rv-hint.open span { filter: none; }
.slots { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 14px 0 4px; cursor: text; }
.slots span { width: 44px; height: 52px; border-radius: 10px; display: grid; place-items: center; font: 600 1.5rem var(--display); border: 1px solid var(--tile-edge); background: var(--tile); box-shadow: 0 2px 0 var(--tile-edge); transition: .2s var(--ease); }
.slots span.fill { animation: pop .25s var(--spring); border-color: #c9bcff; background: #f7f4ff; }
.slots span.cur { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), 0 2px 0 var(--tile-edge); }
.slots span.ok { color: #fff; background: var(--ok); border-color: #059669; box-shadow: 0 2px 0 #047857; animation: flip .5s var(--ease) both; animation-delay: calc(var(--i) * 50ms); }
.slots span.bad { color: #fff; background: var(--bad); border-color: #dc2626; box-shadow: 0 2px 0 #b91c1c; animation: flip .5s var(--ease) both; animation-delay: calc(var(--i) * 50ms); }
.rv-in { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.rv-fb { min-height: 26px; display: flex; align-items: center; gap: 8px; font-size: .92rem; }
.rv-card.right .rv-fb { color: #047857; }
.rv-card.wrong .rv-fb { color: #b91c1c; }
.row-btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }
.review-empty { max-width: 640px; margin: 0 auto; text-align: center; padding: 36px 22px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.review-empty > .i { width: 54px; height: 54px; padding: 13px; border-radius: 16px; color: var(--accent); background: var(--accent-tint); }
.review-empty.done > .i { color: #fff; background: var(--ok); }
.boxes { width: 100%; display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; height: 110px; align-items: end; margin: 8px 0; }
.bx { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bx i { width: 100%; max-width: 40px; height: var(--h); min-height: 4px; border-radius: 6px; background: linear-gradient(180deg, color-mix(in srgb, var(--accent) calc(40% + var(--i) * 12%), var(--cyan)), var(--accent)); transition: height .8s var(--ease); }
.bx b { font: 600 .9rem var(--display); }
.bx small { color: var(--faint); font-size: .68rem; white-space: nowrap; }

/* ---------- Win dialog ---------- */
.dialog { border: 0; padding: 0; background: transparent; color: var(--text); max-width: 500px; width: calc(100% - 32px); }
.dialog::backdrop { background: rgba(30, 32, 50, .35); backdrop-filter: blur(6px); animation: fade .3s; }
@keyframes fade { from { opacity: 0; } }
.win { position: relative; border-radius: 22px; padding: 28px 24px 22px; text-align: center; border: 1px solid var(--line); background: linear-gradient(180deg, #f1ecff, #fff 38%); box-shadow: var(--shadow-lg); animation: winIn .55s var(--spring); max-height: 88vh; overflow: auto; }
@keyframes winIn { from { opacity: 0; transform: translateY(30px) scale(.92) rotateX(20deg); } }
.win-stars { display: flex; justify-content: center; gap: 10px; margin-bottom: 10px; }
.win-stars span .i { width: 44px; height: 44px; color: var(--line-2); fill: var(--surface-3); }
.win-stars span.on .i { color: #f59e0b; fill: #fbbf24; filter: drop-shadow(0 6px 10px rgba(245, 158, 11, .4)); animation: starIn .5s var(--spring) backwards; animation-delay: calc(.3s + var(--i) * .15s); }
@keyframes starIn { from { transform: scale(0) rotate(-90deg); } }
.win h2 { font-size: 1.5rem; }
.win > p { margin: 6px 0 16px; min-height: 1em; }
.win-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.win-stats div { padding: 10px 6px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); display: flex; flex-direction: column; }
.win-stats span { font-size: .66rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.win-stats b { font: 600 1.05rem var(--display); }
.win-words { list-style: none; padding: 0; margin: 0 0 18px; text-align: left; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.win-words li { display: flex; align-items: center; gap: 8px; font-size: .88rem; padding: 3px 0; }
.win-words b { font-family: var(--display); }
.win-words span { color: var(--muted); margin-left: auto; text-align: right; }
.win-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 40; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 12px; min-width: 240px; max-width: 350px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: #fff; box-shadow: var(--shadow-lg); font-size: .9rem; animation: toastIn .45s var(--spring); }
.toast div { display: flex; flex-direction: column; }
.toast span { color: var(--muted); font-size: .8rem; }
.toast > .i { width: 34px; height: 34px; padding: 7px; border-radius: 10px; background: var(--surface-3); }
.toast.quest > .i { color: #fff; background: var(--warn); }
.toast.goal > .i, .toast.ok > .i { color: #fff; background: var(--ok); }
.toast.ach > .i { color: #fff; background: var(--accent); }
.toast.streak > .i { color: #fff; background: var(--flame); }
.toast.bad { border-color: #fecaca; }
.toast.bad > .i { color: #fff; background: var(--bad); }
.toast.out { animation: toastOut .35s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px) scale(.95); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(40px); } }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .play { grid-template-columns: 1fr; }
  .clues { position: static; max-height: none; }
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .nav { position: fixed; inset: auto 0 0 0; height: auto; z-index: 20; flex-direction: row; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); background: rgba(255, 255, 255, .92); }
  .brand, .navfoot { display: none; }
  .navlinks { flex-direction: row; justify-content: space-around; width: 100%; }
  .navlinks a { flex-direction: column; gap: 2px; padding: 6px 2px; font-size: .66rem; flex: 1; text-align: center; }
  .navlinks a.active::before { left: 30%; right: 30%; top: -7px; bottom: auto; width: auto; height: 3px; border-radius: 0 0 3px 3px; }
  .navlinks a .count { position: absolute; top: 2px; right: calc(50% - 22px); min-width: 16px; height: 16px; font-size: .6rem; padding: 0 4px; }
  .main { padding: 0 16px 96px; }
  .topbar { position: static; padding: 12px 0 10px; }
  .titles h1 { font-size: 1.3rem; }
  #stLevel, #stTime { display: none; }
  .stats { width: 100%; }
  .stats .stat { flex: 1; min-width: 0; }
  .today-grid, .social { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar { gap: 6px; }
  .toolbar .grow { display: none; }
  .toolbar select { flex: 1; min-width: 0; }
  .toolbar .seg button { padding: 6px 9px; font-size: .8rem; }
  .tools { width: 100%; justify-content: space-between; }
  .tools .btn { flex: 1; font-size: 0; gap: 0; padding: 0 8px; }
  .tools .btn.primary { flex: 1.3; }
  .tools .btn .i { width: 18px; height: 18px; }
  .tools .switch em { display: none; }
  .cluebar { min-height: 50px; padding: 8px 12px; position: sticky; top: 0; z-index: 4; }
  .clue-text { font-size: 1.05rem; }
  .stage3d { padding: 6px 0 12px; }
  .grid { --rx: 3deg; padding: 8px; gap: 3px; border-radius: 16px; }
  .osk { position: sticky; bottom: calc(62px + env(safe-area-inset-bottom)); z-index: 6; margin: 0 -16px; padding: 8px 6px 10px; background: rgba(244, 245, 250, .95); backdrop-filter: blur(16px); border-top: 1px solid var(--line); }
  .osk button { height: 44px; max-width: none; }
  .win-stats { grid-template-columns: repeat(2, 1fr); }
  .win-words { grid-template-columns: 1fr; }
  .toasts { left: 16px; right: 16px; bottom: 84px; }
  .toast { max-width: none; }
  .league .reset { margin-left: 0; width: 100%; }
  .slots span { width: 36px; height: 44px; font-size: 1.2rem; }
  .rv-tr { font-size: 1.8rem; }
  .banner { flex-wrap: wrap; }
  .lb-row { grid-template-columns: 30px 32px 1fr auto; }
  .lb-row .act { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .grid { transform: none; }
}
