/* Puff Putt refinement: existing dusk art, one surface family, quieter chrome.
   All viewport / iOS top anchoring and safe-area measurements stay in app.css. */
:root {
  --ui-surface: linear-gradient(160deg, rgba(49, 34, 99, .96), rgba(27, 19, 62, .97));
  --ui-control: rgba(30, 22, 68, .84);
  --ui-line: rgba(236, 224, 255, .19);
  --ui-muted: #d2c8e2;
  --ui-shadow: 0 12px 32px rgba(12, 7, 35, .24), inset 0 1px 0 rgba(255, 255, 255, .06);
  --ui-ease: cubic-bezier(.2, .75, .25, 1);
  --glass-line: var(--ui-line);
}

/* A calm, consistent control system; the warm primary remains unmistakable. */
.screen { transform: translateY(8px); transition: opacity .2s ease, transform .24s var(--ui-ease), visibility 0s .24s; }
.screen.active { transform: none; }
.icon-btn, .round-btn, .pill, .wtab { background: var(--ui-control); border: 1px solid var(--ui-line); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05); }
.icon-btn { width: 46px; height: 46px; border-radius: 15px; }
.icon-btn svg { width: 22px; height: 22px; }
.btn, .icon-btn, .round-btn, .lvl, .toggle, .dcard, .wtab { transition: transform .15s var(--ui-ease), background .18s ease, border-color .18s ease, box-shadow .18s ease; }
.btn { font: 850 18px/1.15 var(--body); letter-spacing: 0; border-radius: 18px; min-width: 0; }
.btn-primary { color: #322047; background: linear-gradient(180deg, #ffdc8f, #ffb45c 65%, #ffa250); border: 1px solid #ffe6ac; box-shadow: 0 4px 0 #b95c36, 0 9px 18px rgba(20, 9, 38, .16), inset 0 1px 0 rgba(255, 255, 255, .45); text-shadow: none; }
.btn-primary::after { display: none; }
.btn-primary:active { box-shadow: 0 1px 0 #b95c36, inset 0 1px 0 rgba(255, 255, 255, .25); }
.btn-soft { background: rgba(255, 255, 255, .065); border: 1px solid var(--ui-line); box-shadow: none; color: #fff3e0; }
.btn-ghost { color: #eee5f6; background: rgba(24, 17, 53, .35); border: 1px solid rgba(255, 243, 224, .13); box-shadow: none; height: 48px; font: 800 15px/1 var(--body); }
.btn:active, .icon-btn:active, .round-btn:active, .lvl:active, .dcard:active, .toggle:active { transform: translateY(2px); }
.btn svg { width: 22px; height: 22px; }
.pill { font: 850 17px/1 var(--body); color: #fff3e0; }
.topbar { padding-top: calc(var(--sat) + 16px); gap: 12px; }
.topbar .screen-title { font: 400 27px/1.1 var(--display); letter-spacing: 0; text-shadow: none; -webkit-text-stroke: 0; }
.screen:not(#home) > .topbar { background: linear-gradient(180deg, rgba(24, 15, 60, .96), rgba(24, 15, 60, .8)); padding-bottom: 12px; }
.screen:not(#home) > .topbar { display: grid; grid-template-columns: 52px minmax(0, 1fr) 52px; gap: 8px; }
.screen:not(#home) > .topbar > :last-child { justify-self: end; }
.topbar .pill { min-width: 52px; height: 38px; padding: 0 8px; gap: 4px; }
.topbar .pill svg { width: 18px; height: 18px; }
#daily .screen-title { font-size: clamp(20px, 5.6vw, 25px); white-space: nowrap; }
.scroll { top: calc(var(--sat) + 82px); padding: 12px calc(var(--sar) + 20px) calc(var(--sab) + 28px) calc(var(--sal) + 20px); scrollbar-width: thin; scrollbar-color: rgba(255, 243, 224, .22) transparent; }
#levels::before, #daily::before, #settings::before { background: linear-gradient(180deg, rgba(21, 13, 56, .78), rgba(21, 13, 56, .92)); }

/* Home keeps the character and scene as the hero, above a deliberate action stack. */
#home::before { background: linear-gradient(180deg, rgba(17, 10, 49, .28), transparent 35%, rgba(17, 10, 49, .18) 55%, rgba(17, 10, 49, .9)); }
.home-hero { padding-top: calc(var(--sat) + 74px); }
.logo .logotype { width: min(81vw, 350px); filter: drop-shadow(0 5px 8px rgba(12, 7, 35, .25)); }
.lt-bob, .lt-sp { animation: none; }
.tagline { margin-top: 10px; font: 750 14px/1.5 var(--body); color: #f4eafa; max-width: 290px; opacity: .94; text-shadow: 0 1px 5px rgba(15, 8, 43, .55); }
.home-actions { max-width: 444px; gap: 12px; padding: 0 calc(var(--sar) + 24px) calc(var(--sab) + 20px) calc(var(--sal) + 24px); }
.btn-xl { height: 64px; border-radius: 21px; font: 400 29px/1 var(--display); letter-spacing: .01em; margin-bottom: 6px; }
.btn-xl svg { width: 25px; height: 25px; }
.btn-daily { height: 74px; background: linear-gradient(110deg, #244b5f, #263c59); border: 1px solid rgba(133, 227, 218, .35); border-radius: 18px; box-shadow: 0 5px 12px rgba(13, 8, 34, .14), inset 0 1px 0 rgba(255, 255, 255, .06); padding: 0 14px; gap: 12px; }
.btn-daily .d-icon { width: 42px; height: 42px; border-radius: 13px; background: rgba(108, 229, 209, .14); border: 1px solid rgba(133, 227, 218, .2); box-shadow: none; color: #9cebdc; }
.btn-daily .d-text { gap: 5px; }
.btn-daily .d-text b { font: 900 17px/1.1 var(--body); letter-spacing: 0; }
.btn-daily .d-text small { font: 700 13px/1.3 var(--body); color: #d3e6e5; }
.streak { height: 32px; padding: 0 9px; gap: 4px; font: 850 15px/1 var(--body); border-color: rgba(133, 227, 218, .2); box-shadow: none; }
.streak svg { width: 16px; height: 16px; }
.streak.zero { opacity: .65; }
#hmStreak { flex: none; justify-content: center; min-width: 60px; padding-inline: 12px; gap: 6px; }
#hmStreak svg { flex: none; }
#hmStreakN { min-width: 1ch; font: inherit; font-variant-numeric: tabular-nums; text-align: center; }
#hmLevels { justify-content: flex-start; padding: 0 18px; gap: 10px; }
#hmLevels .nav-next { width: 17px; height: 17px; margin-left: auto; color: var(--ui-muted); }
.stats-line { margin-top: 2px; color: #d5cbe2; font: 750 13px/1.4 var(--body); min-height: 22px; }

/* Course library: artwork leads; rows and tabs share one restrained treatment. */
.world-tabs { top: calc(var(--sat) + 79px); gap: 8px; padding: 10px calc(var(--sar) + 20px) 12px calc(var(--sal) + 20px); background: transparent; }
.wtab { flex: 0 1 46px; min-width: 0; width: 46px; height: 44px; border-radius: 14px; font: 900 17px/1 var(--body); }
.wtab:not(.sel) { background: transparent; border-color: transparent; box-shadow: none; }
.wtab:not(.sel):active { background: rgba(255, 243, 224, .08); transform: translateY(1px); }
.wtab.locked { color: #c2b6d8; }
.wtab.locked .wt-n { opacity: .75; }
.wtab::before { display: none; }
.wtab.sel { background: #ffd085; color: #322047; border-color: #ffe1a4; transform: none; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3); }
.wtab .wt-lock { width: 15px; height: 15px; top: -3px; right: -2px; padding: 3px; background: transparent; opacity: .8; }
.scroll.with-tabs { top: calc(var(--sat) + 146px); }
.world-list { max-width: 520px; padding: 0 0 24px; }
.world header { min-height: 166px; border-radius: 22px; border: 1px solid rgba(255, 243, 224, .24); box-shadow: 0 9px 22px rgba(12, 7, 35, .2); margin: 0 0 18px; padding: 20px; }
.world header::after { background: linear-gradient(90deg, rgba(15, 10, 43, .58), rgba(15, 10, 43, .04)), linear-gradient(0deg, rgba(15, 10, 43, .3), transparent 70%); }
.world header .w-kicker { font: 850 11px/1.3 var(--body); letter-spacing: .11em; color: #eee4f6; padding-right: 72px; margin-bottom: 9px; }
.world header h3, .world:not(.locked) header h3 { font-size: 29px; line-height: 1.12; white-space: normal; max-width: 100%; text-shadow: 0 2px 5px rgba(12, 7, 35, .3); }
.world header small:not(.w-kicker) { margin-top: 7px; font: 750 13px/1.4 var(--body); color: #eee5f3; }
.world .w-stars { top: 15px; right: 15px; padding: 6px 8px; font: 750 12px/1 var(--body); background: rgba(23, 15, 51, .6); border: 1px solid rgba(255, 243, 224, .16); }
.world .w-stars b { font: 900 13px/1 var(--body); }
.w-row { gap: 10px; }
.lvl { min-height: 78px; height: 78px; padding: 12px 16px; gap: 14px; border: 1px solid var(--ui-line); border-radius: 18px; background: var(--ui-surface); box-shadow: var(--ui-shadow); }
.lvl .n { width: 44px; height: 44px; border-radius: 14px; font-size: 25px; background: #ffcf85; box-shadow: none; }
.lvl .nm { font: 850 16px/1.25 var(--body); }
.lvl .lv-info { gap: 7px; }
.lvl .sts { gap: 3px; }
.lvl .sts svg { width: 14px; height: 14px; filter: none; }
.lvl.next { background: linear-gradient(110deg, #4a365d, #34264f); border-color: rgba(255, 208, 133, .6); box-shadow: var(--ui-shadow); }
.lvl.next::after { top: 14px; right: 14px; font: 900 9px/1 var(--body); letter-spacing: .06em; padding: 4px 6px; border-radius: 6px; }
.lvl.next .lv-info { padding-right: 36px; }
.lvl.locked { background: rgba(38, 28, 75, .7); opacity: 1; box-shadow: none; }
.lvl.locked .nm { opacity: .68; }
.lvl.locked .n { opacity: 1; }

/* Daily and settings use the same readable row system. */
.daily-list, .panel, .more { max-width: 480px; }
.daily-date { font: 400 23px/1.2 var(--display); margin: 8px 0 22px; text-shadow: none; }
.dcard { min-height: 94px; padding: 16px; gap: 14px; border: 1px solid var(--ui-line); border-radius: 20px; background: var(--ui-surface); box-shadow: var(--ui-shadow); }
.dcard .badge { width: 44px; height: 48px; border-radius: 13px; font-size: 24px; box-shadow: none; }
.dcard .info { gap: 6px; }
.dcard .info b { font: 850 17px/1.25 var(--body); }
.dcard .info small { font: 700 13px/1.35 var(--body); color: var(--ui-muted); }
.dcard .sts { gap: 1px; }
.dcard .sts svg { width: 16px; height: 16px; filter: none; }
.foot-note, .fine { font: 700 13px/1.5 var(--body); color: var(--ui-muted); opacity: 1; }
.daily-all { font: 850 16px/1.4 var(--body); }
.daily-mascot { width: 116px; height: 116px; margin-top: 24px; animation: none; }
.panel { padding: 4px 16px; border: 1px solid var(--ui-line); background: var(--ui-surface); border-radius: 22px; box-shadow: var(--ui-shadow); }
.toggle { min-height: 80px; padding: 12px 0; gap: 14px; }
.toggle + .toggle { border-top: 1px solid rgba(255, 243, 224, .1); }
.t-ico { width: 40px; height: 40px; border-radius: 13px; background: rgba(190, 168, 255, .12); color: #d5c9ff; }
.t-ico svg { width: 22px; height: 22px; }
.t-label { font: 850 16px/1.3 var(--body); }
.t-label small { font: 650 13px/1.4 var(--body); color: var(--ui-muted); }
.switch { width: 48px; height: 28px; background: #5a4c78; box-shadow: none; }
.switch i { width: 22px; height: 22px; box-shadow: 0 1px 3px rgba(0, 0, 0, .16); transition: transform .18s var(--ui-ease); }
.toggle[aria-checked='true'] .switch { background: #4bbba9; }
[aria-checked='true'] .switch i { transform: translateX(20px); }
.more summary { margin: 18px 0 4px; min-height: 48px; padding: 14px; font: 800 14px/1.2 var(--body); color: #e4d8ef; border: 1px solid var(--ui-line); border-radius: 14px; background: rgba(255, 255, 255, .035); }

/* Gameplay chrome is legible without competing with the course. */
.hud { padding: calc(var(--sat) + 16px) calc(var(--sar) + 16px) 0 calc(var(--sal) + 16px); gap: 10px; }
.hud-row { max-width: 500px; gap: 10px; }
.hud .icon-btn.small { width: 46px; height: 46px; border-radius: 15px; background: rgba(30, 22, 68, .92); }
.tapbox { display: grid; grid-template-columns: auto auto auto; grid-template-rows: auto auto; column-gap: 7px; row-gap: 2px; align-content: center; min-width: 164px; height: 54px; padding: 6px 16px; background: rgba(30, 22, 68, .94); border: 1px solid rgba(255, 243, 224, .24); border-radius: 18px; box-shadow: 0 5px 16px rgba(12, 7, 35, .16); }
.tap-n { grid-column: 1; grid-row: 1 / 3; color: #ffda93; font-size: 29px; text-shadow: none; }
.tap-caption { grid-column: 2; grid-row: 1; font: 850 11px/1 var(--body); text-transform: uppercase; letter-spacing: .05em; color: #f5eaff; align-self: end; }
.tap-l { grid-column: 2; grid-row: 2; font: 700 12px/1 var(--body); padding: 0; max-width: none; align-self: start; color: var(--ui-muted); }
.tap-l b { color: #e2d6f0; }
.pips { grid-column: 3; grid-row: 1 / 3; margin-left: 8px; gap: 2px; }
.pip { width: 13px; height: 13px; color: rgba(255, 243, 224, .22); }
.pip.on { filter: none; color: #ffd085; }
.meter { width: 138px; height: 9px; padding: 2px; border: 1px solid rgba(255, 243, 224, .22); background: rgba(25, 17, 53, .7); box-shadow: none; }
.m-fill { background: linear-gradient(90deg, #ffda93, #ffad5a); box-shadow: none; }
.start-hint { top: 26%; gap: 10px; }
.start-hint small { font: 850 11px/1.2 var(--body); letter-spacing: .13em; }
.start-hint h2 { font-size: clamp(30px, 9vw, 42px); line-height: 1.1; text-shadow: 0 2px 8px rgba(14, 7, 40, .6); }
.start-hint span { font: 750 14px/1.5 var(--body); max-width: 270px; }
.start-hint .go { margin-top: 7px; padding: 11px 20px; font: 850 13px/1 var(--body); letter-spacing: .02em; text-transform: none; border: 1px solid rgba(255, 208, 133, .4); background: rgba(27, 19, 62, .8); animation: none; }
.callout { font-size: 32px; text-shadow: 0 3px 10px rgba(12, 7, 35, .45); }

/* Pause, retry and completion share a sheet anatomy and roomy actions. */
.screen.overlay { background: rgba(13, 9, 35, .65); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.modal, .fail-card, .rot-card { background: var(--ui-surface); border: 1px solid rgba(236, 224, 255, .24); box-shadow: 0 24px 64px rgba(9, 5, 27, .4), inset 0 1px 0 rgba(255, 255, 255, .08); border-radius: 26px; }
.modal { width: min(100%, 370px); padding: 28px 24px 24px; gap: 18px; }
.modal h2, .fail-card h3 { text-shadow: none; }
.modal h2 { font-size: 32px; line-height: 1.1; }
.modal.has-mascot { margin-top: 34px; padding-top: 48px; }
.mascot, .mascot.win { animation: none; width: 88px; height: 88px; top: -50px; margin-left: -44px; filter: drop-shadow(0 5px 6px rgba(10, 5, 33, .2)); }
.pause-modal { gap: 22px; }
.icon-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.icon-row .round-btn { width: 100%; height: 72px; border-radius: 16px; gap: 8px; }
.icon-row .round-btn small { font: 800 12px/1 var(--body) !important; color: #e0d6ed; }
.icon-row .round-btn svg { width: 22px; height: 22px; }
.result { gap: 16px; }
.result h2 { font-size: 33px; }
.rs-name { font: 850 12px/1.4 var(--body); text-transform: none; letter-spacing: .01em; color: var(--ui-muted); }
.stars { gap: 8px; margin: 2px 0 6px; }
.stars .st { width: 54px; height: 54px; }
.stars .st.on { filter: drop-shadow(0 2px 0 rgba(177, 105, 31, .6)); animation-duration: .42s; }
.stars::before { display: none; }
.rs-line { padding: 14px 8px; background: rgba(255, 255, 255, .045); border: 1px solid rgba(255, 255, 255, .08); border-radius: 14px; font: 750 13px/1.5 var(--body); color: #c8bfdc; }
.rs-line b { font: 900 18px/1 var(--body); }
.rs-badge { font: 800 14px/1.4 var(--body); min-height: 0; }
.rs-badge:empty { display: none; }
.action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 2px; }
.action-row .btn { grid-column: 1 / -1; grid-row: 1; width: 100%; height: 56px; font: 850 17px/1.2 var(--body); padding: 0 16px; }
.action-row .round-btn { width: 100%; height: 46px; border-radius: 14px; display: flex; justify-content: center; gap: 8px; font: 800 13px/1 var(--body); }
.action-row .round-btn svg { width: 18px; height: 18px; }
.result .link-btn { display: flex; align-items: center; justify-content: center; min-height: 44px; min-width: 132px; font: 750 13px/1.2 var(--body); text-decoration: none; color: #e0d6ec; padding: 10px 16px; border-radius: 12px; }
.fail-card { width: min(88vw, 340px); padding: 24px; gap: 16px; bottom: calc(var(--sab) + 24px); }
.fail-card h3 { font-size: 30px; }
.fail-card p { font: 750 14px/1.5 var(--body); color: #d1c5e0; }
.fail-card .btn { font-size: 17px; height: 54px; }
.toast { padding: 12px 18px; border-radius: 14px; font: 800 13px/1.4 var(--body); box-shadow: 0 8px 24px rgba(9, 5, 27, .24); }

/* Mobile fit stays within the existing top-anchored PWA shell. */
@media (max-width: 360px) {
  .topbar .screen-title { font-size: 24px; }
  .home-actions { padding-left: calc(var(--sal) + 20px); padding-right: calc(var(--sar) + 20px); }
  .btn-daily { padding: 0 12px; gap: 9px; }
  .btn-daily .d-text b { font-size: 15px; }
  .streak { padding: 0 7px; }
  .scroll { padding-left: calc(var(--sal) + 16px); padding-right: calc(var(--sar) + 16px); }
  .world-tabs { gap: 4px; padding-left: calc(var(--sal) + 16px); padding-right: calc(var(--sar) + 16px); }
  .wtab { min-width: 44px; }
  .world header { padding: 17px; min-height: 154px; }
  .world header h3, .world:not(.locked) header h3 { font-size: 27px; }
  .modal { padding-left: 18px; padding-right: 18px; }
  .icon-row { gap: 6px; }
  .hud { padding-left: calc(var(--sal) + 12px); padding-right: calc(var(--sar) + 12px); }
  .tapbox { min-width: 158px; padding: 6px 11px; }
  .dcard { padding: 14px 12px; gap: 10px; }
  .dcard .sts svg { width: 14px; height: 14px; }
}
@media (max-height: 740px) and (orientation: portrait) {
  .home-hero { padding-top: calc(var(--sat) + 60px); }
  .logo .logotype { width: min(76vw, 290px); }
  .tagline { display: block; font-size: 12px; line-height: 1.35; max-width: 250px; margin-top: 0; }
  .hero-spacer { min-height: 76px; }
  .home-actions { gap: 10px; padding-bottom: calc(var(--sab) + 14px); }
  .btn-xl { height: 56px; font-size: 26px; margin-bottom: 3px; }
  .btn-daily { height: 64px; }
  .btn-ghost { height: 44px; }
  .daily-mascot { width: 88px; height: 88px; margin-top: 16px; }
  .modal { gap: 12px; padding-bottom: 18px; }
  .result .stars .st { width: 46px; height: 46px; }
  .start-hint { top: 25%; gap: 8px; }
}
@media (max-height: 600px) and (orientation: portrait) { .tagline { display: none; } .logo .logotype { width: min(70vw, 260px); } .home-hero { padding-top: calc(var(--sat) + 56px); } }
@media (orientation: landscape) and (max-height: 520px) {
  .home-hero { padding-top: calc(var(--sat) + 58px); }
  .logo .logotype { width: min(32vw, 240px); }
  .home-actions { padding-top: calc(var(--sat) + 46px); gap: 10px; }
  .btn-xl { height: 54px; font-size: 25px; }
  .btn-daily { height: 60px; }
  .btn-ghost { height: 42px; }
  .world header { min-height: 112px; }
}
@media (hover: hover) {
  .btn-primary:hover { background: linear-gradient(180deg, #ffe3a3, #ffbc6a 65%, #ffad5b); }
  .icon-btn:hover, .round-btn:hover, .btn-soft:hover, .btn-ghost:hover { background-color: rgba(87, 67, 130, .6); border-color: rgba(255, 243, 224, .36); }
  .lvl:hover, .dcard:hover { border-color: rgba(255, 243, 224, .4); }
}
@keyframes promptPulse { 50% { opacity: .82; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px); } }
@keyframes starPop { from { opacity: 0; transform: translateY(8px) scale(.7); } to { opacity: 1; transform: none; } }
html.reduce-motion .screen, html.reduce-motion .btn, html.reduce-motion .icon-btn, html.reduce-motion .round-btn { transition: none; }
html.reduce-motion .mascot, html.reduce-motion .daily-mascot, html.reduce-motion .lt-bob, html.reduce-motion .lt-sp, html.reduce-motion .ld-prompt, html.reduce-motion .ld-zzz b { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .screen, .btn, .icon-btn, .round-btn { transition: none; }
  .mascot, .daily-mascot, .lt-bob, .lt-sp, .ld-prompt, .ld-zzz b, .stars .spk { animation: none; }
}
