html, body { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; background: #0d1216; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
#stage { position: fixed; inset: 0; }
#gl { width: 100%; height: 100%; display: block; }
#ui { position: fixed; inset: 0; pointer-events: none; color: #fbf4e4; font-family: var(--font, Georgia, serif); }
#ui * { box-sizing: border-box; }
.layer { position: absolute; inset: 0; }
.hidden { display: none !important; }
.tap { pointer-events: auto; cursor: pointer; }

.txt { text-shadow: 0 2px 0 #1b2a30, 0 0 6px rgba(10, 20, 26, 0.9), 0 0 2px #1b2a30; }
.panel {
  border-style: solid; border-color: transparent; border-width: 22px;
  border-image: url(../assets/ui-panel.webp) 14% fill / 22px / 0 stretch;
}
.btn {
  pointer-events: auto; cursor: pointer; position: relative; display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 6px 28px; font-weight: 800; font-size: 18px; letter-spacing: 0.03em; color: #fff6dc;
  border-style: solid; border-color: transparent; border-width: 14px 30px;
  border-image: url(../assets/ui-button.webp) 30% 18% fill / 14px 30px / 0 stretch;
  text-shadow: 0 2px 0 #13232a, 0 0 4px #13232a; transition: transform 0.12s ease-out, filter 0.15s;
  background: none; font-family: inherit; white-space: nowrap;
}
.btn:hover, .btn.focus { filter: brightness(1.25) drop-shadow(0 0 10px rgba(255, 214, 140, 0.75)); transform: scale(1.04); }
.btn:active { transform: scale(0.95); }
.btn img { width: 28px; height: 28px; object-fit: contain; }
.btn.disabled { filter: grayscale(0.8) brightness(0.6); pointer-events: none; }

/* ---------- title ---------- */
#title { background: #c9c4b4 center / cover no-repeat; overflow: hidden; }
#title .shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(255,250,235,0.0) 40%, rgba(20, 28, 34, 0.45) 100%); }
#logo { position: absolute; left: 50%; top: 6%; width: min(72vw, 128vh); max-height: 34%; object-fit: contain; transform: translateX(-50%); filter: drop-shadow(0 6px 18px rgba(30, 40, 50, 0.45)); animation: logoIn 0.9s cubic-bezier(.2,1.4,.4,1) both, logoFloat 5s ease-in-out 1s infinite; }
@keyframes logoIn { from { opacity: 0; transform: translateX(-50%) translateY(-30px) scale(1.15); } to { opacity: 1; transform: translateX(-50%) scale(1); } }
@keyframes logoFloat { 0%,100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(-6px); } }
#prompt { position: absolute; left: 0; right: 0; bottom: 9%; text-align: center; font-size: clamp(16px, 2.6vh, 26px); font-weight: 700; letter-spacing: 0.12em; animation: pulse 2.2s ease-in-out infinite; }
#prompt::before, #prompt::after { content: "✦"; color: #ffd98a; margin: 0 14px; font-size: 0.8em; }
@keyframes pulse { 0%,100% { opacity: 0.55; } 50% { opacity: 1; } }
.corner { position: absolute; top: calc(12px + env(safe-area-inset-top)); width: 50px; height: 50px; border-radius: 50%; background: rgba(24, 40, 46, 0.45); border: 2px solid rgba(255, 222, 160, 0.65); display: flex; align-items: center; justify-content: center; pointer-events: auto; cursor: pointer; transition: transform .12s, background .15s; box-shadow: 0 2px 10px rgba(0,0,0,0.25); }
.corner:hover { background: rgba(40, 64, 72, 0.7); transform: scale(1.06); }
.corner:active { transform: scale(0.92); }
.corner img, .corner svg { width: 30px; height: 30px; object-fit: contain; }
#btnBoard { right: calc(12px + env(safe-area-inset-right)); }
#btnShop { left: calc(12px + env(safe-area-inset-left)); }
#titleGold { position: absolute; top: calc(22px + env(safe-area-inset-top)); left: calc(72px + env(safe-area-inset-left)); display: flex; align-items: center; gap: 6px; font-size: 18px; font-weight: 800; }
#titleGold img { width: 26px; height: 26px; }
.kbd { position: absolute; top: 64px; font-size: 12px; opacity: 0.8; width: 50px; text-align: center; }

/* ---------- HUD ---------- */
#hud .hpbox { position: absolute; left: calc(10px + env(safe-area-inset-left)); top: 8px; padding: 0 4px; min-width: 200px; }
.hprow { display: flex; gap: 4px; align-items: center; }
.hp { width: 18px; height: 18px; transform: rotate(45deg); border: 2px solid #ffe2a6; background: linear-gradient(135deg, #fff6d6, #f0b955); box-shadow: 0 0 8px rgba(255, 210, 120, 0.8); transition: all .2s; }
.hp.off { background: rgba(20, 30, 36, 0.6); box-shadow: none; border-color: rgba(255,226,166,0.4); }
.scoreline { font-size: 24px; font-weight: 900; margin-top: 4px; letter-spacing: 0.04em; }
.subline { display: flex; gap: 14px; align-items: center; font-size: 16px; font-weight: 800; margin-top: 2px; }
.subline img { width: 20px; height: 20px; vertical-align: middle; }
.boostbar { width: 120px; height: 7px; border-radius: 4px; background: rgba(10, 20, 26, 0.6); border: 1px solid rgba(255, 230, 180, 0.5); overflow: hidden; margin-top: 6px; }
.boostbar > div { height: 100%; width: 100%; background: linear-gradient(90deg, #9fe8e4, #fff); }
#chain { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); font-size: 30px; font-weight: 900; color: #ffe39a; opacity: 0; transition: opacity .3s; white-space: nowrap; }
#bossbar { position: absolute; left: 50%; top: 10px; width: min(46vw, 520px); transform: translateX(-50%); text-align: center; }
#bossbar .name { font-size: 16px; font-weight: 800; letter-spacing: 0.15em; margin-bottom: 4px; }
#bossbar .bar { height: 12px; border-radius: 6px; background: rgba(12, 18, 24, 0.7); border: 2px solid rgba(255, 220, 150, 0.8); overflow: hidden; }
#bossbar .fill { height: 100%; width: 100%; background: linear-gradient(90deg, #b06bd0, #ffb860, #fff1c8); transition: width .2s; }
#hintbox { position: absolute; left: 50%; bottom: 40%; transform: translateX(-50%); text-align: center; font-size: 17px; font-weight: 700; line-height: 1.7; transition: opacity .6s; white-space: nowrap; }

/* ---------- dialogue ---------- */
.dlg { display: flex; align-items: center; gap: 12px; }
.dlg .por { flex: 0 0 auto; width: 76px; height: 76px; border-radius: 50%; overflow: hidden; border: 2px solid #f1d49a; background: radial-gradient(circle, #3c5560, #18262c); box-shadow: 0 0 14px rgba(255, 220, 150, 0.45); }
.dlg .por img { width: 100%; height: 100%; object-fit: cover; object-position: center 20%; }
.dlg .who { font-size: 15px; font-weight: 900; color: #ffd98a; letter-spacing: 0.1em; }
.dlg .say { font-size: 18px; font-weight: 700; line-height: 1.45; }
#bark { position: absolute; left: 50%; top: 64px; width: min(56vw, 600px); transform: translateX(-50%); transition: opacity .3s, transform .3s; }
#bark .por { width: 56px; height: 56px; }
#bark .say { font-size: 16px; }
#story .bar { position: absolute; left: 0; right: 0; height: 11%; background: #05080a; transition: transform .6s ease; }
#story .bar.top { top: 0; } #story .bar.bot { bottom: 0; }
#storyDlg { position: absolute; left: 50%; bottom: 4%; width: min(76vw, 860px); transform: translateX(-50%); pointer-events: auto; cursor: pointer; min-height: 120px; }
#storyDlg .por { width: 92px; height: 92px; }
#storyDlg .say { font-size: 20px; }
#storyDlg .more { position: absolute; right: 2px; bottom: -6px; color: #ffd98a; animation: pulse 1.2s infinite; font-size: 14px; }
#skip { position: absolute; top: calc(10px + env(safe-area-inset-top)); right: calc(12px + env(safe-area-inset-right)); min-height: 46px; font-size: 16px; padding: 4px 18px; }

/* ---------- cards / banners ---------- */
#card { position: absolute; left: 0; right: 0; top: 34%; text-align: center; opacity: 0; }
#card .k { font-size: clamp(16px, 2.6vh, 24px); letter-spacing: 0.5em; color: #ffe1a0; font-weight: 700; }
#card .t { font-size: clamp(32px, 7vh, 64px); font-weight: 900; letter-spacing: 0.18em; margin-top: 6px; }
#card .line { width: 0; height: 2px; margin: 14px auto 0; background: linear-gradient(90deg, transparent, #ffe1a0, transparent); transition: width 1.2s ease; }
#card.show { animation: cardIn 3.6s ease forwards; }
#card.show .line { width: min(60vw, 520px); }
@keyframes cardIn { 0% { opacity: 0; transform: scale(1.08); } 15% { opacity: 1; transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; } }
#toast { position: absolute; left: 0; right: 0; top: 30%; text-align: center; font-size: clamp(26px, 5vh, 44px); font-weight: 900; color: #ffe8b0; letter-spacing: 0.12em; opacity: 0; }
#toast.show { animation: slam 1.6s cubic-bezier(.2,1.3,.4,1) forwards; }
@keyframes slam { 0% { opacity: 0; transform: scale(2); } 14% { opacity: 1; transform: scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px); } }
#fade { position: absolute; inset: 0; background: #fff8ea; opacity: 0; transition: opacity .5s ease; }

/* ---------- modal ---------- */
.modal { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(8, 14, 18, 0.55); pointer-events: auto; }
.modal .box { min-width: min(420px, 80vw); max-width: 86vw; padding: 6px 10px; text-align: center; animation: pop .28s cubic-bezier(.2,1.4,.4,1); }
@keyframes pop { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal h2 { margin: 2px 0 12px; font-size: 26px; font-weight: 900; letter-spacing: 0.1em; color: #ffe1a0; }
.modal .col { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.modal p { white-space: pre-line; text-align: left; font-size: 16px; line-height: 1.6; margin: 0 0 12px; }
.modal .msg { font-size: 14px; color: #ffd27a; min-height: 18px; }

/* ---------- video ---------- */
#vid { position: absolute; inset: 0; background: #000 center / cover no-repeat; pointer-events: auto; }
#vid video { width: 100%; height: 100%; object-fit: cover; }
#vidSub { position: absolute; left: 0; right: 0; bottom: 8%; text-align: center; font-size: clamp(16px, 2.8vh, 24px); font-weight: 700; padding: 0 10%; }

@media (max-height: 460px) {
  .scoreline { font-size: 20px; }
  .dlg .say { font-size: 15px; }
  #storyDlg { width: 80vw; min-height: 96px; bottom: 3%; }
  #storyDlg .por { width: 64px; height: 64px; }
  #storyDlg .say { font-size: 16px; }
  #bark { top: 54px; width: 58vw; }
  #bark .por { width: 44px; height: 44px; }
  #bark .say { font-size: 14px; }
  .modal h2 { font-size: 20px; margin-bottom: 8px; }
  .btn { min-height: 44px; font-size: 15px; }
  .modal .col { gap: 6px; }
  #hud .hpbox { min-width: 160px; }
}
