.front-screen main { max-width: 600px; padding: 0; }
.front-screen header { display: none; }
#opening[hidden],#home[hidden],#selection[hidden],#chapters[hidden] { display: none !important; }
.front-screen button:focus-visible { outline: 3px solid #F1E3C4; outline-offset: 2px; }
#opening { position: relative; height: 100dvh; min-height: 580px; overflow: hidden; background: #49362C; }
.opening-bg { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.opening-logo { position: absolute; width: calc(100% - 28px); height: auto; top: 12%; left: 14px; }
#opening-start { position: absolute; inset: 0; width: 100%; border: 0; background: transparent; box-shadow: none; display: flex; align-items: end; justify-content: center; padding-bottom: max(12dvh,env(safe-area-inset-bottom)); }
#opening-start span { color: #F1E3C4; font-size: clamp(24px,7vw,34px); font-family: 'Kerbaon Serif',serif; text-shadow: 0 2px 3px #211B18,0 0 6px #211B18; animation: opening-prompt 2.4s ease-in-out infinite; }
#opening-start:disabled span { animation: none; }
@keyframes opening-prompt { 50% { opacity: .6; } }
@media(prefers-reduced-motion:reduce) { #opening-start span { animation: none; } }
body.reduce-motion #opening-start span { animation: none; }
#home { padding: max(20px,env(safe-area-inset-top)) 16px 18px; min-height: 100dvh; gap: 14px; align-content: center; }
#home > .story-map-cover { display: none; }
#home h2 { text-align: center; font-size: 1.875rem; color: #D0AD64; margin: 0 0 4px; }
#home .mode-card { width: 100%; height: clamp(154px,21dvh,190px); padding: 0; position: relative; overflow: hidden; border: 1px solid #A88A4B; background: #211B18; box-shadow: none; text-align: left; display: flex; flex-direction: column; justify-content: end; }
.mode-card img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.mode-card::after { content: ''; position: absolute; inset: 0; background: linear-gradient(transparent 5%,#211B18D9 55%,#211B18 100%); }
.mode-card strong,.mode-card small { position: relative; z-index: 1; padding-inline: 14px; text-shadow: 0 1px 2px #211B18; }
.mode-card strong { font-size: 1.625rem; color: #F1E3C4; }
.mode-card small { padding-bottom: 12px; font-size: 1rem; color: #F1E3C4; }
#multi-open img { filter: saturate(.4) brightness(.65); }
.mode-lock { position: absolute; top: 12px; right: 14px; z-index: 2; width: 30px; height: 30px; color: #F1E3C4; }
#multi-status { margin: 0; text-align: center; color: #F1E3C4; }
#multi-status:empty { display: none; }
#opening-back,.home-back,.text-link { min-height: 44px; }
#chapters { padding: 12px 8px; border: 0; background: none; box-shadow: none; }
#chapters #chapters-title { text-align: center; color: #D0AD64; font-size: 1.5625rem; }
#story-phases { gap: 8px; }
#chapters #story-phases button { background: none; border: 0; border-bottom: 2px solid transparent; min-height: 64px; font-size: 1rem; line-height: 1.4; box-shadow: none; }
#story-phases button[aria-selected=true] { color: #D0AD64; border-color: #D0AD64; }
#phase-locked,.map-hint { font-size: 1rem; margin: 8px 0; }
#story-map-viewport { height: clamp(310px,45dvh,470px); overflow: hidden; position: relative; border-block: 1px solid #A88A4B; touch-action: none; overscroll-behavior: none; scrollbar-width: none; }
#story-map-viewport::-webkit-scrollbar { display: none; }
#story-map-layer { position: relative; overflow: hidden; background: #49362C; }
#story-map-art { position: absolute; max-width: none; }
#story-map-paths { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#story-map-paths path { fill: none; stroke-width: 4; stroke: #D0AD64; stroke-dasharray: 9 8; filter: drop-shadow(0 1px 1px #211B18); }
#story-map-paths path.locked { stroke: #78766B; }
#story-map-paths path.viewpoint-transition { stroke: #F1E3C4; stroke-width: 2; stroke-dasharray: 2 15; }
#story-map-layer #chapter-list { display: block; margin: 0; padding: 0; }
#chapter-list li { list-style: none; }
#story-map-layer #chapter-list button { position: absolute; transform: translate(-50%,-50%); width: 44px; height: 44px; min-height: 44px; padding: 0; border: 0; background: transparent; box-shadow: none; color: #D0AD64; text-align: center; overflow: visible; }
#story-map-layer #chapter-list button:disabled { color: #F1E3C4; opacity: 1; }
.chapter-symbol { display: grid; place-items: center; width: 36px; height: 36px; margin: 4px; border: 2px solid currentColor; border-radius: 50%; background: #211B18; box-shadow: 0 1px 5px #211B18; font-size: 1.5625rem; }
.chapter-symbol svg { width: 20px; height: 20px; }
[data-status=current] .chapter-symbol { border-radius: 2px 2px 12px 2px; background: #49362C; }
[data-chapter][aria-pressed=true] .chapter-symbol { outline: 2px solid #F1E3C4; outline-offset: 3px; }
.chapter-number { position: absolute; top: -8px; left: -10px; font-size: 1.125rem; font-weight: 800; color: #F1E3C4; text-shadow: -1px -1px 1px #211B18,1px 1px 2px #211B18,0 0 4px #211B18; }
#chapter-panel { display: grid; grid-template-columns: 88px 1fr; gap: 12px; margin: 12px 0; padding: 12px 0; }
#chapter-preview { width: 88px; height: 130px; object-fit: cover; align-self: start; }
#chapter-panel h3 { font-size: 1.3125rem; margin: 0; }
#chapter-panel p { font-size: 1rem; margin-block: 8px; line-height: 1.5; }
#chapter-start { width: 100%; min-height: 48px; font-size: 1.1875rem; }
#selection { padding: 0 14px 16px; border: 0; box-shadow: none; background: none; }
.practice-heading { position: relative; height: 160px; margin-inline: -14px; overflow: hidden; display: grid; align-items: end; }
.practice-heading img { position: absolute; width: 100%; height: 100%; object-fit: cover; }
.practice-heading::after { content: ''; position: absolute; inset: 0; background: linear-gradient(transparent,#211B18); }
.practice-heading h2 { position: relative; z-index: 1; text-align: center; font-size: 2.125rem; color: #D0AD64; margin-bottom: 8px; }
#nation-selection { padding: 0; border: 0; background: none; box-shadow: none; }
#nation-title,#selection h3 { font-size: 1.25rem; margin: 12px 0; color: #D0AD64; }
#selection .nation-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#selection .nation-choice { position: relative; display: flex; flex-direction: column; align-items: center; padding: 6px; background: transparent; border: 1px solid transparent; }
#selection .nation-choice::before { content: ''; position: absolute; top: 6px; width: 90px; height: 94px; background: #254A60; clip-path: polygon(0 0,100% 0,100% 100%,50% 89%,0 100%); }
#selection .nation-choice[data-nation=sabelu]::before { background: #8A392F; }
#selection .nation-choice[aria-pressed=true]::after { content: '✓'; position: absolute; top: 6px; right: 10px; color: #D0AD64; }
#selection .nation-choice[aria-pressed=true] { border-color: #D0AD64; }
#selection .nation-portrait { position: relative; width: 74px; height: 94px; object-fit: contain; border: 0; filter: brightness(0) invert(.87); }
#selection .nation-copy strong { font-size: 1.0625rem; }
#selection .nation-copy > :not(strong) { display: none; }
#chosen-nation { display: none; }
#nation-change { display: none; }
#deck-open { width: 100%; min-height: 44px; background: none; border: 0; text-decoration: underline; text-underline-offset: 5px; }
.practice-deck h3 { margin-top: 2px !important; }
#practice-deck-summary { margin: 4px 0; }
#difficulty-choices { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
#difficulty-choices button { display: flex; align-items: center; flex-direction: column; background: none; border: 0; border-bottom: 2px solid transparent; padding: 4px; min-height: 110px; font-size: 1.125rem; }
#difficulty-choices button[aria-pressed=true] { border-color: #D0AD64; color: #D0AD64; }
#difficulty-choices img { width: 66px; height: 66px; object-fit: contain; }
#difficulty-choices small { font-size: 0.875rem; }
#selection #start { margin-top: 16px; width: 100%; font-size: 1.5rem; min-height: 56px; }
@media(min-width:600px) { #home .mode-card { height: 180px; } }

#chapters,#selection { position: fixed; inset: 0; width: 100%; height: 100dvh; max-height: none; margin: 0; overflow: hidden; border: 0; border-image: none; padding: 0; background: #49362C; }
.story-topbar,.practice-topbar { position: absolute; z-index: 6; top: 0; left: 0; right: 0; height: calc(44px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); display: grid; grid-template-columns: 48px minmax(82px,1fr) auto; align-items: center; gap: 2px; background: url('./assets/ui/hud3/topbar.webp') center / 100% 100% no-repeat; }
.story-topbar .story-back,.practice-topbar .home-back { width: 44px; height: 44px; min-height: 44px; overflow: hidden; font-size: 0; border: 0; border-image: none; background: none; background-color: transparent; box-shadow: none; }
.story-topbar .story-back::after,.practice-topbar .home-back::after { content: '‹'; display: block; color: #F1E3C4; font-size: 38px; line-height: 32px; text-shadow: 0 1px 2px #211B18; }
#chapters #chapters-title,.practice-topbar h2 { min-width: 0; margin: 0; font-size: 20px; line-height: 28px; color: #F1E3C4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; }
#story-phases { display: flex; gap: 4px; margin: 0 6px 0 0; height: 44px; align-items: center; }
#chapters #story-phases button { width: 83px; height: 38px; min-height: 38px; padding: 0 4px 2px; border: 0; border-image: none; background: url('./assets/front/select/tab-flag.webp') center / 100% 100% no-repeat; background-color: transparent; box-shadow: none; color: #F1E3C4; font-size: 13px; white-space: nowrap; }
#chapters #story-phases button[aria-selected=true] { color: #211B18; background-image: url('./assets/front/select/tab-flag-active.webp'); }
#chapters #story-phases button[data-locked=true] { filter: saturate(.45); }
#chapters #story-phases button[data-locked=true] { position: relative; padding-left: 17px; }
#chapters #story-phases button[data-locked=true]::before { content: ''; position: absolute; left: 3px; top: 10px; width: 14px; height: 18px; background: url('./assets/front/select/pin-locked.webp') center / contain no-repeat; }
#story-complete,.map-hint { display: none !important; }
#phase-locked:not([hidden]) { position: absolute; top: calc(52px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 8; width: max-content; max-width: calc(100vw - 28px); height: 42px; margin: 0; padding: 10px 18px; color: #211B18; font-size: 14px; text-align: center; background: url('./assets/front/select/tab-flag-active.webp') center / 100% 100% no-repeat; pointer-events: none; }
#story-map-viewport { position: absolute; top: calc(44px + env(safe-area-inset-top)); bottom: 0; left: 0; width: 100%; height: auto; border: 0; background: #49362C; }
#story-map-layer #chapter-list button { width: 60px; height: 75px; min-width: 60px; min-height: 75px; padding: 0; border: 0; border-image: none; background: none; background-color: transparent; box-shadow: none; color: #F1E3C4; transform: translate(-16px,-72px); overflow: visible; }
#story-map-layer #chapter-list button[data-status=cleared],#story-map-layer #chapter-list button[data-status=locked] { width: 58px; height: 72px; min-width: 58px; min-height: 72px; transform: translate(-29px,-64px); }
.chapter-symbol { display: block; width: 100%; height: 100%; margin: 0; border: 0; border-radius: 0; background: url('./assets/front/select/pin-current.webp') center / contain no-repeat; box-shadow: none; }
#story-map-layer [data-status=current] .chapter-symbol { border-radius: 0; background: url('./assets/front/select/pin-current.webp') center / contain no-repeat; }
[data-status=cleared] .chapter-symbol { background-image: url('./assets/front/select/pin-done.webp'); }
[data-status=locked] .chapter-symbol { background-image: url('./assets/front/select/pin-locked.webp'); }
#chapter-list [data-status=locked]::before { content: ''; position: absolute; left: 50%; top: 55%; width: 122px; height: 122px; transform: translate(-50%,-50%); background: url('./assets/front/select/fog-overlay.webp') center / contain no-repeat; opacity: .55; pointer-events: none; }
[data-chapter][aria-pressed=true] .chapter-symbol { outline: 0; filter: drop-shadow(0 0 5px #F1E3C4); }
.chapter-number { top: 11px; left: auto; right: -9px; font-size: 17px; line-height: 23px; color: #F1E3C4; }
[data-status=current] .chapter-number { top: 19px; left: 16px; right: auto; font-size: 17px; color: #F1E3C4; }
.chapter-caption:not([hidden]) { position: absolute; top: calc(100% + 4px); left: 50%; transform: translateX(-50%); display: block; width: 140px; max-width: 140px; color: #F1E3C4; font-size: 13px; line-height: 18px; text-align: center; text-shadow: 0 1px 2px #211B18,0 0 4px #211B18; pointer-events: none; }
#story-map-paths image.locked { opacity: .45; }
#phase2-seal:not([hidden]) { position: absolute; z-index: 2; width: 160px; height: 90px; transform: translate(-50%,-60%); display: grid; justify-items: center; align-content: center; gap: 1px; pointer-events: none; color: #F1E3C4; font-size: 14px; line-height: 20px; text-align: center; text-shadow: 0 2px 3px #211B18,0 0 5px #211B18; }
#phase2-seal::before { content: ''; position: absolute; z-index: -1; width: 320px; height: 190px; left: 50%; top: 50%; transform: translate(-50%,-50%); background: url('./assets/front/select/fog-overlay.webp') center / contain no-repeat; opacity: .82; }
.seal-lock { width: 34px; height: 42px; background: url('./assets/front/select/pin-locked.webp') center / contain no-repeat; }
#chapter-panel:not([hidden]) { position: absolute; z-index: 7; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; gap: 2px; min-height: 276px; max-height: min(55dvh,440px); overflow-y: auto; margin: 0; padding: 26px 24px calc(16px + env(safe-area-inset-bottom)); border: 52px 16px 19px 52px solid transparent; border-image: url('./assets/front/select/sheet-panel.webp') 156 48 56 156 fill / 52px 16px 19px 52px; background: none; color: #211B18; animation: chapter-sheet-in .24s ease-out; }
@keyframes chapter-sheet-in { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-handle { align-self: center; display: block; width: 38px; height: 4px; margin: -15px 0 5px; background: #75634c; border-radius: 3px; }
#chapter-close { position: absolute; top: 2px; right: 4px; width: 44px; height: 44px; min-height: 44px; padding: 0; border: 0; border-image: none; background: url('./assets/ui/btn-iron.webp') center / contain no-repeat; background-color: transparent; color: #F1E3C4; font-size: 30px; line-height: 44px; }
#chapter-number { margin: 0; text-align: center; font-size: 13px; line-height: 19px; }
#chapter-panel #chapter-name { margin: 0; text-align: center; font-size: 24px; line-height: 31px; color: #211B18; }
.chapter-profile { display: grid; grid-template-columns: 76px minmax(0,1fr); gap: 12px; align-items: center; min-height: 76px; }
.chapter-portrait { position: relative; width: 76px; height: 76px; background: url('./assets/front/select/portrait-ring.webp') center / contain no-repeat; }
.chapter-portrait::after { content: ''; position: absolute; inset: 0; background: url('./assets/front/select/portrait-ring.webp') center / contain no-repeat; pointer-events: none; }
#chapter-preview { display: block; width: 63px; height: 63px; margin: 6px auto; border-radius: 50%; object-fit: cover; object-position: center top; }
#chapter-panel p { margin: 0; color: #211B18; }
#chapter-enemy { font-size: 16px; font-weight: 700; line-height: 23px; }
#chapter-intro { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font-size: 14px; line-height: 20px; }
#chapter-start { width: 100%; min-height: 48px; margin-top: 5px; padding: 0; border: 0; border-image: none; background: url('./assets/front/select/btn-march.webp') center / 100% 100% no-repeat; background-color: transparent; color: #211B18; font-size: 20px; }
#chapter-start:active { background-image: url('./assets/front/select/btn-march-pressed.webp'); }
#chapter-start::before { display: none; }

#selection { isolation: isolate; }
.practice-heading { position: absolute; z-index: 0; inset: 0; width: 100%; height: 100%; margin: 0; display: block; }
.practice-heading img { width: 100%; height: 100%; object-fit: cover; }
.practice-heading::after { display: none; }
.practice-topbar { z-index: 5; }
#selection #nation-selection { position: absolute; top: calc(72px + env(safe-area-inset-top)); left: 0; right: 0; padding: 0 16px; background: none; border: 0; border-image: none; }
#selection #nation-title { width: 156px; height: 38px; line-height: 38px; margin: 0 auto 8px; text-align: center; color: #211B18; font-size: 16px; text-shadow: 0 1px 0 #F1E3C4; background: url('./assets/front/select/tab-flag-active.webp') center / 100% 100% no-repeat; }
#selection .nation-choices { gap: 8px; }
#selection .nation-choice { height: 108px; padding: 8px 4px; border: 0; border-image: none; background: url('./assets/front/select/tab-flag.webp') center / 100% 100% no-repeat; }
#selection .nation-choice[aria-pressed=true] { border: 0; background-image: url('./assets/front/select/tab-flag-active.webp'); }
#selection .nation-choice::before,#selection .nation-choice::after { display: none; }
#selection .nation-portrait { width: 48px; height: 48px; filter: brightness(0) invert(.87); }
#selection .nation-copy strong { display: block; max-width: 148px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: #F1E3C4; text-shadow: 0 1px 2px #211B18; }
#selection .nation-choice[aria-pressed=true] .nation-copy strong { color: #211B18; text-shadow: none; }
.practice-sheet { position: absolute; z-index: 3; left: 0; right: 0; bottom: 0; max-height: min(63dvh,480px); min-height: 300px; overflow-y: auto; padding: 15px 28px calc(16px + env(safe-area-inset-bottom)); border: 52px 16px 19px 52px solid transparent; border-image: url('./assets/front/select/sheet-panel.webp') 156 48 56 156 fill / 52px 16px 19px 52px; color: #211B18; }
#selection .practice-sheet h3,#selection .practice-sheet p { color: #211B18; }
.practice-sheet #deck-open { color: #211B18; text-align: left; }
#selection .practice-sheet #difficulty-choices { gap: 4px; }
#selection .practice-sheet #difficulty-choices button { color: #211B18; }
#selection .practice-sheet #difficulty-choices button[aria-pressed=true] { border-color: #8A392F; }
#selection .practice-sheet #start { margin-top: 10px; border: 0; border-image: none; min-height: 48px; background: url('./assets/front/select/btn-march.webp') center / 100% 100% no-repeat; background-color: transparent; color: #211B18; font-size: 20px; }
#selection .practice-sheet #start:active { background-image: url('./assets/front/select/btn-march-pressed.webp'); }
#selection .practice-sheet #start::before { display: none; }
@media (max-height:700px) { #chapter-panel:not([hidden]) { max-height: 58dvh; } .practice-sheet { max-height: 53dvh; min-height: 0; } #selection #nation-selection { top: calc(52px + env(safe-area-inset-top)); } #selection .nation-choice { height: 88px; } }
@media (prefers-reduced-motion:reduce) { #chapter-panel:not([hidden]) { animation: none; } }
body.reduce-motion #chapter-panel:not([hidden]) { animation: none; }
