:root { --game-event-size:28px; --game-event-font:400 var(--game-event-size)/1.15 var(--portal-display); --game-event-color:#ffe2b6; --game-event-shadow:0 2px 0 #45283b,0 4px 12px #111124aa; }
/* Shared visual language for the lobby, lessons, recovery and results. */
:root {
  --portal-ink: #261d3c;
  --portal-cream: #fff0cf;
  --portal-muted: #cdbedb;
  --portal-gold: #ffbd72;
  --portal-edge: #bda0d5;
  --portal-face: radial-gradient(ellipse at 50% 0%, #825075, #3d2c50 85%);
  --portal-frame: linear-gradient(180deg, #c2a3dd, #80659f 48%, #664b83);
  --portal-display: 'Creepster', SlopeDisplay, sans-serif;
}
:is(button, input, select, summary):focus-visible { outline: 3px solid #ffe0a4; outline-offset: 4px; }

/* One material for primary actions; each screen owns its button's width. */
:is(#startscreen #startbtn, #guidePanel #guideNext, #setupPanel #setupContinue,
    #gamePanel #resumeBtn, #overscreen #againbtn, #overscreen[data-completed] #againbtn, #overscreen #shareAchievement,
    dialog.flow-dialog .flow-primary) {
  position: relative; isolation: isolate; overflow: visible; box-sizing: border-box;
  display: flex; align-items: center; justify-content: center; gap: 0;
  min-height: 60px; height: auto; padding: 13px 28px;
  border: 3px solid var(--portal-ink); border-radius: 16px;
  background: var(--portal-frame); color: #ffe3aa;
  font: 400 27px/1.15 var(--portal-display); letter-spacing: .025em;
  text-shadow: 0 2px 0 #45283b, 0 0 12px #f9a35c55;
  text-decoration: none; white-space: normal; text-wrap: balance; transform: none;
  box-shadow: inset 0 2px 0 #e8ccef, inset 0 -3px 0 #50385f,
    0 6px 0 #3d2c51, 0 9px 0 #21192e, 0 14px 23px #08071966;
  transition: transform .16s ease, filter .16s ease, box-shadow .16s ease;
}
:is(#startscreen #startbtn, #guidePanel #guideNext, #setupPanel #setupContinue,
    #gamePanel #resumeBtn, #overscreen #againbtn, #overscreen[data-completed] #againbtn, #overscreen #shareAchievement,
    dialog.flow-dialog .flow-primary)::before {
  content: ''; position: absolute; z-index: -1; inset: 7px;
  border: 2px solid #362640; border-radius: 8px; background: var(--portal-face);
  box-shadow: inset 0 2px 5px #211a3966, 0 1px 0 #ddb6e044;
  opacity: 1; pointer-events: none; transition: none;
}
:is(#startscreen #startbtn, #guidePanel #guideNext, #setupPanel #setupContinue,
    #gamePanel #resumeBtn, #overscreen #againbtn, #overscreen[data-completed] #againbtn, #overscreen #shareAchievement,
    dialog.flow-dialog .flow-primary)::after {
  content: ''; position: absolute; z-index: 2; inset: -8px auto auto calc(50% - 7px);
  box-sizing: border-box; width: 14px; height: 14px;
  border: 2px solid #5d3a55; border-radius: 3px;
  background: linear-gradient(135deg, #ffe7a2, #ffad50);
  box-shadow: inset 2px 2px 0 #fff2bd77, 2px 2px 0 #261b3a, 0 0 15px #ffb25833;
  color: transparent; font-size: 0; opacity: 1; filter: none;
  transform: rotate(45deg); animation: none; transition: none; pointer-events: none;
}
:is(#startscreen #startbtn, #guidePanel #guideNext, #setupPanel #setupContinue,
    #gamePanel #resumeBtn, #overscreen #againbtn, #overscreen[data-completed] #againbtn, #overscreen #shareAchievement,
    dialog.flow-dialog .flow-primary):hover:enabled {
  background: var(--portal-frame); color: #ffe3aa; text-decoration: none;
  filter: brightness(1.1); transform: translateY(-2px);
  box-shadow: inset 0 2px 0 #f0d6f4, inset 0 -3px 0 #50385f,
    0 6px 0 #3d2c51, 0 9px 0 #21192e, 0 0 28px #a982c44a;
}
:is(#startscreen #startbtn, #guidePanel #guideNext, #setupPanel #setupContinue,
    #gamePanel #resumeBtn, #overscreen #againbtn, #overscreen[data-completed] #againbtn, #overscreen #shareAchievement,
    dialog.flow-dialog .flow-primary):active:enabled {
  transform: translateY(4px);
  box-shadow: inset 0 2px 0 #e8ccef, inset 0 -3px 0 #50385f,
    0 2px 0 #3d2c51, 0 4px 0 #21192e;
}
:is(#startscreen #startbtn, #guidePanel #guideNext, #setupPanel #setupContinue,
    #gamePanel #resumeBtn, #overscreen #againbtn, #overscreen[data-completed] #againbtn, #overscreen #shareAchievement,
    dialog.flow-dialog .flow-primary):disabled {
  opacity: 1; background: linear-gradient(180deg, #9584a8, #695a7e 48%, #584669);
  border-color: var(--portal-ink); color: #cbbad9; cursor: default;
  text-shadow: 0 2px 0 #382d43;
  box-shadow: inset 0 2px 0 #c8b5d5, inset 0 -3px 0 #50385f, 0 5px 0 #3d2c51, 0 8px 0 #21192e;
}
:is(#guidePanel #guideNext, dialog.flow-dialog .flow-primary):disabled::after { background: #9c85b0; box-shadow: 2px 2px 0 #261b3a; }
#startscreen #startbtn { width: 100%; max-width: 100%; min-width: 0; min-height: 72px; padding: 15px 38px; font-size: 32px; letter-spacing: .035em; }
#startscreen #startbtn:disabled { font-size: 22px; }
#startscreen #startbtn > span:first-child { position: relative; z-index: 1; }
#startscreen #startbtn > .portal-rails { position: absolute; inset: 0; pointer-events: none; }
#startscreen #startbtn .portal-rails::before, #startscreen #startbtn .portal-rails::after {
  content: ''; position: absolute; left: -6px; top: 50%; width: 11px; height: 30px;
  border: 2px solid #30213c; border-radius: 6px;
  background: linear-gradient(90deg, #78568c, #d0abd9, #73518c);
  box-shadow: 0 2px 0 #21192e; transform: translateY(-50%);
}
#startscreen #startbtn .portal-rails::after { left: auto; right: -6px; }
#guidePanel #guideNext, #guidePanel:is([data-phase], [data-quick]) #guideNext { width: max-content; min-width: 164px; max-width: 100%; margin: 0; }
#overscreen #againbtn { justify-content: center; margin: 0; }

/* The same lavender bevel surrounds every modal, without the old rivets. */
:is(#guidePanel, #setupPanel, #gamePanel, dialog.flow-dialog, #overscreen .results-panel) {
  border: 3px solid var(--portal-ink); border-radius: 21px;
  color: var(--portal-cream);
  background: radial-gradient(ellipse at 15% 0%, #533a63, #35283f 64%, #2d233b);
  box-shadow: inset 0 0 0 2px #d2b5e6, inset 0 0 0 7px #80659f,
    inset 0 0 0 9px #362640, 0 6px 0 #3d2c51, 0 9px 0 #21192e, 0 24px 90px #090b2580;
  scrollbar-color: #a78abd #30243f;
}
:is(#guidePanel, #setupPanel, #gamePanel, dialog.flow-dialog)::backdrop { background: #111124b8; backdrop-filter: blur(8px); }
:is(#setupPanel, #gamePanel, dialog.flow-dialog) { padding: 31px 32px 34px; }
:is(#setupPanel, #gamePanel, dialog.flow-dialog) h2, #guidePanel .guide-copy h2 {
  font: 400 clamp(32px, 3.1vw, 41px)/1.12 var(--portal-display);
  letter-spacing: .018em; color: var(--portal-cream);
  text-shadow: 0 3px 0 #45283b; text-wrap: balance;
}
:is(#setupPanel, #gamePanel, dialog.flow-dialog) p:not(.forest-ribbon), #guidePanel .guide-copy p { color: var(--portal-muted); }
:is(.flow-dialog, #gamePanel) .forest-ribbon, .forest-ribbon {
  padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none;
  margin: 0 auto 16px; max-width: 100%;
  font: 500 10px/1.6 Poppins, sans-serif; letter-spacing: .13em;
  color: #d6bce8; text-shadow: none; transform: none; text-transform: uppercase;
}
.forest-ribbon::before, .forest-ribbon::after { content: none; }
#gamePanel .forest-ribbon { margin-left: 0; }
#guidePanel .preparation-label.forest-ribbon { padding: 0; margin: 0; font: 400 26px/1.1 var(--portal-display); letter-spacing: .02em; color: var(--portal-cream); }
#guidePanel { grid-template-columns: minmax(0, 1fr); }
#guidePanel .guide-header, #guidePanel .guide-footer { min-width: 0; box-sizing: border-box; }
#guidePanel .guide-header { padding: 24px 30px 22px; }
#guidePanel .preparation-grid { padding-bottom: 29px; }
#guidePanel .preparation-demo { border: 2px solid #211a32; border-radius: 15px; box-shadow: 0 0 0 2px #a185b64d, inset 0 0 0 1px #dac2e52e; }
#guidePanel .preparation-eyebrow { color: #cdb7dc; letter-spacing: .1em; }
#guidePanel .guide-copy h2 { font-size: 37px; margin-bottom: 16px; }
#guidePanel .guide-copy p { line-height: 1.85; }
#guidePanel .guide-footer { padding: 22px 30px 28px; border-top: 1px solid #b99dce38; background: #261e3559; }
#guidePanel .guide-input-picker { border: 1px solid #ac8cbd66; background: #281f39; padding: 4px; border-radius: 10px; }
#guidePanel .guide-input-picker button { min-height: 36px; padding: 8px 15px; color: #cdbedb; border-radius: 7px; }
#guidePanel .guide-input-picker button[aria-pressed='true'] { border-color: #e5b67f88; color: #ffe3aa; background: linear-gradient(#735169, #513b57); box-shadow: inset 0 1px 0 #f1d3a333; }
#guidePanel #guideCameraSlot { border: 2px solid #ac8ec4; box-shadow: 0 4px 0 #261d3c; background: #211c31; }
#guidePanel .guide-bindings, #guidePanel #guideControlKeys kbd, #gamePanel .control-guide kbd { border-color: #ad8ec166; background: #2a213a; color: var(--portal-cream); }
#guidePanel .preparation-progress li { border-color: #a78abb77; background: #2a203a; color: #d3c0df; }
#guidePanel .preparation-progress [aria-current='step'] { background: #ffbf78; color: #3d263e; border-color: #ffe3aa; box-shadow: 0 0 0 3px #ffcb7912; }
#guidePanel .preparation-progress .is-complete { background: #554e60; border-color: #b2bb9e; color: #e0edc7; }
#guidePanel #guideInputLabel { color: var(--portal-muted); background: #30243f; border-color: #a689bc44; }
#guidePanel #guideBack { border-color: #261d3c; background: linear-gradient(#ad8ec1, #6a507f); box-shadow: inset 0 1px 0 #e1c4ef88, 0 3px 0 #21192e; }

/* Secondary controls stay quieter than the gem-topped action. */
:is(#overscreen #saveName, #gamePanel #panelCameraTools button,
    #guidePanel #guideTouchControls button) {
  border: 2px solid #9d80b5; border-radius: 10px; background: linear-gradient(#634b78, #493554);
  color: var(--portal-cream); box-shadow: inset 0 1px 0 #d2b5e644, 0 3px 0 #261d3c;
  font-family: Poppins, sans-serif; text-shadow: none;
}
:is(#overscreen #saveName, #gamePanel #panelCameraTools button):hover:enabled { filter: brightness(1.12); }
:is(#overscreen #saveName, #gamePanel #panelCameraTools button):active:enabled { transform: translateY(2px); box-shadow: inset 0 1px 0 #d2b5e644, 0 1px 0 #261d3c; }
:is(#gamePanel .panel-links button, #overscreen #resultHome, #overscreen #resultControls, dialog.flow-dialog .flow-text, #guidePanel #guidePrevious) { color: #d7c6e3; font-family: Poppins, sans-serif; }
#gamePanel details { border-color: #a98dbd38; padding-bottom: 14px; margin-top: 14px; }
#gamePanel summary { color: #f0e0f2; min-height: 40px; }
#gamePanel select, #guidePanel select, #overscreen .result-name input { border: 2px solid #9b7aaf88; border-radius: 9px; background: #291f38; color: var(--portal-cream); box-shadow: inset 0 2px 5px #1c152d55; }
#gamePanel .sound-setting input { accent-color: #c7a3de; }
#gamePanel .sound-setting output { color: #ffe0b0; }
#gamePanel #resumeBtn { margin-top: 29px; }
#trackingPanel #trackingStatus { color: #d8e7b9; }

/* Results retain a readable hierarchy of achievement, total, then statistics. */
#overscreen { background: linear-gradient(#1511289e, #151128e8); }
#overscreen .results-panel { padding: 43px 35px 32px; }
#overscreen .results-panel::after { content: none; }
#overscreen .results-panel > .forest-ribbon { padding: 8px 24px; border: 2px solid #9d80b5; border-radius: 10px; background: #473352; box-shadow: inset 0 1px 0 #d2b5e644, 0 3px 0 #261d3c; font: 400 22px/1.2 var(--portal-display); letter-spacing: .02em; color: #ffcf91; transform: translateX(-50%); }
#overscreen #resultTitle { font: 400 clamp(34px, 3.3vw, 45px)/1.1 var(--portal-display); letter-spacing: .018em; text-shadow: 0 3px 0 #45283b; }
#overscreen #resultScore { font: 600 clamp(48px, 5vw, 66px)/1.1 Poppins, sans-serif; letter-spacing: -.04em; color: #ffc07c; text-shadow: 0 3px 0 #45283b; }
#overscreen #recordStamp { font-family: var(--portal-display); font-size: 21px; color: #3a293d; background: #ffd18d; border-color: #4d3550; }
#overscreen #overstats .pill span { font: 500 21px/1.4 Poppins, sans-serif; color: #fff0cf; }
#overscreen .marks-heading, #overscreen #overboard .bhead h2 { font: 400 25px/1.15 var(--portal-display); color: #ffe3b8; letter-spacing: .015em; }
#overscreen .result-ranking { border-color: #a98dbd55; }
#overscreen .mountain-marks li { border-color: #a98dbd33; }
#overscreen .mark-seal { background: #af8dca26; color: #dbc3eb; }
#overscreen #shareAchievement { min-height: 55px; font-size: 12px; }
#overscreen #downloadAchievement, #overscreen #copyAchievement { font-size: 10px; min-height: 32px; }
#overscreen #overboard ol li { border-color: #b69bcc26; color: #ded0e8; }
#overscreen #overboard .self { background: #c5a3de14; color: #ffe2b6; }
#overscreen .result-name input { min-width: 0; }
#overscreen #saveName { padding: 8px 12px; }

/* The course keeps its minimal HUD; the material is reserved for controls. */
body[data-screen='playing'] #hud #score { color: #fff0cf; text-shadow: 0 2px 0 #39263e, 0 3px 12px #090d25a6; }
body[data-screen='playing'] #hud .score-unit { color: #dbc8e5; }
body[data-screen='playing'] #hud #scoreBonus { color: #ffd095; }
body[data-screen='playing'] #tabs .tab, #tabs #muteBtn { border: 1px solid #ae8ac166; border-radius: 10px; background: #3c2c50a6; color: #fff0cf; box-shadow: inset 0 1px 0 #d7bce633, 0 3px 0 #241a35; }
body[data-screen='playing'] #stageNotice strong, body[data-screen='playing'] #runFeedback strong,
body[data-screen='playing'] #comboNotice strong, body[data-screen='playing'] #trickNotice strong,
body[data-screen='playing'] #passed { font: var(--game-event-font); letter-spacing: .02em; color: var(--game-event-color); text-shadow: var(--game-event-shadow); }
body[data-screen='playing'] #runFeedback strong { color: #ffbd91; }
#courseProgress .course-track { background: #b99fce35; }
#courseProgress .course-track i { background: #e1caee; }
#trickNotice .trick-progress { background: #b99fce35; }
#trickNotice .trick-progress i { background: #ffd095; }
#launchCount { font-family: var(--portal-display); color: #ffe3aa; text-shadow: 0 5px 0 #60404d, 0 14px 35px #090d2580; }
#launchLabel { color: #e4d1ed; font-family: Poppins, sans-serif; }
#arrivalOverlay h2 { font-family: var(--portal-display); font-weight: 400; letter-spacing: .02em; color: #ffe3aa; }
#arrivalOverlay > div { background: radial-gradient(ellipse, #42304fdd, #241d38bb); border-color: #ad8fc04d; }
#cameraDock #camwrap { border: 2px solid #9e80b9; border-radius: 12px; background: #30233edb; box-shadow: inset 0 1px 0 #d7bce655, 0 4px 0 #241a35; }
#cameraDock .camera-controls button { background: #624a76; color: #fff0cf; border-radius: 6px; }
#trickTouch button { background: #3c2c50db; border-color: #ad8fc088; color: #fff0cf; box-shadow: inset 0 1px 0 #d7bce633, 0 3px 0 #241a35; }
#trickTouch button:active { background: #654a77; border-color: #e0bfef; }
#startscreen .loading-state progress { accent-color: #c7a3de; }

@media (max-width: 700px) {
  #guidePanel[open] { grid-template-rows: max-content max-content max-content; }
  #guidePanel .preparation-grid { min-height: auto; }
  :is(#setupPanel, #gamePanel, dialog.flow-dialog) { padding: 28px 24px 30px; }
  :is(#setupPanel, #gamePanel, dialog.flow-dialog) h2 { font-size: 33px; }
  :is(#gamePanel #resumeBtn, #overscreen #againbtn, #overscreen[data-completed] #againbtn, #overscreen #shareAchievement, dialog.flow-dialog .flow-primary) { font-size: 25px; padding: 13px 22px; }
  #guidePanel .guide-header { padding: 22px 22px 18px; min-height: 70px; }
  #guidePanel .preparation-label.forest-ribbon { font-size: 24px; }
  #guidePanel .guide-copy h2 { font-size: 31px; }
  #guidePanel .preparation-grid { padding: 0 22px 23px; gap: 21px; }
  #guidePanel .guide-footer { position: static; padding: 21px 22px 27px; gap: 16px; }
  #guidePanel #guideNext, #guidePanel:is([data-phase], [data-quick]) #guideNext { min-width: 142px; font-size: 23px; padding: 12px 16px; min-height: 56px; }
  #guidePanel .preparation-actions { gap: 14px; }
  #overscreen .results-panel { padding: 38px 25px 28px; border-radius: 20px; }
  #overscreen #resultTitle { font-size: 35px; }
  #overscreen #resultScore { font-size: 54px; }
  #overscreen .forest-result-hero { gap: 18px; }
  #overscreen .forest-result-actions { gap: 20px; }
  body[data-screen='playing'] #stageNotice strong, body[data-screen='playing'] #runFeedback strong,
  body[data-screen='playing'] #comboNotice strong, body[data-screen='playing'] #trickNotice strong,
  body[data-screen='playing'] #passed { font-size: var(--game-event-size); }
  :root { --game-event-size:25px; }
}
@media (max-width: 390px) {
  #guidePanel .guide-header { gap: 10px; }
  #guidePanel .preparation-label.forest-ribbon { font-size: 22px; }
  #guidePanel .preparation-header-actions { gap: 6px; min-width: 0; }
  #guidePanel #guideInputLabel { box-sizing: border-box; max-width: 56px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  #guidePanel .preparation-actions { width: 100%; justify-content: space-between; margin-left: 0; }
  #guidePanel .preparation-footer-context { width: 100%; }
  #guidePanel .guide-copy h2 { font-size: 29px; }
  #overscreen .forest-result-hero { grid-template-columns: 70px minmax(0, 1fr); gap: 14px; }
  #overscreen .forest-result-emblem { height: 100px; }
  #overscreen #resultTitle { font-size: 29px; }
  #overscreen #resultScore { font-size: 43px; }
  #overscreen #resultPerformance { gap: 9px; }
  #overscreen #resultPerformance dd { font-size: 16px; }
}
@media (max-height: 650px) and (min-width: 701px) {
  #guidePanel .guide-header { padding-top: 18px; padding-bottom: 18px; }
  #guidePanel .guide-copy h2 { font-size: 31px; }
  #guidePanel .guide-footer { padding-top: 20px; padding-bottom: 23px; }
}
@media (prefers-reduced-motion: reduce) {
  :is(#startscreen #startbtn, #guidePanel #guideNext, #setupPanel #setupContinue,
      #gamePanel #resumeBtn, #overscreen #againbtn, #overscreen[data-completed] #againbtn, #overscreen #shareAchievement,
      dialog.flow-dialog .flow-primary) { transition: none; }
  :is(#startscreen #startbtn, #guidePanel #guideNext, #setupPanel #setupContinue,
      #gamePanel #resumeBtn, #overscreen #againbtn, #overscreen[data-completed] #againbtn, #overscreen #shareAchievement,
      dialog.flow-dialog .flow-primary):hover:enabled { transform: none; }
}
