/* Lingua Quest — shared look: watercolor paper, mint + apricot, glowing teal ink. */
:root {
  --font: "Trebuchet MS", sans-serif;
  --cream: #fff8ec; --paper: #fdf1dc; --mint: #bfe8dc; --mint2: #8fd3c3; --teal: #3d8f86; --ink-glow: #54e0cf;
  --apricot: #f5a46b; --apricot2: #e88a5a; --sakura: #f6b8c4; --lav: #b9a8e8; --text: #4a3528; --text2: #7a6352;
  --good: #3fb37f; --bad: #e86b6b; --gold: #f2c14e;
  --nav-h: 66px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #f3e6cf; color: var(--text); font-family: var(--font); user-select: none; -webkit-user-select: none; touch-action: manipulation; }
#app { position: fixed; inset: 0; overflow: hidden; background: radial-gradient(circle at 30% 10%, #fffdf6, #f6e6cc 70%); }
#screen { position: absolute; inset: 0; }
#app.has-nav #screen { bottom: calc(var(--nav-h) + var(--safe-b)); }
.scr { position: absolute; inset: 0; overflow: hidden; display: flex; flex-direction: column; transition: opacity .25s ease, transform .28s cubic-bezier(.3,1.4,.5,1); }
.scr-enter { opacity: 0; transform: translateY(14px) scale(.985); }
.scr-leave { opacity: 0; transform: translateY(-8px); pointer-events: none; }
.scroll { overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.scroll::-webkit-scrollbar { display: none; }
#layer { position: absolute; inset: 0; pointer-events: none; z-index: 50; }
#layer > * { pointer-events: auto; }
button { font-family: var(--font); color: var(--text); }
h1, h2, h3 { margin: 0; font-weight: 900; }
.outlined { text-shadow: 0 2px 0 #fff, 2px 0 0 #fff, -2px 0 0 #fff, 0 -2px 0 #fff, 0 3px 4px rgba(74,53,40,.35); }

/* panel and buttons wear the UI art (9-slice via border-image) */
.panel { border: 22px solid transparent; border-image: url(../assets/ui-panel.webp) 18% fill / 22px stretch; padding: 4px; filter: drop-shadow(0 4px 8px rgba(90,60,30,.18)); }
.btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; min-width: 96px; padding: 4px 18px;
  border: 14px solid transparent; border-image: url(../assets/ui-button.webp) 30% fill / 14px stretch; background: none; cursor: pointer;
  font-size: 18px; font-weight: 900; color: #fff; text-shadow: 0 2px 0 #b8603a, 1px 0 0 #b8603a, -1px 0 0 #b8603a, 0 -1px 0 #b8603a;
  transition: transform .12s, filter .15s; }
.btn .btn-t { line-height: 1.15; }
.btn .btn-ic { width: 26px; height: 26px; object-fit: contain; }
.btn.small { min-height: 44px; min-width: 72px; font-size: 15px; padding: 2px 10px; }
.btn.primary { filter: saturate(1.15) drop-shadow(0 0 8px rgba(84,224,207,.55)); }
.btn.ghost { border-image: none; border: 2px solid rgba(74,53,40,.18); border-radius: 14px; background: rgba(255,250,240,.85); color: var(--text); text-shadow: none; }
.btn:hover:not([disabled]) { filter: brightness(1.07) saturate(1.1); transform: translateY(-1px) scale(1.02); }
.btn:active:not([disabled]), .btn.pop { animation: squash .22s; }
.btn[disabled] { filter: grayscale(.7) opacity(.55); cursor: default; }
@keyframes squash { 0% { transform: scale(1); } 35% { transform: scale(.92, .86); } 70% { transform: scale(1.05, 1.04); } 100% { transform: scale(1); } }
.icon-btn { position: relative; width: 48px; height: 48px; border: 0; padding: 4px; cursor: pointer; background: url(../assets/ui-pause.webp) center / 0 0 no-repeat, radial-gradient(circle, #fffaf0 60%, #f5d8b8); border-radius: 14px; box-shadow: 0 3px 0 #d9a77c, 0 4px 8px rgba(0,0,0,.15); transition: transform .12s; }
.icon-btn img { width: 100%; height: 100%; object-fit: contain; }
.icon-btn:active { transform: scale(.9); }
.badge { position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--bad); color: #fff; font-size: 12px; font-weight: 900; line-height: 20px; text-align: center; }
.kfocus { outline: 3px solid var(--ink-glow) !important; outline-offset: 3px; box-shadow: 0 0 14px var(--ink-glow) !important; border-radius: 12px; }

/* chips + top hud */
.chip { display: inline-flex; align-items: center; gap: 5px; height: 44px; min-height: 44px; padding: 0 10px; border-radius: 18px; border: 2px solid rgba(255,255,255,.9); background: rgba(255,250,240,.92); box-shadow: 0 2px 6px rgba(90,60,30,.18); font-weight: 900; font-size: 16px; color: var(--text); }
button.chip { cursor: pointer; }
.chip-ic { width: 24px; height: 24px; object-fit: contain; }
.top-hud .chip { flex: 0 1 auto; min-width: 44px; justify-content: center; }
.top-hud .lv-chip { flex: 1 1 auto; min-width: 60px; }
@media (max-width: 420px) { .top-hud .lang-name { display: none; } .top-hud .chip { padding: 0 8px; } }
.top-hud { position: relative; z-index: 5; display: flex; align-items: center; gap: 6px; padding: calc(10px + var(--safe-t)) 64px 6px 10px; flex-wrap: nowrap; }
.lang-chip .flag { font-size: 18px; }
.lang-chip span:last-child { max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.lv-chip { padding: 0 8px 0 2px; flex: 1; min-width: 70px; }
.lv-ring { --p: 0%; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--teal) var(--p), #e8dccb 0); flex: none; }
.lv-ring b { width: 23px; height: 23px; border-radius: 50%; background: #fffaf0; display: grid; place-items: center; font-size: 13px; }
.xpbar { flex: 1; height: 9px; border-radius: 5px; background: #eadfcd; overflow: hidden; }
.xpbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--mint2), var(--ink-glow)); border-radius: 5px; transition: width .6s cubic-bezier(.3,1.3,.5,1); }
.flag { font-size: 20px; line-height: 1; }
.flag.big { font-size: 34px; }

/* bottom nav */
#nav { position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + var(--safe-b)); padding: 4px 4px var(--safe-b); display: flex; z-index: 20;
  background: linear-gradient(#fffaf0, #fbeedb); border-top: 2px solid #f0dcc0; box-shadow: 0 -4px 12px rgba(90,60,30,.1); }
#nav[hidden] { display: none; }
.nav-tab { flex: 1; min-width: 0; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; cursor: pointer; font-size: 12px; font-weight: 900; color: var(--text2); border-radius: 14px; transition: transform .15s; }
.nav-tab .nav-ic { width: 34px; height: 34px; object-fit: contain; transition: transform .2s cubic-bezier(.3,1.6,.5,1); filter: saturate(.6); }
.nav-tab span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.nav-tab.on { color: var(--teal); background: rgba(191,232,220,.55); }
.nav-tab.on .nav-ic { transform: translateY(-3px) scale(1.12); filter: drop-shadow(0 0 6px rgba(84,224,207,.7)); }

/* modal, toast, banner, subtitle */
.modal-wrap { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(60,40,30,.35); animation: fadein .2s; }
.modal-wrap.out { animation: fadeout .2s forwards; }
.modal { position: relative; width: min(100%, 380px); max-height: 88%; display: flex; flex-direction: column; animation: popin .28s cubic-bezier(.3,1.6,.5,1); }
.modal-title { text-align: center; font-size: 22px; color: var(--teal); padding: 6px 30px 8px; }
.modal-body { overflow-y: auto; padding: 4px 6px; font-size: 16px; line-height: 1.5; scrollbar-width: none; }
.modal-body p { margin: 6px 0; }
.modal-actions { display: flex; gap: 10px; justify-content: center; padding-top: 10px; flex-wrap: wrap; }
.modal-x { position: absolute; top: -8px; right: -8px; width: 44px; height: 44px; border: 0; border-radius: 50%; background: #fffaf0; box-shadow: 0 2px 6px rgba(0,0,0,.2); font-size: 18px; font-weight: 900; cursor: pointer; color: var(--text2); }
@keyframes popin { 0% { transform: scale(.7); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes fadein { from { opacity: 0; } } @keyframes fadeout { to { opacity: 0; } }
.toast { position: absolute; left: 50%; top: calc(64px + var(--safe-t)); transform: translateX(-50%); display: flex; align-items: center; gap: 8px; max-width: 86%; padding: 10px 16px; border-radius: 16px; background: rgba(255,250,240,.97); box-shadow: 0 4px 14px rgba(0,0,0,.2); font-weight: 900; font-size: 15px; animation: dropin .3s cubic-bezier(.3,1.6,.5,1); }
.toast.out { opacity: 0; transition: opacity .35s; }
.toast-ic { width: 28px; height: 28px; object-fit: contain; }
@keyframes dropin { from { transform: translate(-50%, -30px); opacity: 0; } }
.banner { position: absolute; left: 0; right: 0; top: 38%; text-align: center; pointer-events: none !important; animation: slam .45s cubic-bezier(.3,1.7,.5,1); }
.banner span { display: inline-block; padding: 10px 26px; font-size: 34px; font-weight: 900; color: #fff; background: linear-gradient(90deg, transparent, rgba(61,143,134,.92) 15%, rgba(61,143,134,.92) 85%, transparent); text-shadow: 0 3px 0 #2a5f59, 0 0 16px var(--ink-glow); }
.banner.out { opacity: 0; transform: scale(1.1); transition: all .35s; }
@keyframes slam { 0% { transform: scale(2.2); opacity: 0; } 60% { transform: scale(.95); opacity: 1; } 100% { transform: scale(1); } }
#subtitle { position: absolute; left: 50%; bottom: calc(var(--nav-h) + 16px + var(--safe-b)); transform: translateX(-50%); max-width: 88%; padding: 8px 14px; border-radius: 12px; background: rgba(40,30,25,.78); color: #fff; font-size: 15px; font-weight: 700; text-align: center; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 60; }
#subtitle.on { opacity: 1; }

/* language picker + celebrations */
.lang-list { display: flex; flex-direction: column; gap: 10px; }
.lang-opt { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 8px 14px; border-radius: 16px; border: 2px solid #f0dcc0; background: #fffaf0; cursor: pointer; text-align: left; transition: transform .12s; }
.lang-opt.on { border-color: var(--teal); background: #eafaf5; box-shadow: 0 0 10px rgba(84,224,207,.5); }
.lang-opt:active { transform: scale(.97); }
.lang-name { display: flex; flex-direction: column; } .lang-name b { font-size: 18px; } .lang-name small { color: var(--text2); font-size: 13px; }
.celebrate { display: flex; flex-direction: column; align-items: center; text-align: center; }
.celebrate-ic { width: 140px; height: 140px; object-fit: contain; animation: popin .5s cubic-bezier(.3,1.6,.5,1); }
.help p { margin: 8px 0; }
canvas.actor { display: block; pointer-events: none; }
