:root {
  color-scheme: light;
  font-family: 'Fredoka', ui-rounded, 'Arial Rounded MT Bold', system-ui, sans-serif;
  --ink: #594765;
  --muted: #8c7897;
  --pink: #ed8eb7;
  --purple: #a68ad9;
  --cream: #fffaf4;
  --glass: rgba(255, 250, 252, .88);
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #e9d9ee; color: var(--ink); }
button, a { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible { outline: 3px solid #8d68ca; outline-offset: 3px; }
.hidden { display: none !important; }
.game-shell { height: 100dvh; display: flex; flex-direction: column; }
.game-bar { height: 48px; flex: 0 0 48px; display: flex; align-items: center; gap: 14px; padding: 0 max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left)); background: rgba(255,250,252,.94); border-bottom: 1px solid rgba(112,80,130,.1); z-index: 20; }
.back-link { color: var(--ink); text-decoration: none; font-weight: 600; display: flex; align-items: center; gap: 5px; }
.back-link:first-letter { font-size: 25px; color: var(--pink); }
.game-bar-title { font-size: 14px; font-weight: 600; flex: 1; text-align: center; }
.bar-actions { display: flex; gap: 6px; }
.icon-btn { width: 34px; height: 34px; border-radius: 12px; border: 1px solid #eadcf0; background: #fff; color: var(--ink); cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { background: #f8edf7; transform: translateY(-1px); }
.game-wrap { position: relative; flex: 1; min-height: 0; overflow: hidden; isolation: isolate; }
#game-canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.soft-vignette { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle at 55% 45%, transparent 48%, rgba(97,67,126,.12) 120%); z-index: 1; }
.fx-labels { position: absolute; inset: 0; z-index: 7; pointer-events: none; overflow: hidden; }
.point-pop { position: absolute; transform: translate(-50%,-50%); font-size: 20px; font-weight: 700; text-shadow: 0 2px 5px rgba(79,51,92,.45); animation: point-rise .95s ease-out forwards; }
@keyframes point-rise { 0% { opacity: 0; transform: translate(-50%,-20%) scale(.7); } 18% { opacity: 1; transform: translate(-50%,-70%) scale(1.12); } 100% { opacity: 0; transform: translate(-50%,-190%) scale(.92); } }
.screen { position: absolute; inset: 0; z-index: 10; display: none; align-items: center; justify-content: center; padding: 24px; background: rgba(87,60,109,.16); backdrop-filter: blur(4px); overflow: auto; }
.screen-active { display: flex; }
#screen-menu { justify-content: flex-start; padding-left: clamp(24px, 7vw, 110px); background: linear-gradient(90deg, rgba(246,225,239,.48), transparent 68%); backdrop-filter: none; }
.panel { width: min(470px, 100%); padding: 34px; border-radius: 32px; background: var(--glass); border: 1px solid rgba(255,255,255,.9); box-shadow: 0 22px 70px rgba(91,63,116,.18), inset 0 1px 0 #fff; text-align: center; position: relative; }
.menu-panel { width: min(430px, 100%); padding: 32px 38px 28px; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .18em; color: #a277ac; margin-bottom: 12px; }
.title-star { position: absolute; right: 34px; top: 24px; color: #efb956; font-size: 34px; transform: rotate(12deg); text-shadow: 0 4px 12px #f2c96680; }
h1 { margin: 0; line-height: .88; font-size: clamp(46px, 6vw, 70px); letter-spacing: -.055em; color: #76608c; }
h1 span { display: block; color: #e888b2; font-size: 1.12em; text-shadow: 0 4px 0 #fff; }
h2 { margin: 4px 0 10px; font-size: clamp(27px, 4vw, 38px); line-height: 1.06; letter-spacing: -.035em; color: #6e567e; }
.subtitle { color: var(--muted); line-height: 1.55; margin: 18px 0; font-size: 16px; }
.best-strip { display: flex; justify-content: center; gap: 10px; margin: 18px 0; }
.best-strip span { background: #f5eaf4; border: 1px solid #ead8ec; border-radius: 999px; padding: 8px 12px; font-size: 12px; color: #8a7295; }
.best-strip b { color: #6d537c; margin-left: 3px; }
.menu-actions { display: grid; gap: 10px; margin-top: 20px; }
.menu-actions.compact { grid-template-columns: 1.4fr 1fr; }
.menu-actions button { border: 1px solid #e6d6e9; border-radius: 16px; padding: 13px 18px; background: rgba(255,255,255,.78); color: #755f83; font-weight: 600; cursor: pointer; box-shadow: 0 4px 0 rgba(116,81,135,.08); transition: transform .15s, box-shadow .15s, background .15s; }
.menu-actions button:hover { transform: translateY(-2px); box-shadow: 0 7px 0 rgba(116,81,135,.08); background: #fff; }
.menu-actions button:active { transform: translateY(2px); box-shadow: none; }
.menu-actions button.primary { color: #fff; border-color: #d77fac; background: linear-gradient(135deg, #efa1c1, #c393dc); box-shadow: 0 5px 0 #b477ad, 0 10px 24px rgba(206,126,177,.25); text-shadow: 0 1px 1px rgba(90,50,100,.15); }
.menu-actions button.primary:hover { background: linear-gradient(135deg, #f2acc8, #cba0e2); box-shadow: 0 7px 0 #b477ad, 0 12px 26px rgba(206,126,177,.28); }
.menu-actions button.big { padding: 16px 20px; font-size: 17px; }
.tiny-note { margin: 18px 0 0; font-size: 11px; color: #aa94b3; }
.character-tag { position: absolute; right: 7%; bottom: 7%; background: rgba(255,255,255,.76); border: 1px solid #fff; border-radius: 18px; padding: 10px 16px; transform: rotate(-3deg); box-shadow: 0 8px 30px rgba(86,56,100,.12); text-align: left; }
.character-tag b, .character-tag span { display: block; }
.character-tag b { color: #d67ea7; }
.character-tag span { color: #9b84a5; font-size: 11px; }
.readable { width: min(720px, 100%); text-align: left; max-height: calc(100dvh - 110px); overflow: auto; }
.readable > .eyebrow, .readable > h2 { text-align: center; }
.how-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 24px; }
.how-grid > div { position: relative; border-radius: 20px; background: #f7eef6; padding: 20px 16px 16px; border: 1px solid #eddfed; }
.how-grid i { position: absolute; top: -10px; right: 12px; background: #dfb0d2; color: #fff; border-radius: 999px; padding: 4px 8px; font-size: 11px; font-style: normal; }
.how-grid b { display: block; color: #795e89; font-size: 15px; margin-bottom: 8px; }
.how-grid span, .controls-note span { color: #907b99; font-size: 13px; line-height: 1.5; display: block; }
.controls-note { margin-top: 14px; background: #fff7ed; border: 1px solid #f2e3cd; border-radius: 18px; padding: 14px 16px; }
.controls-note b { display: block; margin-bottom: 5px; color: #8a705c; font-size: 13px; }
kbd { background: #fff; border: 1px solid #dbcddd; border-bottom-width: 2px; border-radius: 5px; padding: 1px 5px; font-family: inherit; font-size: .9em; }
.goal-note { text-align: center; color: #907b99; font-size: 13px; }
.small-panel { width: min(390px, 100%); }
.small-panel p { color: var(--muted); }
.loading-panel { width: min(330px, 90%); }
.loading-panel p { color: var(--muted); }
.moon-spinner { font-size: 58px; color: #c194d5; animation: moon-bob 1.5s ease-in-out infinite; }
@keyframes moon-bob { 50% { transform: translateY(-8px) rotate(10deg); } }
.hud { position: absolute; inset: 0; z-index: 4; pointer-events: none; padding: 18px; }
.hud-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.hud-card, .timer-card { background: rgba(255,251,253,.88); border: 1px solid rgba(255,255,255,.9); box-shadow: 0 7px 24px rgba(90,61,110,.12); border-radius: 19px; padding: 11px 15px; backdrop-filter: blur(10px); }
.hud-label, .timer-card span { font-size: 9px; font-weight: 700; letter-spacing: .14em; color: #a087aa; display: block; }
.goal-card { width: 160px; }
.goal-line { display: flex; align-items: baseline; gap: 4px; margin: 1px 0 6px; }
.goal-line b { font-size: 24px; color: #d482ae; }
.goal-line span { font-size: 13px; color: #9983a2; }
.goal-track { height: 6px; border-radius: 999px; background: #eaddf0; overflow: hidden; }
.goal-track i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #f0a0be, #f4c76b); transition: width .25s; }
.timer-card { text-align: center; min-width: 82px; }
.timer-card b { display: block; font-size: 25px; color: #765e88; line-height: 1.1; }
.timer-card small { display: block; max-width: 150px; margin-top: 4px; color: #a087aa; font-size: 9px; line-height: 1.2; white-space: nowrap; }
.timer-card.urgent { animation: urgent-pulse .8s infinite; background: #fff0ee; }
@keyframes urgent-pulse { 50% { transform: scale(1.05); } }
.score-card { min-width: 160px; position: relative; padding-right: 52px; text-align: right; }
.score-card > b { display: block; color: #8c70a0; font-size: 24px; }
.pause-btn { pointer-events: auto; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border-radius: 12px; border: 1px solid #e6d6eb; background: #f4eaf5; color: #876c96; cursor: pointer; font-weight: 700; }
.carry-card { position: absolute; left: 18px; top: 114px; background: rgba(255,251,253,.75); padding: 9px 12px; border-radius: 15px; border: 1px solid rgba(255,255,255,.8); }
.carry-card > span { display: block; font-size: 8px; letter-spacing: .12em; color: #a38bab; margin-bottom: 5px; }
.carry-pips { display: flex; gap: 5px; }
.carry-pips i { width: 18px; height: 18px; display: grid; place-items: center; border-radius: 50%; background: #e9deed; font-style: normal; font-size: 11px; color: transparent; transition: transform .15s, background .15s; }
.carry-pips i.full { color: #d99a39; background: #fff0b9; transform: scale(1.1) rotate(8deg); }
.objective { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); white-space: nowrap; background: rgba(255,251,253,.78); border: 1px solid rgba(255,255,255,.9); border-radius: 999px; padding: 8px 15px; color: #91799b; font-size: 11px; box-shadow: 0 5px 18px rgba(90,61,110,.09); }
.wayfinder { position: absolute; bottom: 58px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; white-space: nowrap; background: rgba(93,69,116,.78); color: #fff; border: 1px solid rgba(255,255,255,.35); border-radius: 999px; padding: 7px 13px; box-shadow: 0 5px 18px rgba(73,50,96,.15); }
.wayfinder > span:first-child { display: inline-block; color: #ffe38c; font-size: 18px; line-height: 1; transition: transform .15s; }
.wayfinder b { font-size: 11px; font-weight: 500; }
.wayfinder small { color: #eadcf2; font-size: 10px; }
.toast { position: absolute; top: 22%; left: 50%; transform: translate(-50%, -8px); background: rgba(100,74,116,.88); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 13px; opacity: 0; transition: opacity .2s, transform .2s; text-align: center; max-width: 85%; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.dash-meter { position: absolute; right: 25px; bottom: 25px; width: 60px; height: 5px; background: rgba(255,255,255,.6); border-radius: 99px; overflow: hidden; }
.dash-meter i { display: block; height: 100%; background: #d294d9; width: 100%; }
.touch-controls { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.joystick { position: absolute; left: max(24px, env(safe-area-inset-left)); bottom: max(28px, env(safe-area-inset-bottom)); width: 112px; height: 112px; border-radius: 50%; background: rgba(255,250,253,.32); border: 2px solid rgba(255,255,255,.55); box-shadow: inset 0 0 24px rgba(108,73,130,.08); pointer-events: auto; touch-action: none; }
.joystick-knob { position: absolute; width: 52px; height: 52px; left: 28px; top: 28px; border-radius: 50%; background: rgba(255,250,253,.83); border: 1px solid #fff; box-shadow: 0 5px 14px rgba(83,55,105,.16); }
.dash-btn { position: absolute; right: max(28px, env(safe-area-inset-right)); bottom: max(39px, env(safe-area-inset-bottom)); width: 78px; height: 78px; border-radius: 50%; border: 2px solid rgba(255,255,255,.8); background: linear-gradient(145deg, rgba(241,176,206,.9), rgba(184,147,217,.9)); color: #fff; box-shadow: 0 7px 0 rgba(131,92,158,.35), 0 10px 24px rgba(91,59,110,.16); pointer-events: auto; touch-action: none; }
.dash-btn span, .dash-btn small { display: block; }
.dash-btn span { font-size: 26px; line-height: 1; }
.dash-btn small { font-size: 9px; font-weight: 700; letter-spacing: .08em; margin-top: 3px; }
.dash-btn:active { transform: translateY(4px); box-shadow: 0 3px 0 rgba(131,92,158,.35); }
.results-panel { width: min(470px, 100%); }
.result-icon { font-size: 50px; margin-top: -58px; filter: drop-shadow(0 6px 8px rgba(90,60,100,.16)); }
.final-score { margin: 18px auto; position: relative; }
.final-score > span { display: block; color: #a28bab; font-size: 10px; letter-spacing: .16em; }
.final-score > b { display: block; color: #d17fa9; font-size: 52px; line-height: 1.05; }
.final-score em { position: absolute; right: 15px; top: 18px; transform: rotate(8deg); color: #b17a32; background: #fff0b8; border-radius: 8px; padding: 5px 8px; font-size: 10px; font-style: normal; font-weight: 700; }
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.summary-grid div { padding: 12px 6px; border-radius: 15px; background: #f6edf6; }
.summary-grid b, .summary-grid span { display: block; }
.summary-grid b { color: #7c628d; font-size: 21px; }
.summary-grid span { color: #9a85a3; font-size: 10px; }
.score-nudge { margin-top: 14px; border-radius: 14px; background: #fff5dc; padding: 10px; font-size: 12px; }
.score-nudge p { margin: 0 0 8px; }
.score-nudge a { color: #9a67a6; font-weight: 600; }
.score-nudge button { border: 0; background: none; color: #a391a7; margin-left: 10px; cursor: pointer; font-size: 11px; }
@media (pointer: fine) { .touch-controls { display: none !important; } }
@media (max-width: 760px) {
  .screen { padding: 16px; }
  #screen-menu { justify-content: center; align-items: flex-end; padding: 16px 16px 24px; background: linear-gradient(0deg, rgba(238,216,234,.75), transparent 78%); }
  .menu-panel { padding: 23px 24px 19px; border-radius: 26px; }
  h1 { font-size: 43px; }
  h1 span { display: inline; margin-right: 8px; }
  .subtitle { margin: 10px 0; font-size: 13px; }
  .subtitle br { display: none; }
  .eyebrow { margin-bottom: 8px; }
  .title-star { right: 25px; top: 18px; font-size: 27px; }
  .best-strip { margin: 12px 0; }
  .menu-actions { margin-top: 12px; }
  .menu-actions button.big { padding: 13px 18px; }
  .tiny-note { margin-top: 12px; }
  .character-tag { display: none; }
  .how-grid { grid-template-columns: 1fr; gap: 9px; }
  .how-grid > div { padding: 13px 14px 12px 50px; }
  .how-grid i { left: 12px; right: auto; top: 14px; }
  .readable { padding: 24px 20px; max-height: calc(100dvh - 100px); }
  .controls-note { padding: 11px 13px; }
  .hud { padding: 10px; }
  .hud-top { gap: 7px; }
  .hud-card, .timer-card { border-radius: 15px; padding: 9px 10px; }
  .goal-card { width: 118px; }
  .goal-line b { font-size: 20px; }
  .score-card { min-width: 108px; padding-right: 38px; }
  .score-card > b { font-size: 20px; }
  .pause-btn { right: 6px; width: 28px; height: 30px; }
  .timer-card { min-width: 62px; }
  .timer-card b { font-size: 20px; }
  .carry-card { left: 10px; top: 91px; }
  .objective { bottom: 153px; font-size: 10px; padding: 7px 12px; }
  .wayfinder { bottom: 194px; padding: 6px 11px; }
  .wayfinder b { font-size: 10px; }
  .dash-meter { display: none; }
  .results-panel { padding: 28px 22px 22px; }
}
@media (max-height: 690px) and (max-width: 760px) {
  .menu-panel .subtitle, .tiny-note { display: none; }
  .menu-panel { padding-top: 18px; }
  .best-strip { margin: 9px 0; }
  .menu-actions { gap: 7px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
