@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:ital,wght@0,500;0,600;0,700;0,800;0,900;1,500&family=IBM+Plex+Mono:wght@400;500;600&family=Open+Sans:wght@400;500;600;700&display=swap');

:root {
  color-scheme: dark;
  --ink: #e7e5d7;
  --muted: #9c9b88;
  --dim: #666d62;
  --base: #171e1b;
  --panel: #242c28;
  --panel-edge: #46504a;
  --brass: #d4a942;
  --mint: #a8c8a5;
  --red: #e05b43;
  --display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --mono: 'IBM Plex Mono', Consolas, monospace;
  --sans: 'Open Sans', Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background: url("img/background.png");
  font-family: var(--mono);
	background-size:90vh
}

button { font: inherit; touch-action: manipulation; }

.game-shell { width: min(800px, calc(100% - 48px)); margin: 0 auto; padding: 18px 0 4px; }
.masthead { display: flex; justify-content: space-between; align-items: center; padding: 0 0 12px;}
.brand-group { display: flex; align-items: center; gap: 14px; }
.brand { display: inline-flex; gap: 12px; align-items: center; color: inherit; text-decoration: none; }
.brand-mark { display: flex; align-items: center; justify-content: center; gap: 1px; width: 43px; height: 43px; border: 1px solid var(--brass); color: var(--brass); font: 900 20px var(--display); transform: skew(-7deg);  background:rgba(0,0,0,0.3) }
.brand-mark-s { color: #fff; }
.brand-name { font: 800 25px/.82 var(--display); letter-spacing: 1px; }
.brand-name b { color: var(--brass); }
.brand-name i { color: var(--dim); font-style: italic; font-weight: 500; }
.brand-name [data-attract="digit"], .flash-letter { display: inline-block; }
.header-controls { display: flex; align-items: center; gap: 14px; }
.difficulty { display: flex; gap: 3px; padding: 3px; border: 1px solid var(--panel-edge); background: rgba(0,0,0,0.15); }
.difficulty button { border: 0; padding: 7px 11px; color: var(--muted); background: transparent; cursor: pointer; font: 500 10px var(--mono); text-transform: uppercase; transition: color .15s, background .15s; }
.difficulty button:hover { color: var(--ink); }
.difficulty button.selected { color: #1a201d; background: var(--brass); }
.difficulty button.locked { position: relative; color: rgba(255,255,255,.18); cursor: not-allowed; }
.difficulty button.locked:hover { color: rgba(255,255,255,.18); }
.lock-icon { position: absolute; top: 50%; left: 50%; width: 14px; height: 14px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transform: translate(-50%, -50%); }
.difficulty.in-trip button:not(.selected) { opacity: .4; cursor: not-allowed; }
.difficulty.in-trip button:not(.selected):hover { color: var(--muted); }
.difficulty button.unlock-new { animation: symbol-new-pulse 2.8s ease-in-out infinite; }
.difficulty button.unlock-perfect { animation: difficulty-perfect-glow 1.6s ease-in-out infinite; }

.game-board { display: grid; grid-template-columns: 1fr; gap: 16px; padding-top: 4px; touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.left-rail { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; min-width: 0; }
.main-column { display: flex; flex-direction: column; gap: 0; min-width: 0; }
.panel { border: 1px solid var(--panel-edge); background: linear-gradient(145deg, rgba(255,255,255,.035), transparent 38%), var(--panel); box-shadow: inset 0 1px rgba(255,255,255,.04), 0 8px 24px rgba(0,0,0,.14); }
.timer-panel { min-height: 0; padding: 10px 12px; border-top: 0; background: rgba(0,0,0,0.3); box-shadow: none; }
.page-footer { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.page-footer > .volume-control { justify-self: end; }
.timer-track { height: 5px; margin: 0; overflow: hidden; background: #111714; -webkit-mask: repeating-linear-gradient(90deg, #000 0 5px, transparent 5px 9px); mask: repeating-linear-gradient(90deg, #000 0 5px, transparent 5px 9px); }
.timer-fill { width: 100%; height: 100%; opacity: .1; background: var(--mint); transform-origin: left; transition: background .2s; }
.timer-fill.urgent { background: var(--red); }

.splash-panel { position: relative; padding: 0; border: 0; overflow: hidden; container-type: inline-size; }
.splash-panel img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; }
.best-trips-board { position: absolute; top: 28.5%; right: 0; left: 0; display: grid; gap: 3.5cqw; padding: 0 6cqw; color: #fff; font: 600 4.4cqw/1.5 var(--sans); text-align: center; text-shadow: 0 1px 3px rgba(0,0,0,.9), 0 0 8px rgba(0,0,0,.8); }
.best-trips-board[hidden] { display: none; }
.board-heading { color: var(--muted); }
.board-name { color: #ffd84a; font: 800 6cqw var(--display); letter-spacing: .1em; }
.board-sep { opacity: .5; }
.board-cleanest { font-size: .75em; }
@container (min-width: 260px) {
  .best-trips-board { gap: 3.8cqw; font-size: 4.6cqw; }
  .board-name { font-size: 6.2cqw; }
}
@container (min-width: 330px) {
  .best-trips-board { gap: 4cqw; font-size: 4.6cqw; line-height: 1.42; }
  .board-name { font-size: 6.2cqw; }
}
.splash-panel .level-reveal { transform: translateY(100%); }
.splash-panel.animate .level-reveal { transition: transform .6s ease-out, box-shadow .6s ease-out; }
.trip-slideshow { position: absolute; z-index: 3; inset: 0; }
.splash-panel .level-reveal.casting-shadow { box-shadow: 0 -6px 10px rgba(0,0,0,.45), 0 -18px 32px rgba(0,0,0,.35); }
.palette-panel { --palette-gap: 8px; position: relative; container-type: inline-size; align-self: start; padding: 0; border: 0; background: transparent; box-shadow: none; }
.symbol-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--palette-gap); }
.symbol-key { position: relative; display: grid; place-items: center; aspect-ratio: 1; min-width: 0; padding: 5px; border: 1px solid rgba(255,255,255,0.5); color: var(--ink); background-color: #2c342f; cursor: pointer; transition: border-color .15s, background-color .15s, transform .12s, opacity .2s; }
.symbol-key[data-symbol="1"], .sequence-cell[data-symbol="1"]::before { background-image: linear-gradient(rgba(9,24,12,.34), rgba(9,24,12,.42)), url("img/bg-1.png"); background-position: center; background-size: cover; }
.symbol-key[data-symbol="2"], .sequence-cell[data-symbol="2"]::before { background-image: linear-gradient(rgba(29,17,9,.3), rgba(29,17,9,.4)), url("img/bg-2.png"); background-position: center; background-size: cover; }
.symbol-key[data-symbol="3"], .sequence-cell[data-symbol="3"]::before { background-image: linear-gradient(rgba(4,24,39,.3), rgba(4,24,39,.4)), url("img/bg-3.png"); background-position: center; background-size: cover; }
.symbol-key[data-symbol="4"], .sequence-cell[data-symbol="4"]::before { background-image: linear-gradient(rgba(18,19,22,.3), rgba(18,19,22,.4)), url("img/bg-4.png"); background-position: center; background-size: cover; }
.symbol-key[data-symbol="5"], .sequence-cell[data-symbol="5"]::before { background-image: linear-gradient(rgba(24,14,38,.3), rgba(24,14,38,.4)), url("img/bg-5.png"); background-position: center; background-size: cover; }
.symbol-key[data-symbol="6"], .sequence-cell[data-symbol="6"]::before { background-image: linear-gradient(rgba(36,27,8,.3), rgba(36,27,8,.4)), url("img/bg-6.png"); background-position: center; background-size: cover; }
.symbol-key[data-symbol="7"], .sequence-cell[data-symbol="7"]::before { background-image: linear-gradient(rgba(14,20,30,.3), rgba(14,20,30,.4)), url("img/bg-7.png"); background-position: center; background-size: cover; }
.symbol-key[data-symbol="8"], .sequence-cell[data-symbol="8"]::before { background-image: linear-gradient(rgba(38,12,10,.3), rgba(38,12,10,.4)), url("img/bg-8.png"); background-position: center; background-size: cover; }
.symbol-key[data-symbol="9"], .sequence-cell[data-symbol="9"]::before { background-image: linear-gradient(rgba(18,14,40,.3), rgba(18,14,40,.4)), url("img/bg-9.png"); background-position: center; background-size: cover; }
.symbol-key:hover:not(:disabled), .symbol-grid.preview .symbol-key:not(.locked):hover, .symbol-key:focus-visible { z-index: 1; border-color: var(--brass); background-color: #465047; outline: none; transform: translateY(-2px); }
.symbol-key:active:not(:disabled) { transform: translateY(1px); }
.symbol-key:disabled { cursor: not-allowed; }
.symbol-key:not(.locked):disabled { opacity: .92; cursor: default; }
.symbol-key.locked { border-style: dashed; border-color: rgba(255,255,255,.2); background: rgba(0,0,0,0.15); }
.symbol-key .symbol-icon { transform: translate(-10%, -10%); }
.symbol-icon { position: relative; display: block; width: 75%; height: 75%; }
.symbol-shadow, .symbol-art { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.symbol-shadow { z-index: 0; object-fit: contain; opacity: .5; filter: brightness(0) blur(2px); transform: translate(5px, 6px); }
.symbol-art { z-index: 1; object-fit: contain; }
.symbol-key .symbol-icon { z-index: 1; }
.symbol-key.unlocking { z-index: 1; animation: symbol-new-pulse 2.8s ease-in-out .45s infinite; }
.symbol-key.unlocking .symbol-art { animation: symbol-new-icon-pulse 2.8s ease-in-out .45s infinite; }
.symbol-key.unlocking::before { position: absolute; z-index: 0; inset: 0; background: var(--base); content: ''; pointer-events: none; animation: symbol-unlock-bg .7s ease-out both; }
.symbol-key.unlocking .symbol-icon { animation: symbol-unlock-icon 1.1s cubic-bezier(.34,1.56,.64,1) .45s both; }
.symbol-key.unlocking .symbol-number { animation: symbol-unlock-number .3s ease-out 1.4s both; }
.symbol-number { z-index: 2; position: absolute; right: 5px; bottom: 5px; padding: 3px 6px; border-radius: 4px; color: var(--ink); background: rgba(0,0,0,.5); font: 700 26px/1 var(--sans); }
.sequence-panel { position: relative; padding: 0; background: transparent; box-shadow: none; container-type: inline-size; }
.sequence-track { --sequence-cell-size: 120px; display: flex; align-items: flex-start; gap: 5px; height: calc(var(--sequence-cell-size) + 16px); padding: 7px; overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none; border: 1px solid #131916; background: rgba(0,0,0,0.3); }
.sequence-track::-webkit-scrollbar { display: none; }
.sequence-cell { display: grid; position: relative; flex: 0 0 var(--sequence-cell-size); place-items: center; width: var(--sequence-cell-size); height: var(--sequence-cell-size); will-change: translate; }
.sequence-cell::before { position: absolute; z-index: 0; inset: 0; border: 1px solid #3c453e; background: linear-gradient(150deg, #353e38, #262d29); content: ''; transition: border-color .15s, background-color .15s; }
.sequence-cell::after { position: absolute; z-index: 2; inset: 0; border: 1px solid transparent; content: ''; opacity: 0; pointer-events: none; }
.sequence-cell > .symbol-icon { position: relative; z-index: 1; width: 79.2%; height: 79.2%; }
.sequence-cell:not(.current)::before { filter: brightness(.5) saturate(.25); }
.sequence-cell.current::before { border-color: #fff; }
.sequence-cell.current::after { box-shadow: 0 0 18px rgba(255,255,255,.8); will-change: opacity; animation: current-pulse 2.2s ease-in-out infinite; }
.sequence-cell.current.entering::after { animation: none; }
.sequence-cell.entering::before { animation: sequence-square-enter .36s cubic-bezier(.35,0,.65,1) both; animation-delay: var(--entry-delay, 0ms); }
.sequence-cell.entering .symbol-icon { animation: sequence-icon-enter .36s cubic-bezier(.35,0,.65,1) both; animation-delay: var(--entry-delay, 0ms); }
.sequence-cell.matched { animation: matched-fade .48s ease-out forwards; }
.sequence-cell.matched::after { animation: matched-slot .48s ease-out forwards; }
.sequence-cell.matched .symbol-icon { animation: matched-icon .48s ease-out forwards; }
.sequence-cell.matched .symbol-icon::after { background: #fff; animation: matched-white .48s ease-out forwards; }
.sequence-cell.wrong::before { border-color: var(--red); background: transparent; }
.sequence-cell.wrong::after { border-color: var(--red); background: rgba(224,91,67,.22); box-shadow: inset 0 0 22px rgba(224,91,67,.65), 0 0 18px rgba(224,91,67,.7); animation: wrong-flash .36s ease-out both; }
.sequence-cell.wrong .symbol-art { filter: drop-shadow(0 0 4px var(--red)) drop-shadow(0 0 10px rgba(224,91,67,.9)); }
.sequence-cell.wrong .symbol-shadow { opacity: .9; filter: brightness(0) drop-shadow(0 0 6px var(--red)) drop-shadow(0 0 13px rgba(224,91,67,.9)); }
.symbol-icon::after { position: absolute; z-index: 2; inset: 0; background: var(--red); content: ''; opacity: 0; pointer-events: none; -webkit-mask: var(--icon-src) center / contain no-repeat; mask: var(--icon-src) center / contain no-repeat; }
.sequence-cell.wrong .symbol-icon::after { opacity: .5; }
.sequence-cell.fading { animation: sequence-fade-out .4s ease-out forwards; }
.start-overlay { position: absolute; z-index: 2; inset: 0; display: flex; align-items: center; gap: clamp(10px, 3cqw, 24px); padding: 0 clamp(10px, 3cqw, 24px); pointer-events: none; }
.game-over-label { flex: 1 1 auto; min-width: 0; margin: 0; color: var(--red); font: 800 clamp(16px, 4cqw, 22px) var(--display); letter-spacing: 2px; text-shadow: 0 0 12px rgba(224,91,67,.6); }
.game-over-label.hidden { display: none; }
.game-over-label.level-complete { animation: label-color-cycle 4s ease-in-out infinite; }
.game-over-label.intro { color: #fff; text-shadow: none; }
.palette-hint { position: absolute; z-index: 2; top: calc((100cqw - 2 * var(--palette-gap)) / 3 + var(--palette-gap) + 14px); left: 0; right: 0; padding: 0 12px; text-align: center; text-shadow: 0 2px 6px rgba(0,0,0,.9); pointer-events: none; }
.palette-hint .label-headline { justify-content: center; }
.label-headline { display: flex; align-items: center; gap: clamp(6px, 1.6cqw, 12px); font-size: clamp(18px, 5cqw, 32px); }
.label-icon { flex: 0 0 auto; width: clamp(20px, 5.5cqw, 36px); height: clamp(20px, 5.5cqw, 36px); fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.game-over .label-headline { font-size: clamp(22px, 6.5cqw, 44px); }
.intro .label-headline { font-size: clamp(14px, 4.2cqw, 30px); }
.intro .label-icon { width: clamp(16px, 4.6cqw, 32px); height: clamp(16px, 4.6cqw, 32px); }
.glow-icon { color: #ffd84a; animation: perfect-star-glow 1.6s ease-in-out infinite; }
.filled-icon { stroke: none; }
.label-headline.underlined { display: inline-flex; padding-bottom: clamp(3px, 1cqw, 6px); border-bottom: 2px solid currentColor; }
.label-headline.underlined + .label-detail { margin-top: clamp(3px, 1cqw, 6px); }
.intro .label-headline.underlined { border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: rgba(255,255,255,.3); }
.stat-label { opacity: .5; }
.label-stats { display: block; margin-top: clamp(3px, 1cqw, 6px); color: #fff; font: 700 clamp(12px, 3cqw, 17px)/1.45 var(--sans); letter-spacing: normal; text-shadow: 0 1px 4px rgba(0,0,0,.8); }
.perfect { color: #ffd84a; animation: perfect-glow 1.6s ease-in-out infinite; }
.icon-red { color: var(--red); }
.label-inline-icon { width: 1.1em; height: 1.1em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.15em; }
.stat-aside { margin-left: .5em; font-size: .75em; }
.stat-sep { margin-right: .5em; }
.stat-aside.trip-total { color: #fff; font-size: 1em; }
.small-stat { font-size: .75em; }
.label-star { width: 1.05em; height: 1.05em; fill: currentColor; vertical-align: -.12em; animation: perfect-star-glow 1.6s ease-in-out infinite, perfect-spin 6s linear infinite; }
.label-detail { display: block; color: var(--muted); font: 500 clamp(11px, 2.6cqw, 15px) var(--sans); letter-spacing: normal; }
.start-button { position: relative; display: inline-flex; flex: 0 0 auto; margin-left: auto; pointer-events: auto; align-items: center; justify-content: center; gap: 26px; min-height: 72px; border: 2px solid #d4a942; padding: 0 26px 0 0; color: #fff; background: rgba(0,0,0,.62); -webkit-backdrop-filter: blur(7px); backdrop-filter: blur(7px); filter: drop-shadow(0 6px 8px rgba(0,0,0,.55)); cursor: pointer; font: 800 34px var(--display); letter-spacing: .4px; white-space: nowrap; animation: button-border-cycle 2.5s ease-in-out infinite; transition: background .15s, opacity .15s, box-shadow .15s, scale .15s; }
.start-button:hover { background: rgba(0,0,0,.74); box-shadow: 0 0 16px currentColor; scale: 1.05; -webkit-text-fill-color: #fff; }
.start-button::after { position: absolute; inset: -2px; z-index: -1; box-shadow: 0 0 18px currentColor, 0 0 36px currentColor; content: ''; pointer-events: none; animation: button-glow-pulse 2.5s ease-in-out infinite; }
.start-button.hidden { display: none; }
.button-icon { display: grid; place-items: center; align-self: stretch; width: 44px; background: currentColor; -webkit-text-fill-color: #111; font-size: 20px; }
.start-button.icon-only { padding: 0; }
.start-button.icon-only .button-icon { display: grid; width: 72px; background: transparent; -webkit-text-fill-color: currentColor; font-size: 32px; }
.page-footer { padding-top: 14px; color: var(--dim); font-size: 8px; line-height: 1; letter-spacing: .65px; }
.page-footer b { color: var(--brass); font-weight: 400; }
.footer-info { display: flex; align-items: center; gap: .5em; }
.footer-link { color: var(--muted); text-decoration: none; transition: color .15s; }
.footer-link:hover { color: var(--brass); }
.layout-toggle { justify-self: start; display: inline-flex; align-items: center; gap: 8px; padding: 0; border: 0; color: var(--muted); background: transparent; cursor: pointer; font: inherit; letter-spacing: inherit; transition: color .15s; }
.layout-icon { display: grid; place-items: center; width: 28px; height: 28px; border: 1px solid #505a51; transition: border-color .15s; }
.layout-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.layout-toggle:hover { color: var(--brass); }
.layout-toggle:hover .layout-icon { border-color: var(--brass); }
body[data-layout="desktop"] :is(.layout-icon, .volume-control .sound-toggle) { border-color: rgba(255,255,255,.12); }
body[data-layout="desktop"] :is(.layout-toggle:hover .layout-icon, .volume-control .sound-toggle:hover) { border-color: var(--brass); }
.sound-toggle { display: grid; place-items: center; width: 28px; height: 28px; border: 1px solid #505a51; padding: 0; color: var(--muted); background: transparent; cursor: pointer; transition: border-color .15s, color .15s; }
.sound-toggle:hover { border-color: var(--brass); color: var(--brass); }
.sound-toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sound-toggle path:first-child { fill: currentColor; }
.trip-restart { font-size: 17px; line-height: 1; }
.trip-restart[hidden] { display: none; }
.volume-control { position: relative; }
.volume-popup { position: absolute; z-index: 5; right: 0; bottom: calc(100% + 8px); display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid #505a51; background: var(--panel); box-shadow: 0 8px 24px rgba(0,0,0,.45); }
.volume-popup[hidden] { display: none; }
.volume-slider { width: 120px; accent-color: var(--brass); cursor: pointer; }

@keyframes perfect-glow { 0%, 100% { text-shadow: 0 0 4px rgba(255,216,74,.5); } 50% { text-shadow: 0 0 10px #ffd84a, 0 0 18px rgba(255,216,74,.7); } }
@keyframes perfect-star-glow { 0%, 100% { filter: drop-shadow(0 0 2px rgba(255,216,74,.5)); } 50% { filter: drop-shadow(0 0 5px #ffd84a) drop-shadow(0 0 9px rgba(255,216,74,.7)); } }
@keyframes difficulty-perfect-glow { 0%, 100% { box-shadow: 0 0 4px rgba(255,216,74,.5); text-shadow: 0 0 4px rgba(255,216,74,.5); } 50% { box-shadow: 0 0 10px #ffd84a, 0 0 18px rgba(255,216,74,.7); text-shadow: 0 0 10px #ffd84a; } }
@keyframes perfect-spin { to { rotate: 360deg; } }
@keyframes symbol-new-pulse { 0%, 100% { border-color: rgba(255,255,255,.5); box-shadow: 0 0 0 rgba(255,255,255,0); } 50% { border-color: #ffd84a; box-shadow: 0 0 10px 2px rgba(255,255,255,.38), 0 0 22px 6px rgba(255,255,255,.18); } }
@keyframes symbol-new-icon-pulse { 0%, 100% { filter: brightness(1) saturate(1) drop-shadow(0 0 0 rgba(255,255,255,0)); } 50% { filter: brightness(1.6) saturate(.5) drop-shadow(0 0 6px rgba(255,255,255,.45)); } }
@keyframes symbol-unlock-bg { to { opacity: 0; } }
@keyframes symbol-unlock-icon { from { scale: 0; } to { scale: 1; } }
@keyframes symbol-unlock-number { from { opacity: 0; } }
@keyframes wrong-flash { 0%, 35% { opacity: 1; } 100% { opacity: 0; } }
@keyframes matched-fade { to { opacity: .18; } }
@keyframes sequence-square-enter { 0%, 30% { opacity: 0; transform: translateY(150px); } 100% { opacity: 1; transform: translateY(0); } }
@keyframes sequence-icon-enter { 0%, 30% { opacity: 0; transform: translateY(-300px); } 100% { opacity: 1; transform: translateY(0); } }
@keyframes sequence-fade-out { to { opacity: 0; transform: scale(.55); filter: blur(6px); } }
@keyframes current-pulse { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }
@keyframes label-color-cycle { 0%, 100% { color: #d4a942; text-shadow: 0 0 12px rgba(212,169,66,.6); } 33% { color: #68cf82; text-shadow: 0 0 12px rgba(104,207,130,.6); } 66% { color: #64b9f2; text-shadow: 0 0 12px rgba(100,185,242,.6); } }
@keyframes button-glow-pulse { 0%, 100% { opacity: .15; } 50% { opacity: .45; } }
@keyframes button-border-cycle { 0%, 100% { color: #d4a942; border-color: #d4a942; } 33% { color: #68cf82; border-color: #68cf82; } 66% { color: #64b9f2; border-color: #64b9f2; } }
@keyframes matched-slot { to { opacity: 0; } }
@keyframes matched-icon { 0%, 30% { opacity: 1; scale: 1; } 100% { opacity: 0; scale: .65; } }
@keyframes matched-white { 0%, 30% { opacity: 1; } 100% { opacity: 0; } }

@media (min-width: 1100px) {
  .game-board, .left-rail { gap: 18px; }
}

@media (max-width: 760px) {
  .game-shell { width: min(100% - 28px, 600px); padding-top: 16px; }
  .masthead { align-items: flex-start; gap: 10px; }
  .brand-mark { width: 37px; height: 37px;}
  .brand-name { font-size: 21px; }
  .header-controls { gap: 7px; }
  .difficulty button { padding: 7px 6px; font-size: 8px; }
  .game-board, .left-rail { gap: 12px; }
  .timer-panel { padding: 10px; }
  .palette-panel { --palette-gap: 6px; }
}

@media (max-width: 580px) {
  .start-button { padding: 0 26px; }
  .button-icon, .wide-only { display: none; }
  .symbol-number { right: 4px; bottom: 3px; font-size: 16px; }
}

@media (max-width: 450px) {
  .game-shell { width: calc(100% - 20px); }
  .brand { gap: 7px; }
  .brand-mark { width: 32px; height: 32px; font-size: 17px; }
  .brand-name { font-size: 18px; }
  .header-controls { gap: 5px; }
  .difficulty { gap: 0; padding: 2px; }
  .difficulty button { padding: 6px 4px; font-size: 7px; }
  .left-rail { gap: 8px; }
  .palette-panel { --palette-gap: 4px; }
  .sequence-track { --sequence-cell-size: 80px; gap: 3px; height: calc(var(--sequence-cell-size) + 12px); padding: 5px; }
  .start-button { min-height: 64px; padding: 0 20px; font-size: 30px; }
  .page-footer { gap: 10px; font-size: 7px; }
}

body[data-layout="mobile"] .game-shell {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 3fr);
  grid-template-rows: 1fr auto auto auto auto 1fr;
  grid-template-areas:
    ". . . splash"
    "brand brand brand splash"
    "credit credit credit splash"
    "difficulty difficulty difficulty splash"
    "restart . volume splash"
    ". . . splash"
    "sequence sequence sequence sequence"
    "timer timer timer timer"
    "palette palette palette palette"
    "toggle toggle toggle toggle";
  width: min(430px, calc(100% - 20px));
  padding: 10px 0;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
body[data-layout="mobile"] :is(.masthead, .brand-group, .header-controls, .game-board, .left-rail, .main-column, .page-footer) { display: contents; }
body[data-layout="mobile"] .game-shell::before { grid-column: 1 / 4; grid-row: 1 / 7; margin-right: -12px; background: linear-gradient(to right, transparent, rgba(0,0,0,.33)); content: ''; }
body[data-layout="mobile"] .brand { grid-area: brand; flex-direction: column; justify-self: center; gap: 6px; }
body[data-layout="mobile"] .brand-mark { width: 32px; height: 32px; font-size: 17px; }
body[data-layout="mobile"] .brand-name { font-size: 18px; white-space: nowrap; }
body[data-layout="mobile"] .footer-info { grid-area: credit; justify-self: center; margin-top: 8px; }
body[data-layout="mobile"] .difficulty { grid-area: difficulty; align-self: start; gap: 2px; margin-top: 12px; padding: 2px; }
body[data-layout="mobile"] .difficulty button { flex: 1; padding: 6px 2px; font-size: 7px; }
body[data-layout="mobile"] .volume-control { grid-area: volume; justify-self: end; margin-top: 10px; }
body[data-layout="mobile"] :is(.volume-control .sound-toggle, .trip-restart) { position: relative; width: auto; height: auto; border: 0; opacity: .6; }
body[data-layout="mobile"] :is(.volume-control .sound-toggle, .trip-restart)::after { position: absolute; inset: -8px -12px -12px; content: ''; }
body[data-layout="mobile"] .layout-toggle { grid-area: toggle; justify-self: start; margin-top: 14px; }
body[data-layout="mobile"][data-playing] .layout-toggle { opacity: .3; pointer-events: none; }
body[data-layout="mobile"] .trip-restart { grid-area: restart; justify-self: start; margin-top: 10px; }
body[data-layout="mobile"] .volume-popup { top: calc(100% + 8px); bottom: auto; }
body[data-layout="mobile"] .splash-panel { grid-area: splash; align-self: start; aspect-ratio: 1; margin-left: 12px; }
body[data-layout="mobile"] .sequence-panel { grid-area: sequence; margin-top: 12px; }
body[data-layout="mobile"] .sequence-track { --sequence-cell-size: 80px; }
body[data-layout="mobile"] .timer-panel { grid-area: timer; padding: 10px; }
body[data-layout="mobile"] .palette-panel { --palette-gap: 8px; grid-area: palette; align-self: auto; margin-top: 12px; }
body[data-layout="mobile"] .symbol-key { aspect-ratio: 4 / 3; }
body[data-layout="mobile"].square-keys .symbol-key { aspect-ratio: 1; }
body[data-layout="mobile"] .start-button { min-height: 64px; padding: 0 20px; font-size: 30px; }
body[data-layout="mobile"] .start-button.icon-only { padding: 0; }
body[data-layout="mobile"] :is(.button-icon, .wide-only) { display: none; }

@media (hover: none) and (pointer: coarse) {
  .symbol-number { display: none; }
  .layout-toggle { display: none; }
  .symbol-key .symbol-icon { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}