/* Copyright (c) 2026 Authentically Belize Movement (@authenticallybelize). All rights reserved. See LICENSE. */
:root { color-scheme: dark; font-family: "Courier New", monospace; color: #f7f0d8; background: #05090d; }
* { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; display: grid; place-items: safe center; background: radial-gradient(ellipse at top, #203b2a, #05090d 70%); padding: 16px; }
#wrap { position: relative; width: min(100%, 820px); padding: 12px; border: 3px solid #030407; outline: 2px solid #b98639; background: linear-gradient(#16231c, #0c1417); box-shadow: 0 14px 40px #0008; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#wrap input { -webkit-user-select: text; user-select: text; }
#gameHeader { display: grid; grid-template-columns: 100px minmax(0, 1fr) 80px; gap: 6px; margin-bottom: 12px; }
#gameHeader #title { margin: 0; }
#menuBtn { display: none; }
#title { margin: 0 0 12px; padding: 9px; font-size: clamp(15px, 3vw, 23px); text-align: center; color: #ffe07a; letter-spacing: 1px; border: 2px solid #d9a441; background: #070d0d; text-shadow: 2px 2px #5a291b; }
button { font: bold 12px "Courier New", monospace; color: #ffe07a; padding: 8px 5px; min-height: 42px; border: 2px solid #b98639; background: linear-gradient(#253127, #0d1314); cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
button:hover { color: #fff3b2; background: #334637; }
button:focus-visible { outline: 3px solid #9fe6a0; outline-offset: 2px; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: default; }
#topbar { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 5px; margin-bottom: 12px; }
#pwaStatus { grid-column: 1 / -1; font-size: 11px; line-height: 1.4; color: #bfe2bc; }
#stage { position: relative; aspect-ratio: 4/3; border: 3px solid #020305; outline: 2px solid #d9a441; background: #030608; }
canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; touch-action: manipulation; }
#startOverlay { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 8px; padding: 2.5% 12px; text-align: center; overflow: auto; background: url('assets/start-landscape-v1.png') center / cover; }
#startOverlay h2 { color: #ffd65a; font-size: clamp(18px, 3.4vw, 28px); letter-spacing: 2px; margin: 0 0 8px; text-shadow: 2px 2px #783317; }
.story { max-width: 570px; font-size: clamp(10px, 1.6vw, 14px); line-height: 1.5; }
.story p { margin: 10px 0; }
.credits { color: #d6c66d; font-size: .85em; }
.era { color: #9fe6a0; font-weight: bold; }
.lobStartMenu { display: flex; gap: 7px; }
.lobStartMenu button { padding: 8px 16px; }
.startHint { margin: 3px 0 0; font-size: 10px; color: #c9b98a; }
.hidden { display: none !important; }
.srOnly { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.startTagline { margin: 0; color: #fff6d2; font-size: clamp(9px, 1.6vw, 15px); background: #06241ce0; padding: 6px 10px; border-radius: 3px; }
.lobStartMenu { width: 34%; min-width: 140px; flex-direction: column; gap: 7px; }
.lobStartMenu button { min-height: 39px; border-color: #d3ad62; box-shadow: 0 2px 0 #030e0b; background: #0d342ceb; letter-spacing: 1px; }
.lobStartMenu button:not(:first-child) { background: #3d2919ed; }
.startCredits { margin: 6px 0 0; font-size: clamp(7px, 1.2vw, 11px); line-height: 1.35; color: #fff0c1; text-shadow: 1px 1px 2px #000; }
#interactionMenu { margin-top: 14px; border: 2px solid #c7a261; padding: 12px; background: #0b201c; font-size: 14px; line-height: 1.45; }
#interactionMenu h2 { font-size: 18px; color: #ffe1a0; margin: 0 0 5px; }
#interactionMenu p { margin: 6px 0 10px; }
.shopTabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin: 10px 0; }
.itemList { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 6px; margin: 8px 0; max-height: 300px; overflow-y: auto; touch-action: pan-y pinch-zoom; }
.itemList button { text-align: left; padding: 9px; color: #f2eedc; font-weight: normal; min-height: 52px; }
.itemList button span { display: block; color: #c9d5c5; font-size: 11px; margin-top: 3px; }
.shopTabs .selected, .itemList .selected { outline: 2px solid #aad8aa; outline-offset: -2px; background: #2a4b35; }
.itemEffect { border-left: 3px solid #bba46e; padding: 8px 10px; background: #07130f; color: #eee9d3; }
.shopConfirm { width: 100%; min-height: 46px; font-size: 14px; background: #275039; }
#log { margin: 12px 0; padding: 10px; min-height: 54px; border: 2px solid #b98639; background: #05090a; font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
#objective { margin-top: 10px; padding: 8px 10px; border: 1px solid #b98639; background: #05090a; color: #f7f0d8; font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
#controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
#dpad { display: none; position: relative; grid-template-columns: repeat(3, var(--pad-size)); grid-template-rows: repeat(3, var(--pad-size)); justify-content: center; align-self: center; justify-self: center; }
#upBtn { grid-column: 2; grid-row: 1; }
#leftBtn { grid-column: 1; grid-row: 2; }
#downBtn { grid-column: 2; grid-row: 3; }
#rightBtn { grid-column: 3; grid-row: 2; }
#dpadCenter { grid-column: 2; grid-row: 2; z-index: 2; place-self: center; width: 80%; height: 80%; border-radius: 50%; background: #10211b; border: 3px solid #07100e; box-shadow: inset 0 2px 3px #fff2, 0 2px 3px #0009; pointer-events: none; }
#dpad::before, #dpad::after { content: ""; position: absolute; inset: 0; clip-path: polygon(33.333% 0, 66.667% 0, 66.667% 33.333%, 100% 33.333%, 100% 66.667%, 66.667% 66.667%, 66.667% 100%, 33.333% 100%, 33.333% 66.667%, 0 66.667%, 0 33.333%, 33.333% 33.333%); background: #d9b665; pointer-events: none; }
#dpad::after { inset: 4px; background: linear-gradient(#314337, #12251e); }
#dpad button { z-index: 1; min-height: 0; width: var(--pad-size); height: var(--pad-size); border: 0; padding: 0; background: transparent; font-size: 24px; touch-action: none; }
#dpad button:active { background: #fff2; transform: none; }
#mobileHint { font-size: 11px; line-height: 1.5; color: #c9b98a; text-align: center; margin: 10px 0 0; }

/* Mobile uses the same actions in a handheld layout; menus overlay only the map. */
body.mobile { --pad-size: clamp(44px, 5.3vw, 64px); --action-size: clamp(62px, 8vw, 90px); padding: max(5px, env(safe-area-inset-top)) max(5px, env(safe-area-inset-right)) max(5px, env(safe-area-inset-bottom)) max(5px, env(safe-area-inset-left)); }
body.mobile #wrap { width: min(100%, 980px); padding: 8px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-areas: "header header" "stage stage" "objective objective" "log log" "pad controls"; gap: 8px; background: linear-gradient(#102b20, #081a14); }
body.mobile #gameHeader { grid-area: header; grid-template-columns: 44px minmax(0, 1fr) 56px 44px; margin: 0; align-items: stretch; }
body.mobile #title { font-size: clamp(11px, 2vw, 20px); padding: 8px 0; border: 0; background: transparent; align-self: center; }
body.mobile #gameHeader button { min-height: 44px; border-radius: 6px; font-size: 11px; }
body.mobile #gameHeader #musicBtn { font-size: 0; }
body.mobile #musicBtn::before { content: "♫"; font-size: 25px; }
body.mobile #gameHeader #menuBtn { display: block; font-size: 25px; padding: 0; }
body.mobile #topbar { display: none; }
body.mobile #wrap.menu-open #topbar { display: grid; position: absolute; z-index: 30; top: 58px; right: 8px; width: min(320px, calc(100% - 16px)); grid-template-columns: 1fr; gap: 6px; margin: 0; padding: 10px; border: 2px solid #d9b665; background: #10251e; box-shadow: 0 8px 24px #000b; max-height: calc(100dvh - 80px); overflow-y: auto; }
body.mobile #topbar button { min-height: 44px; }
body.mobile #stage { grid-area: stage; width: 100%; min-width: 0; justify-self: center; align-self: center; }
body.mobile #objective { grid-area: objective; }
body.mobile #log { grid-area: log; }
body.mobile #objective, body.mobile #log { margin: 0; padding: 6px 10px; min-height: 32px; max-height: 64px; overflow-y: auto; font-size: 11px; line-height: 1.35; touch-action: pan-y pinch-zoom; }
body.mobile #dpad { display: grid; grid-area: pad; }
body.mobile #controls { grid-area: controls; min-width: 0; height: 230px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: 48px minmax(110px, 1fr) 44px; gap: 6px; align-self: center; }
body.mobile #controls button { font-size: 0; border-radius: 7px; min-height: 44px; min-width: 0; padding: 5px; overflow-wrap: anywhere; }
body.mobile #controls button::after { content: attr(data-hint); font-size: 10px; line-height: 1.2; }
body.mobile #eatBtn { grid-column: 1; grid-row: 1; }
body.mobile #memoryBtn { grid-column: 2; grid-row: 1; }
body.mobile #eatBtn::before, body.mobile #memoryBtn::before { content: ""; display: block; width: 19px; height: 19px; margin: 0 auto 3px; background: #ffe07a; }
body.mobile #eatBtn::before { mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 6V4a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v2' fill='none' stroke='black' stroke-width='2'/%3E%3Crect x='3' y='6' width='18' height='16' rx='3'/%3E%3C/svg%3E") center / contain no-repeat; }
body.mobile #memoryBtn::before { mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M5 2h16v18l-3 2H2l3-4zm3 4v2h10V6zm0 5v2h8v-2z'/%3E%3C/svg%3E") center / contain no-repeat; }
body.mobile[data-mode="battle"] #memoryBtn::before { display: none; }
body.mobile #magicBtn { grid-column: 1; grid-row: 3; }
body.mobile #specialBtn { grid-column: 2; grid-row: 3; }
body.mobile #controls #actBtn, body.mobile #controls #statusBtn { position: relative; padding: 0; min-height: 0; width: var(--action-size); height: var(--action-size); border: 3px solid #d9b665; border-radius: 50%; background: linear-gradient(145deg, #3a4c3f, #10251b); box-shadow: inset 0 0 0 3px #071710, inset 0 0 0 5px #ffffff28, 0 4px 5px #0007; justify-self: center; margin-bottom: 24px; }
body.mobile #actBtn { grid-column: 2; grid-row: 2; align-self: start; }
body.mobile #statusBtn { grid-column: 1; grid-row: 2; align-self: end; }
body.mobile #actBtn::before { content: "A"; }
body.mobile #statusBtn::before { content: "B"; }
body.mobile #controls #actBtn::before, body.mobile #controls #statusBtn::before { font-size: clamp(30px, 4.5vw, 48px); line-height: 1; }
body.mobile #controls #actBtn::after, body.mobile #controls #statusBtn::after { position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%); width: calc(var(--action-size) + 25px); color: #ffe07a; text-align: center; }
body.mobile #interactionMenu { grid-area: stage; position: absolute; inset: 0; z-index: 20; margin: 0; min-height: 0; padding: 9px; overflow-y: auto; font-size: 12px; touch-action: pan-y pinch-zoom; }
body.mobile #interactionMenu h2 { font-size: 15px; }
body.mobile[data-mode="dialog"] #interactionMenu, body.mobile[data-mode="cutscene"] #interactionMenu { display: none !important; }
body.mobile[data-mode="battle"] #interactionMenu { grid-area: auto; inset: auto 0 auto 0; top: calc(100% + 10px); height: auto; overflow: visible; }
body.mobile .itemList { grid-template-columns: 1fr; max-height: 180px; }
body.mobile #mobileHint { display: none; }
body.mobile #startOverlay { padding: 5px; gap: 4px; }
body.mobile .lobStartMenu { gap: 4px; min-width: 132px; }
body.mobile .lobStartMenu button { min-height: 44px; padding: 4px; font-size: 10px; }
body.mobile .startTagline { font-size: 9px; padding: 3px 7px; }
body.mobile .startCredits { font-size: 7px; margin: 0; }
body.tablet { --pad-size: 64px; --action-size: 90px; }
body.tablet #controls { height: 280px; }
body.tablet #controls button::after { font-size: 12px; }
@media (orientation: landscape) {
  body.mobile #wrap { width: min(100%, 1400px); height: calc(100dvh - max(5px, env(safe-area-inset-top)) - max(5px, env(safe-area-inset-bottom))); grid-template-columns: clamp(138px, 19vw, 210px) minmax(0, 1fr) clamp(148px, 21vw, 230px); grid-template-rows: 44px minmax(0, 1fr) auto auto; grid-template-areas: "header header header" "pad stage controls" "objective objective objective" "log log log"; gap: 6px 10px; }
  body.mobile #stage { width: min(100%, calc((100dvh - 148px) * 4 / 3)); }
  body.mobile #controls { height: min(100%, 280px); }
  body.mobile #objective, body.mobile #log { max-height: 46px; }
  body.mobile .startTagline { display: none; }
  body.tablet #wrap { grid-template-columns: 210px minmax(0, 1fr) 240px; }
}
