:root {
  color-scheme: dark;
  --page: #0b1223;
  --surface: #111d34;
  --surface-raised: #182841;
  --ink: #fff1d8;
  --light: #f2f4fe;
  --quiet: #b6c1d8;
  --stroke: #31415e;
  --amber: #ffc373;
  --mint: #62d8c5;
  --coral: #ff9e91;
  --violet: #cfb0ff;
  --blue: #9bc8ff;
  --accent: var(--amber);
  --shell: 1120px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  font-size: 16px;
  background: var(--page);
  color: var(--light);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100svh; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; }
h1, h2, p { margin: 0; }
h1, h2, strong { overflow-wrap: anywhere; }
:focus-visible { outline: 3px solid var(--mint); outline-offset: 4px; }

.shell { width: min(var(--shell), calc(100% - 64px)); margin-inline: auto; }
.site-header { border-bottom: 1px solid #24314c; }
.header-content { display: flex; min-height: 72px; align-items: center; justify-content: space-between; gap: 16px; }
.header-actions, .hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; font-weight: 850; letter-spacing: 0.075em; font-size: 1.3rem; }
.brand-mark { position: relative; width: 38px; height: 38px; display: block; border-radius: 50%; background: #202c4d; border: 1px solid #5b6882; }
.brand-mark::before { content: ''; position: absolute; inset: 13px 4px; border: 1px solid #f5cc86; border-radius: 50%; transform: rotate(-29deg); opacity: .85; }
.brand-mark i { position: absolute; z-index: 1; border-radius: 50%; background: var(--amber); box-shadow: inset 1px 1px 2px #fff9; width: 12px; height: 12px; left: 14px; top: 12px; }
.brand-mark i:nth-child(2) { width: 7px; height: 7px; background: var(--mint); left: 6px; top: 22px; }
.brand-mark i:nth-child(3) { width: 6px; height: 6px; background: var(--violet); left: 25px; top: 8px; }

.offline-status { color: var(--quiet); font-size: .88rem; white-space: nowrap; }
.offline-status::before { content: ''; display: inline-block; width: 7px; height: 7px; background: var(--mint); border-radius: 50%; margin-inline-end: 8px; vertical-align: .1em; }
.button { min-height: 46px; padding: 10px 17px; display: inline-flex; justify-content: center; align-items: center; gap: 8px; border: 1px solid transparent; border-radius: 12px; font-weight: 730; line-height: 1.2; text-align: center; text-decoration: none; transition: background-color .18s, border-color .18s, color .18s, transform .18s; }
.button.primary { color: #201407; background: var(--amber); border-color: #ffd5a0; box-shadow: 0 3px 0 #80512a; }
.button.primary:hover:not(:disabled) { background: #ffd49c; transform: translateY(-1px); }
.button.quiet { color: var(--light); background: #172540; border-color: var(--stroke); }
.button.quiet:hover:not(:disabled), .button.hero-secondary:hover { background: #26395e; border-color: #7889aa; }
.button.hero-secondary { color: var(--light); background: #101a30bb; border-color: #66718e; }
.button:disabled { color: #a3aec5; background: #171f32; border-color: #344159; box-shadow: none; }
.settings-button span { color: var(--amber); font-size: 1.18rem; line-height: 1; }

main.shell { padding-block: 26px 44px; }
.hero { position: relative; display: flex; align-items: center; min-height: 374px; isolation: isolate; overflow: hidden; border: 1px solid #4a5674; border-radius: 26px; background: #141b37 url('assets/cabin.jpg') center 52% / cover no-repeat; }
.hero::before { position: absolute; content: ''; inset: 0; z-index: -1; background: linear-gradient(90deg, #0b1426 0%, #0b1426ed 25%, #0b14268a 46%, #0b142600 70%); }
.hero-content { position: relative; padding: 32px clamp(28px, 6vw, 72px) 40px; }
.hero-subtitle { color: #dce3f3; font-size: .88rem; font-weight: 680; letter-spacing: .085em; }
.hero h1 { max-width: 7em; margin-top: 14px; color: var(--ink); font-size: clamp(3.6rem, 7.25vw, 6.45rem); line-height: .91; font-weight: 880; letter-spacing: -.086em; }
.hero h1 em { display: block; color: var(--amber); font-style: normal; }
.hero-description { margin: 22px 0 19px; color: #d8e2f3; font-size: 1.08rem; line-height: 1.5; }
.hero-actions { align-items: stretch; }
.hero-actions .button { min-height: 50px; padding-inline: 20px; }

.games { margin-top: 34px; scroll-margin-top: 20px; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px 16px; margin-bottom: 15px; }
.section-heading h2 { font-size: clamp(1.55rem, 3vw, 2rem); letter-spacing: -.048em; }
.secondary-text { color: var(--quiet); font-size: .92rem; }
.mode-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.mode-card { position: relative; display: flex; align-items: center; min-height: 143px; isolation: isolate; padding: 20px 14px 20px 20px; border: 1px solid var(--stroke); border-radius: 17px; background: var(--surface); text-decoration: none; overflow: hidden; transition: border-color .18s, background-color .18s, transform .18s; }
.mode-card:hover, .level-card:hover { border-color: var(--accent); background: var(--surface-raised); transform: translateY(-2px); }
.mode-text { z-index: 1; display: grid; gap: 6px; min-width: 0; flex: 1 1 auto; }
.mode-text strong { color: var(--ink); font-size: clamp(1.18rem, 2.15vw, 1.55rem); line-height: 1.07; letter-spacing: -.032em; }
.mode-text > span { color: var(--quiet); font-size: .93rem; line-height: 1.35; }
.mode-text .mode-meta { color: var(--accent); font-size: .86rem; margin-top: 4px; font-weight: 690; }
.theme-coral { --accent: var(--coral); }
.theme-mint { --accent: var(--mint); }
.theme-violet { --accent: var(--violet); }
.theme-blue { --accent: var(--blue); }

.marble { display: grid; place-items: center; position: relative; width: 82%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(ellipse at 32% 20%, #ffffff9e 0%, #ffffff17 27%, transparent 52%), radial-gradient(ellipse at 56% 104%, var(--orb-glow) 6%, var(--orb) 62%, var(--orb-dark) 98%); border: 1px solid var(--orb-edge); box-shadow: inset -2px -3px 6px #0004, inset 1px 2px 3px #fffa, 0 4px 7px #050913b8; color: #fffaf5; font-size: var(--symbol-size, clamp(1.05rem, 4.5vw, 2.1rem)); font-weight: 720; line-height: 1; text-shadow: 0 1px 4px #17042788; }
.coral { --orb: #b83854; --orb-dark: #7c2446; --orb-glow: #ff7a83; --orb-edge: #ff9eaa; }
.mint { --orb: #087e79; --orb-dark: #095865; --orb-glow: #31cdbb; --orb-edge: #77e0d1; }
.amber { --orb: #9b4e10; --orb-dark: #7c3e0b; --orb-glow: #ffc15e; --orb-edge: #ffe096; }
.violet { --orb: #6943ac; --orb-dark: #41296f; --orb-glow: #af78ee; --orb-edge: #d7adff; }

.mode-art { pointer-events: none; display: grid; align-content: center; justify-content: center; flex: 0 0 101px; height: 88px; width: 101px; --symbol-size: .76rem; }
.mode-art .marble { width: 23px; }
.art-tray { display: grid; grid-template-columns: repeat(3, 23px); gap: 3px; padding: 5px; border: 1px solid #ad8352; border-radius: 12px; background: #433143; transform: rotate(-9deg); }
.art-sort { position: relative; }
.art-case { position: absolute; width: 35px; top: 12px; left: 15px; display: grid; gap: 4px; place-items: center; background: #733f45; border: 1px solid #c18a75; border-radius: 9px; padding: 4px; transform: rotate(-11deg); }
.art-case.side { left: 53px; top: 21px; transform: rotate(10deg); }
.art-route { display: grid; grid-template-columns: repeat(2, 23px); gap: 2px; padding: 7px; border: 1px dashed #72d6ca; border-radius: 12px; background: #1a3b49; transform: rotate(11deg); }
.art-route .marble:last-child { grid-column: 2; }
.art-trace { display: grid; grid-template-columns: repeat(3, 23px); gap: 3px; padding: 4px; transform: rotate(-10deg); }
.art-trace .marble { box-shadow: 0 0 12px #b38cff87, inset 1px 1px 3px #fffb; }
.art-trace .marble:last-child { grid-column: 3; }
.art-tilt { display: grid; grid-template-columns: repeat(2, 23px); border: 1px solid #92b9e2; padding: 5px; gap: 4px; background: #243d57; border-radius: 10px; transform: rotate(14deg); }
.art-tilt i { height: 15px; border: 1px solid #577397; background: #172c49; border-radius: 3px; }

.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 2px 0 22px; color: var(--quiet); line-height: 1.4; }
.breadcrumbs a { color: var(--light); text-underline-offset: .23em; padding-block: 8px; }
.mode-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 185px; padding: 23px clamp(20px, 5vw, 47px); margin-bottom: 28px; background: var(--surface); border: 1px solid var(--stroke); border-radius: 21px; box-shadow: inset 0 3px 0 var(--accent); }
.mode-heading h1, .game-info h1 { color: var(--ink); font-size: clamp(2.18rem, 5.8vw, 4.2rem); letter-spacing: -.066em; font-weight: 870; line-height: 1.04; }
.mode-heading p, .game-instructions { max-width: 54ch; color: var(--quiet); line-height: 1.52; margin-top: 12px; }
.mode-heading .mode-art { transform: scale(1.24); margin-right: 6px; }
.level-list { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.level-card { min-height: 88px; height: 100%; display: flex; align-items: center; gap: 14px; padding: 14px; background: var(--surface); border: 1px solid var(--stroke); border-radius: 14px; text-decoration: none; transition: .18s ease; }
.level-number { display: grid; place-items: center; flex: 0 0 42px; height: 42px; background: #223454; color: var(--accent); border-radius: 11px; font-weight: 830; font-variant-numeric: tabular-nums; }
.level-copy { display: grid; gap: 4px; }
.level-copy strong { color: var(--light); line-height: 1.15; }
.level-copy > span { color: var(--quiet); font-size: .86rem; }

.game-layout { display: grid; grid-template-columns: minmax(0, .79fr) minmax(0, 1.21fr); align-items: start; column-gap: clamp(18px, 5vw, 65px); }
.game-info { padding-top: 25px; }
.game-level { margin-bottom: 9px; color: var(--accent); font-weight: 750; }
.route-color { display: flex; align-items: center; gap: 8px; margin-top: 12px; color: var(--light); font-weight: 690; }
.route-color .marble { width: 29px; --symbol-size: 1rem; }
.goal { margin-top: 24px; padding: 15px 17px; border: 1px solid var(--stroke); border-radius: 14px; background: var(--surface); }
.goal-line { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; line-height: 1.23; }
.goal-line strong { color: var(--accent); font-variant-numeric: tabular-nums; white-space: nowrap; }
progress { display: block; appearance: none; width: 100%; height: 7px; margin: 11px 0 0; border: 0; border-radius: 10px; overflow: hidden; background: #263857; accent-color: var(--accent); }
progress::-webkit-progress-bar { background: #263857; border-radius: 10px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 10px; transition: width .22s; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 10px; }
.game-play { width: 100%; max-width: 565px; justify-self: center; min-width: 0; }
.play-board { position: relative; }
.board { --cell-gap: 5px; display: grid; grid-template-columns: repeat(var(--columns), minmax(0, 1fr)); gap: var(--cell-gap); padding: 10px; overflow: hidden; background: #182748; border: 1px solid #586a8b; border-radius: 20px; box-shadow: inset 0 0 0 2px #23365a, 0 12px 36px #070c1680; }
.cell { appearance: none; display: grid; align-items: center; justify-items: center; position: relative; width: 100%; min-width: 0; aspect-ratio: 1; padding: 0; border: 1px solid #35476d; border-radius: 12px; background: #111c35; color: var(--light); touch-action: manipulation; }
.cell:focus-visible { z-index: 3; outline-offset: -1px; }
button.cell:hover:not(:disabled) { background: #28406b; border-color: #798eb8; }
.cell .marble { z-index: 1; pointer-events: none; }
.cell.has-window { background: #594039; border-color: #ba8f5f; }
.cell.window-on { background: #966735; border-color: #ffd187; box-shadow: inset 0 0 14px #ffd27a9c; }
.cell.is-selected, .suitcase.is-selected { border-color: var(--mint); outline: 2px solid var(--mint); outline-offset: -2px; }
.cell.is-hinted, .suitcase.is-hinted, .button.is-hinted { border-color: var(--amber); outline: 2px dashed var(--amber); outline-offset: -2px; }
[data-hint]::after { content: attr(data-hint); position: absolute; z-index: 4; inset: 3px 3px auto auto; min-inline-size: 18px; min-block-size: 18px; display: grid; place-items: center; padding-inline: 3px; border-radius: 50px; color: #201407; background: var(--amber); font-size: .73rem; font-weight: 850; line-height: 1; pointer-events: none; }
.cell.is-route { background: #1c474f; border-color: #699f9f; }
.cell.is-anchor { background: #4b3b28; border-color: #ab8755; }
.beacon { color: var(--amber); font-size: clamp(1.25rem, 4vw, 2.45rem); line-height: 1; }
.board-trace { background: #221e42; border-color: #6f6098; box-shadow: inset 0 0 0 2px #3c3263, 0 12px 36px #070c1680; }
.board-trace .cell { background: #1a1935; border-color: #443b64; }
.connector { position: absolute; z-index: 2; width: 103%; height: 4px; pointer-events: none; background: #f0d9ff; box-shadow: 0 0 8px #cd8aff; }
.connector.left { right: 50%; }
.connector.right { left: 50%; }
.connector.up, .connector.down { width: 4px; height: 103%; }
.connector.up { bottom: 50%; }
.connector.down { top: 50%; }
.board-tilt .is-stone { background: #45516d; border-color: #697a99; box-shadow: inset 0 3px 0 #94a1b44c; }
.socket { display: grid; place-items: center; position: absolute; z-index: 0; width: 77%; aspect-ratio: 1; border: 2px dashed var(--orb-edge); border-radius: 50%; color: var(--orb-edge); background: #090f21; font-size: var(--symbol-size, clamp(1.05rem, 4.5vw, 2.1rem)); }
.is-filled .socket { border-style: solid; background: var(--orb-dark); }

.suitcase-board { min-height: 250px; display: grid; justify-items: center; gap: 15px; padding: clamp(12px, 3vw, 23px); background: #271d35; border: 1px solid #6f515f; border-radius: 20px; box-shadow: inset 0 0 0 2px #302440; }
.suitcase-row { display: flex; justify-content: center; flex-wrap: wrap; gap: 9px; }
.suitcase { position: relative; min-width: 66px; width: clamp(66px, 14vw, 82px); display: grid; justify-items: center; padding: 9px 7px 5px; border: 1px solid #ba827c; border-radius: 12px; background: #69394b; color: #ffe3d8; }
.suitcase:hover:not(:disabled) { background: #875065; }
.suitcase:not(.pocket)::before { content: ''; display: block; position: absolute; width: 32%; height: 7px; border: 2px solid #c09791; border-radius: 4px 4px 0 0; bottom: 100%; left: 34%; }
.suitcase.is-packed { border-color: #93d8b1; background: #284c4d; }
.suitcase-slots { display: grid; gap: 4px; width: 100%; }
.suitcase-slot { display: grid; place-items: center; height: clamp(39px, 9vw, 56px); background: #2d1f33; border: 1px solid #9e7281; border-radius: 8px; }
.suitcase-slot .marble { width: min(87%, 45px); --symbol-size: 1.32rem; }
.suitcase-label { min-width: 0; font-size: .83rem; margin: 7px 0 2px; font-weight: 720; }
.suitcase.pocket { width: 95px; background: #443853; border-color: #9d86ac; }
.pocket .suitcase-slot { height: 44px; }

.mode-controls, .game-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }
.mode-controls:not(:empty) { margin-top: 12px; }
.game-message { min-height: 1.55em; margin: 10px 0; color: var(--ink); text-align: center; font-size: .98rem; line-height: 1.42; }
.outcome { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding: 13px 16px; border: 1px solid #548b8d; border-radius: 14px; background: #163d41; }
.outcome > div { display: grid; gap: 3px; }
.outcome strong { color: #d7ffe9; font-size: 1.13rem; }
.outcome span { color: #d1e6e2; font-size: .9rem; }

.settings { width: min(400px, calc(100vw - 26px)); padding: 22px; background: var(--surface); color: var(--light); border: 1px solid #667896; border-radius: 18px; box-shadow: 0 22px 60px #050912a8; }
.settings::backdrop { background: #060a16b8; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 9px; }
.dialog-heading h2 { color: var(--ink); letter-spacing: -.035em; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 55px; padding: 8px 0; border-top: 1px solid var(--stroke); cursor: pointer; }
.setting input { width: 21px; height: 21px; accent-color: var(--mint); }
.settings > form .button { width: 100%; margin-top: 16px; }

.cell.flash .marble { animation: scatter .22s ease-in both; }
.cell.falling .marble { animation: fall .31s cubic-bezier(.25,.64,.45,1) both; }
@keyframes scatter {
  0% { transform: scale(1); opacity: 1; }
  48% { transform: scale(1.13); filter: brightness(1.65); }
  100% { transform: scale(.25); opacity: 0; }
}
@keyframes fall {
  0% { transform: translateY(calc(-120% * var(--fall))); opacity: .65; }
  92% { transform: translateY(5%) scaleY(.95); }
  100% { transform: translateY(0) scaleY(1); opacity: 1; }
}
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }

@media (max-width: 900px) {
  .mode-list, .level-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { background-position: 53% center; }
}

@media (max-width: 690px) {
  .shell { width: calc(100% - 36px); }
  .header-content { min-height: 62px; }
  main.shell { padding-top: 16px; }
  .hero { min-height: 328px; }
  .hero h1 { font-size: clamp(3.25rem, 10vw, 4.8rem); }
  .game-layout { grid-template-columns: 1fr; row-gap: 12px; }
  .game-info { padding-top: 0; }
  .game-info h1 { font-size: clamp(2.1rem, 7.9vw, 3.4rem); }
  .goal { margin-top: 12px; }
  .breadcrumbs { margin-bottom: 12px; }
}

@media (max-width: 500px) {
  .shell { width: calc(100% - 24px); }
  .header-content { gap: 7px; }
  .header-actions { gap: 8px; }
  .offline-status { display: none; }
  .settings-button { padding: 9px 12px; }
  .hero { align-items: end; min-height: 350px; border-radius: 20px; background-position: 72% 29%; }
  .hero::before { background: linear-gradient(0deg, #0b1426 1%, #0b1426ef 28%, #0b14267d 67%, #0b14261c 98%); }
  .hero-content { padding: 22px 18px 24px; }
  .hero-subtitle { font-size: .8rem; }
  .hero h1 { font-size: clamp(3rem, 12.8vw, 4.3rem); }
  .hero-description { margin: 13px 0 15px; font-size: 1rem; }
  .hero-actions { gap: 8px; }
  .hero-actions .button { padding-inline: 12px; min-height: 44px; }
  .games { margin-top: 23px; }
  .mode-list, .level-list { grid-template-columns: 1fr; gap: 9px; }
  .mode-card { min-height: 111px; padding: 11px 15px; }
  .mode-text { gap: 4px; }
  .mode-text strong { font-size: 1.35rem; }
  .mode-meta { margin-top: 2px; }
  .mode-heading { align-items: flex-start; min-height: 0; margin-bottom: 21px; padding: 17px; }
  .mode-heading .mode-art { transform: scale(.83); margin-right: -11px; width: 79px; flex-basis: 79px; }
  .level-card { min-height: 67px; }
  .game-instructions { margin-top: 7px; }
  .game-level { margin-bottom: 5px; }
  .board { --cell-gap: 3px; padding: 6px; border-radius: 14px; }
  .cell { border-radius: 8px; }
  .game-actions .button { font-size: .92rem; min-height: 44px; padding-inline: 11px; }
  .suitcase-board { gap: 13px; padding: 14px 8px; }
  .suitcase-row { gap: 10px 7px; }
}
