:root { color-scheme: dark; font-family: system-ui, -apple-system, sans-serif; color: #f0f0f5; background: #11121a; --red: #ee4b4b; }
* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; background: radial-gradient(ellipse at 50% 5%, #262330 0, #11121a 65%); }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; font: inherit; cursor: pointer; border: 1px solid #363640; background: #20212b; border-radius: 6px; padding: 10px 13px; font-size: 12px; font-weight: 650; touch-action: manipulation; }
button:hover { background: #30313c; border-color: #66616c; }
button:disabled { opacity: .38; cursor: default; }
button:focus-visible, a:focus-visible { outline: 2px solid #f4c783; outline-offset: 3px; }
[hidden] { display: none !important; }
#arcade { width: min(900px, calc((100dvh - 280px) * 4 / 3 + 48px), 100%); padding: 26px 24px 16px; margin: auto; }
.masthead { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin: 0 0 18px; }
.wordmark { display: flex; align-items: center; gap: 14px; }
.wordmark > span { color: var(--red); font-size: 34px; font-weight: 900; }
h1 { font-size: 25px; margin: 0; letter-spacing: 3px; font-weight: 900; }
.wordmark p { font-size: 8px; color: #a7a4b3; letter-spacing: 1.8px; margin: 4px 0 0; }
.edition { font-size: 10px; font-weight: 750; letter-spacing: 2px; text-align: right; color: #bab5c4; }
.edition span { display: block; font-size: 9px; font-weight: 450; margin-top: 6px; color: #817c8e; }
#screen { width: 100%; aspect-ratio: 4/3; position: relative; background: #000; border: 1px solid #43404b; border-radius: 5px; box-shadow: 0 14px 50px #0006; overflow: hidden; }
#game { width: 100%; height: 100%; }
#game canvas { image-rendering: pixelated; }
#intro { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; background: #0d192c center / cover no-repeat; }
.intro-content { padding: 24px; width: 100%; align-self: end; background: linear-gradient(0deg, #080911fa 60%, #08091100); }
.intro-content .eyebrow { color: #e5c48e; }
.intro-content h2 { font-family: "Hiragino Mincho ProN",serif; color: #f3dfbb; font-size: clamp(28px, 5vw, 46px); margin: 8px 0 18px; }
.eyebrow { font-size: 11px; letter-spacing: 5px; color: #e4a2a0; }
h2 { font-size: clamp(24px, 5vw, 47px); line-height: 1.15; letter-spacing: 1px; font-weight: 900; margin: 22px 0; }
.intro-subtitle { color: #c9c5d0; font-size: 14px; margin: 0 0 24px; }
.primary { background: var(--red); color: #fff; border-color: #ee6767; font-size: 15px; padding: 14px 24px; border-radius: 5px; box-shadow: 0 5px 22px #de292927; }
.primary:hover { background: #fb6262; }
.primary span { margin-left: 16px; font-size: 12px; }
.start-hint { color: #a5a0b1; font-size: 11px; margin: 17px 0 0; }
#pause-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 22px; background: #060710a6; }
#pause-overlay > span { font-weight: 850; letter-spacing: 8px; font-size: 26px; }
.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 14px 0; }
.toolbar-group { display: flex; gap: 6px; }
footer { color: #a19caa; font-size: 11px; }
.controls { display: flex; flex-wrap: wrap; gap: 10px 22px; margin: 4px 0 16px; }
.controls span { white-space: nowrap; }
kbd { font: 10px system-ui; border: 1px solid #423d49; border-bottom-width: 2px; background: #201e29; border-radius: 3px; padding: 1px 4px; color: #dbd6e4; margin-right: 2px; }
#status { min-height: 16px; color: #c3bccb; }
.credit { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 5px 16px; color: #76707f; font-size: 9px; letter-spacing: .6px; border-top: 1px solid #282530; padding-top: 13px; margin-top: 15px; }
a { color: inherit; text-decoration-color: #4c4756; text-underline-offset: 3px; }
#touch-controls { display: none; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0 14px; user-select: none; touch-action: none; }
.dpad { display: grid; grid-template-columns: repeat(3, 38px); grid-template-rows: repeat(3, 38px); gap: 2px; }
.dpad button { padding: 0; font-size: 18px; }
.dpad button[data-input*=','] { font-size: 15px; color: #97909f; background: #181923; }
.action-buttons { display: flex; gap: 8px; align-items: center; }
.action-buttons button { width: 48px; height: 48px; border-radius: 50%; border-color: #6d3b40; background: #3d242e; font-size: 17px; }
.action-buttons button:nth-child(2) { margin-top: 30px; }
.touch-start { font-size: 9px; padding: 8px; }
.pressed { background: var(--red) !important; color: white !important; }
.ejs_menu_bar, .ejs_virtualGamepad, .ejs_virtualGamepad_open { display: none !important; }
#arcade:fullscreen { background: #000; width: 100%; height: 100%; padding: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
#arcade:fullscreen > :not(#screen) { display: none !important; }
#arcade:fullscreen #screen { width: min(100vw, calc(100dvh * 4 / 3)); flex: 0 0 auto; border: 0; border-radius: 0; }
@media (pointer: coarse), (max-width: 650px) {
  #arcade { width: 100%; padding: 16px 12px; }
  .masthead { margin-bottom: 12px; }
  .wordmark { gap: 8px; }
  .wordmark > span { font-size: 27px; }
  h1 { font-size: 20px; letter-spacing: 2px; }
  .wordmark p { font-size: 6px; letter-spacing: 1px; }
  .edition { font-size: 8px; letter-spacing: 1px; }
  .edition span { font-size: 7px; }
  .toolbar { justify-content: center; gap: 6px; padding: 10px 0; }
  .toolbar button { font-size: 10px; padding: 9px 10px; }
  #touch-controls { display: flex; }
  .intro-content { padding: 15px; }
  .eyebrow { margin: 0; letter-spacing: 3px; font-size: 8px; }
  h2 { margin: 12px 0; font-size: 25px; }
  .intro-subtitle { font-size: 11px; margin-bottom: 14px; }
  .primary { font-size: 12px; padding: 11px 18px; }
  .start-hint { font-size: 9px; margin-top: 11px; }
  .controls { gap: 9px 14px; font-size: 10px; }
}
@media (max-width: 350px) { .dpad { grid-template-columns: repeat(3, 32px); grid-template-rows: repeat(3, 32px); } .action-buttons { gap: 4px; } .action-buttons button { width: 40px; height: 40px; } .edition { display: none; } }
@media (max-height: 500px) and (orientation: landscape) {
  #arcade { width: 100%; padding-top: 8px; }
  .masthead { display: none; }
  #screen { width: min(100%, calc((100dvh - 75px) * 4 / 3)); margin: auto; }
  .controls, .credit { display: none; }
  #touch-controls { position: fixed; bottom: 8px; left: 8px; right: 8px; pointer-events: none; z-index: 5; padding: 0; }
  #touch-controls button { pointer-events: auto; opacity: .85; }
}

#hd-canvas { position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; pointer-events: none; image-rendering: auto; }
#hd-canvas[hidden] { display: none; }
#screen.hide-boot-logo #game, #screen.hide-boot-logo #hd-canvas { visibility: hidden; }
#intro, #pause-overlay { z-index: 3; }
#loading-overlay { position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; padding: clamp(10px, 3vw, 28px); background: linear-gradient(145deg, #222937f5, #0b111afc); overflow: auto; }
.loading-content { width: min(440px, 100%); }
.loading-content .eyebrow { margin: 0 0 10px; color: #d5b786; }
#loading-title { margin: 0 0 14px; font-size: clamp(18px, 3vw, 28px); letter-spacing: .3px; }
#loading-phase { font-size: 13px; line-height: 1.4; min-height: 2.8em; margin: 0 0 8px; color: #e3dce9; }
.loading-meter { display: flex; align-items: center; gap: 12px; }
#loading-progress { display: block; width: 100%; height: 9px; border: 0; border-radius: 9px; overflow: hidden; background: #3a3b47; accent-color: #efbc6e; }
#loading-progress::-webkit-progress-bar { background: #3a3b47; border-radius: 9px; }
#loading-progress::-webkit-progress-value { background: #efbc6e; border-radius: 9px; }
#loading-progress:indeterminate { background: linear-gradient(90deg, #3a3b47 20%, #efbc6e 50%, #3a3b47 80%); background-size: 200% 100%; animation: loading-pulse 1.8s linear infinite; }
#loading-progress:indeterminate::-webkit-progress-bar { background: transparent; }
#loading-value { white-space: nowrap; min-width: 58px; text-align: right; font-size: 12px; font-variant-numeric: tabular-nums; color: #f4d59f; }
#loading-steps { list-style: none; padding: 0; margin: 15px 0 12px; }
#loading-steps li { display: flex; gap: 10px; align-items: baseline; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid #ffffff12; font-size: 12px; }
#loading-steps li::before { content: '○'; color: #898394; width: 12px; flex-shrink: 0; }
#loading-steps li[data-state='loading']::before { content: '◉'; color: #efbc6e; }
#loading-steps li[data-state='done']::before { content: '✓'; color: #9cddb9; }
#loading-steps li[data-state='warning']::before { content: '!'; color: #efbc6e; }
#loading-steps li > span { flex: 1; }
#loading-steps small { max-width: 68%; color: #b6b0c2; text-align: right; font-size: 11px; font-variant-numeric: tabular-nums; }
#loading-note { font-size: 10px; line-height: 1.4; color: #938c9f; margin: 0; }
#loading-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
#loading-actions .primary { font-size: 12px; padding: 10px; }
@keyframes loading-pulse { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { #loading-progress:indeterminate { animation: none; } }
@media (max-width: 650px), (max-height: 500px) and (orientation: landscape) {
 #loading-overlay { padding: 10px 16px; }
 .loading-content .eyebrow { margin-bottom: 5px; font-size: 8px; }
 #loading-title { margin-bottom: 5px; font-size: 17px; }
 #loading-phase { font-size: 11px; min-height: 2.4em; margin-bottom: 4px; }
 #loading-steps { margin: 8px 0; }
 #loading-steps li { padding: 4px 0; font-size: 10px; }
 #loading-steps small { font-size: 9px; }
 #loading-note { font-size: 8px; }
 #loading-value { font-size: 10px; }
}
@media (max-width: 350px) {
 #loading-steps li { padding: 2px 0; }
 #loading-phase { min-height: 2em; }
 #loading-steps { margin: 6px 0; }
}
.intro-level-button { margin-left: 8px; padding: 14px 18px; font-size: 13px; background: #121622df; border-color: #71707b; }
#level-select-overlay { position: absolute; inset: 0; z-index: 5; padding: clamp(12px, 2.5vw, 24px); display: flex; flex-direction: column; gap: 10px; background: linear-gradient(155deg, #232734, #0b111a 65%); overflow: auto; }
.level-select-heading { display: flex; align-items: center; gap: 14px; flex: 0 0 auto; }
.level-select-heading > span { color: #f0635b; font: 800 30px 'Hiragino Mincho ProN', serif; }
.level-select-heading .eyebrow { color: #d5b786; font-size: 8px; letter-spacing: 3px; margin: 0 0 3px; }
.level-select-heading h2 { font-size: 23px; margin: 0; letter-spacing: .4px; }
.level-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(48px, 1fr)); gap: 8px; flex: 1 1 auto; min-height: 104px; }
.level-card { position: relative; overflow: hidden; padding: 0; min-height: 48px; border-radius: 4px; border: 1px solid #555365; background: #172333; }
.level-card img { width: 100%; height: 100%; position: absolute; inset: 0; object-fit: cover; opacity: .72; transition: opacity .12s; }
.level-card::after { content: ''; position: absolute; inset: 0; background: linear-gradient(0deg, #080e18eb, #080e1800 85%); }
.level-card > span { position: absolute; bottom: 7px; left: 9px; z-index: 1; display: flex; align-items: baseline; gap: 6px; font-size: 8px; letter-spacing: 1px; color: #e5dac3; }
.level-card strong { font-size: 25px; letter-spacing: 0; }
.level-card[aria-pressed='true'] { border: 2px solid #efbc6e; box-shadow: 0 0 0 1px #f4b46042, inset 0 0 20px #fff2; }
.level-card[aria-pressed='true'] img, .level-card:hover img { opacity: 1; }
.level-card[aria-pressed='true'] > span { color: #fff2d0; }
#level-select-status { flex: 0 0 auto; margin: 0; font-size: 11px; color: #c2bdce; min-height: 15px; }
.level-select-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex: 0 0 auto; }
.level-select-actions .primary { font-size: 13px; padding: 11px 16px; }
.level-select-keys { margin: 0; font-size: 9px; color: #8f8a9e; }
@media (max-width: 650px) {
 .intro-level-button { padding: 11px 12px; font-size: 11px; }
 #level-select-overlay { padding: 12px; gap: 7px; }
 .level-select-heading { gap: 9px; }
 .level-select-heading > span { font-size: 24px; }
 .level-select-heading h2 { font-size: 18px; }
 .level-grid { gap: 6px; }
 .level-card > span { left: 6px; bottom: 4px; gap: 4px; font-size: 6px; }
 .level-card strong { font-size: 20px; }
 #level-select-status { font-size: 9px; min-height: 12px; }
 .level-select-actions button { font-size: 10px; padding: 9px 12px; }
 .level-select-keys { display: none; }
}
@media (max-width: 350px) {
 #level-select-overlay { padding: 8px; gap: 5px; }
 .level-select-heading > span { font-size: 20px; }
 .level-select-heading h2 { font-size: 16px; }
 .level-select-heading .eyebrow { display: none; }
 .level-grid { min-height: 92px; grid-template-rows: repeat(2, minmax(44px, 1fr)); gap: 4px; }
 .level-card { min-height: 44px; }
 .level-select-actions .primary { font-size: 11px; padding: 8px 10px; }
}

#asset-loading { margin: 10px 0; border: 1px solid #ffffff14; border-radius: 5px; padding: 8px 10px; color: #b9b5c1; font-size: 11px; }
#asset-loading summary { cursor: pointer; line-height: 1.5; }
#asset-progress { width: 80px; height: 5px; margin-left: 8px; accent-color: #efbc6e; }
#asset-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 16px; margin-top: 10px; }
#asset-groups > div { display: flex; justify-content: space-between; gap: 8px; font-variant-numeric: tabular-nums; }
#asset-groups [data-state="failed"] { color: #efbc6e; }
#asset-loading p { color: #928d9c; font-size: 10px; line-height: 1.4; }
#asset-retry-btn { font-size: 11px; }
#loading-overlay { background-color: #0b111a; background-size: cover; background-position: center; }
.loading-content { padding: 16px; border-radius: 6px; background: #101623ed; }
@media (max-width: 390px) { #asset-groups { grid-template-columns: 1fr; } #asset-progress { width: 48px; } }

#boot-title, .loading-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.intro-content, .loading-content { position: relative; z-index: 1; }
.loading-art { opacity: .35; }

.loading-content { max-height: 100%; overflow: auto; }
@media (max-width: 480px) { .loading-content { padding: 8px; } #loading-actions button { padding: 8px; font-size: 10px; } }

.loading-meter { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
#loading-progress { min-width: 0; }
#loading-value { min-width: 0; }
