@font-face {
  font-family: "NinjaPixel";
  src: url("../assets/Ninja%20Adventure%20-%20Asset%20Pack/Ui/Font/NormalFont.ttf") format("truetype");
  font-display: swap;
}
:root {
  --wood-d: #20140e; --wood: #3a261a; --wood-l: #5a3c26; --gold: #e0b45c; --gold-d: #a8793a;
  --paper: #f3e2b8; --paper-d: #d9c08a; --ink: #3a2616; --text: #f8ecd2; --muted: #c9b48e;
  --hp: #d8403c; --mp: #3f7fe0; --xp: #e8c44a; --good: #6fcf7f; --bad: #ff6b5e;
  --font: "NinjaPixel", "Courier New", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #0d0a08; color: var(--text); font-family: var(--font); font-size: 16px; word-spacing: .35em; overflow: hidden; -webkit-tap-highlight-color: transparent; }
button, input { font-family: inherit; font-size: inherit; color: inherit; }
img, canvas { image-rendering: pixelated; }
.hidden { display: none !important; }
#app { position: fixed; inset: 0; }
.screen { position: absolute; inset: 0; display: none; }
.screen.active { display: block; }

/* ------------------------------------------------------------- scenery */
.title-art {
  position: absolute; inset: 0; overflow: hidden;
  background:
    radial-gradient(circle at 18% 72%, rgba(255,190,90,.55) 0 2.2%, transparent 3.5%),
    radial-gradient(circle at 30% 66%, rgba(255,120,80,.5) 0 1.8%, transparent 3%),
    radial-gradient(circle at 78% 70%, rgba(255,190,90,.5) 0 2.2%, transparent 3.5%),
    radial-gradient(circle at 66% 76%, rgba(255,120,80,.45) 0 1.6%, transparent 2.8%),
    radial-gradient(ellipse at 50% 120%, #1c3a22 0 38%, transparent 39%),
    radial-gradient(ellipse at 15% 118%, #14301b 0 34%, transparent 35%),
    radial-gradient(ellipse at 88% 118%, #14301b 0 36%, transparent 37%),
    linear-gradient(#150f26 0%, #2c1d46 38%, #6a3d5a 66%, #e0905a 100%);
}
.title-art::before, .title-art::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(#fff 1px, transparent 1.5px); background-size: 90px 90px, 140px 140px; opacity: .35;
  mask-image: linear-gradient(#000, transparent 55%); -webkit-mask-image: linear-gradient(#000, transparent 55%); }
.title-art::after { background-size: 140px 140px; background-position: 40px 30px; opacity: .25; }
.boot-card { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; background: var(--wood-d); }
.logo-mark { width: 48px; height: 48px; margin: 0 auto 12px; background: var(--gold); border-radius: 50%; box-shadow: 0 0 0 6px var(--wood), 0 0 28px 8px rgba(224,180,92,.5); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.12); box-shadow: 0 0 0 6px var(--wood), 0 0 40px 14px rgba(224,180,92,.65); } }

/* ------------------------------------------------------------- panels */
.panel {
  position: relative; background: linear-gradient(180deg, var(--wood-l), var(--wood) 14%, var(--wood-d));
  border: 4px solid var(--gold-d); outline: 4px solid var(--wood-d); outline-offset: -8px;
  box-shadow: 0 0 0 3px #000, 0 12px 40px rgba(0,0,0,.6); padding: 22px 24px; border-radius: 6px;
}
.panel h2, .panel h3 { margin: 0 0 10px; font-weight: normal; color: var(--gold); letter-spacing: 1px; }
.game-title { margin: 0; font-weight: normal; font-size: 40px; color: var(--gold); text-shadow: 3px 3px 0 #000, 0 0 18px rgba(224,180,92,.45); text-align: center; }
.game-title.big { font-size: 56px; }
.subtitle { margin: 4px 0 14px; text-align: center; color: var(--muted); }
.auth-panel, .create-panel, .title-panel, .small-panel { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.auth-panel { width: min(420px, 92vw); } .title-panel { width: min(400px, 92vw); } .small-panel { width: min(420px, 92vw); }
.create-panel { width: min(760px, 96vw); max-height: 96vh; overflow: auto; }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tab { flex: 1; padding: 8px 10px; background: var(--wood-d); border: 2px solid var(--wood-l); border-bottom-width: 4px; border-radius: 4px; cursor: pointer; color: var(--muted); }
.tab.active { background: var(--wood-l); border-color: var(--gold); color: var(--gold); }
.tab:hover { color: var(--text); }

label { display: block; margin: 10px 0; color: var(--muted); font-size: 14px; }
label .opt { opacity: .6; }
input { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; background: #140d09; border: 2px solid var(--wood-l); border-radius: 4px; color: var(--text); outline: none; }
input:focus { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(224,180,92,.25); }
.form-msg { min-height: 20px; margin: 6px 0; color: var(--bad); font-size: 14px; }
.form-msg.ok { color: var(--good); }

.btn { display: block; width: 100%; padding: 12px 16px; margin: 6px 0; background: linear-gradient(var(--wood-l), var(--wood)); border: 2px solid var(--gold-d); border-bottom-width: 5px; border-radius: 5px; cursor: pointer; letter-spacing: 1px; text-align: center; transition: transform .05s, filter .1s; }
.btn:hover:not(:disabled) { filter: brightness(1.25); }
.btn:active:not(:disabled) { transform: translateY(2px); border-bottom-width: 3px; }
.btn.primary { background: linear-gradient(#e8bd62, #b9812f); color: #2a1a0c; border-color: #6e4818; font-weight: bold; }
.btn.danger { background: linear-gradient(#b94a42, #7c2a26); border-color: #4b1512; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.small { display: inline-block; width: auto; padding: 5px 10px; margin: 2px; font-size: 13px; border-bottom-width: 3px; }
.row { display: flex; gap: 10px; } .row .btn { flex: 1; }
.menu-list { display: grid; gap: 2px; }

/* ------------------------------------------------------------- creation */
.create-grid { display: grid; grid-template-columns: 190px 1fr; gap: 20px; }
.create-preview { text-align: center; background: radial-gradient(circle, #4f6b3a, #25361b); border: 3px solid var(--wood-l); border-radius: 6px; padding: 14px 8px; }
.create-preview canvas { width: 128px; height: 128px; }
.preview-class { margin-top: 8px; font-size: 14px; color: var(--paper); min-height: 70px; }
.field-title { margin: 12px 0 6px; color: var(--gold); font-size: 14px; letter-spacing: 1px; }
.choice-list { display: grid; gap: 6px; }
.choice { text-align: left; padding: 8px 12px; background: var(--wood-d); border: 2px solid var(--wood-l); border-radius: 4px; cursor: pointer; }
.choice.active { border-color: var(--gold); background: var(--wood-l); }
.choice small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.swatch-list { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 52px; height: 52px; padding: 0; border: 3px solid var(--wood-l); border-radius: 6px; background: #25361b; cursor: pointer; overflow: hidden; }
.swatch.active { border-color: var(--gold); box-shadow: 0 0 10px rgba(224,180,92,.6); }
.swatch canvas { width: 100%; height: 100%; }

/* ------------------------------------------------------------- game stage + HUD */
#screenGame { background: #000; }
#stage { position: absolute; inset: 0; }
#gameCanvas { width: 100%; height: 100%; display: block; background: #0a120a; }
#hud { position: absolute; inset: 0; pointer-events: none; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
#hud > * { pointer-events: auto; }
.hud-card { position: absolute; left: 10px; top: 10px; display: flex; gap: 8px; align-items: center; padding: 8px 10px; min-width: 260px;
  background: rgba(32,20,14,.88); border: 3px solid var(--gold-d); border-radius: 6px; box-shadow: 0 0 0 2px #000; }
.face { width: 54px; height: 54px; flex: none; border: 3px solid var(--gold-d); border-radius: 4px; background: #25361b center/contain no-repeat; image-rendering: pixelated; }
.face.big { width: 96px; height: 96px; background-size: 90%; }
.hud-main { flex: 1; min-width: 0; }
.hud-line { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; margin-bottom: 3px; }
.hud-line b { font-weight: normal; color: var(--paper); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud-line span { color: var(--gold); white-space: nowrap; }
.bar { position: relative; height: 14px; margin: 3px 0; background: #130c08; border: 2px solid #000; border-radius: 3px; overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; width: 100%; transition: width .2s; }
.bar span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; text-shadow: 1px 1px 0 #000; }
.bar.hp i { background: linear-gradient(#ff6a60, #b02a26); } .bar.mp i { background: linear-gradient(#6ea6ff, #2a56b4); }
.bar.xp { height: 9px; } .bar.xp i { background: linear-gradient(#ffe27a, #c79a22); } .bar.xp span { font-size: 8px; }
.bar.enemy { height: 18px; } .bar.enemy i { background: linear-gradient(#e86a5a, #8e2a26); }
.gold { display: flex; flex-direction: column; align-items: center; font-size: 13px; color: var(--gold); gap: 2px; }
.gold img { width: 24px; height: 24px; }
#hudTop { position: absolute; right: 10px; top: 10px; display: flex; gap: 8px; align-items: center; }
.hud-pill { padding: 8px 14px; background: rgba(32,20,14,.88); border: 3px solid var(--gold-d); border-radius: 20px; font-size: 14px; color: var(--paper); }
.icon-btn { width: 40px; height: 40px; background: rgba(32,20,14,.9); border: 3px solid var(--gold-d); border-radius: 6px; cursor: pointer; font-size: 20px; color: var(--gold); line-height: 1; }
.icon-btn:hover { filter: brightness(1.3); }
.enemy-bar { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); width: min(340px, 36vw); text-align: center; }
.enemy-bar .ename { text-shadow: 2px 2px 0 #000; margin-bottom: 2px; color: #ffd9c8; }
.tracker { position: absolute; left: 10px; top: 100px; width: 250px; font-size: 13px; text-shadow: 1px 1px 0 #000; }
.tracker .q { margin-bottom: 6px; padding: 6px 8px; background: rgba(32,20,14,.72); border-left: 4px solid var(--gold); border-radius: 3px; }
.tracker .q b { font-weight: normal; color: var(--gold); display: block; }
.tracker .q.ready { border-left-color: var(--good); } .tracker .q.ready b { color: var(--good); }
.prompt { position: absolute; left: 50%; bottom: 128px; transform: translateX(-50%); padding: 6px 14px; background: rgba(32,20,14,.92); border: 2px solid var(--gold); border-radius: 14px; font-size: 14px; white-space: nowrap; }
.prompt kbd { background: var(--gold); color: #2a1a0c; padding: 1px 7px; border-radius: 3px; margin-right: 6px; }
#toasts { position: absolute; left: 50%; top: 70px; transform: translateX(-50%); display: grid; gap: 6px; justify-items: center; pointer-events: none; width: min(560px, 94vw); }
.toast { padding: 8px 16px; background: rgba(20,12,8,.94); border: 2px solid var(--gold-d); border-radius: 5px; text-align: center; animation: toast 3.4s forwards; font-size: 14px; }
.toast.good { border-color: var(--good); } .toast.bad { border-color: var(--bad); } .toast.gold { border-color: var(--gold); color: var(--gold); }
@keyframes toast { 0% { opacity: 0; transform: translateY(-8px); } 8%, 82% { opacity: 1; transform: none; } 100% { opacity: 0; } }

#skillbar { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); display: flex; gap: 8px; padding: 8px 10px; align-items: center;
  background: rgba(32,20,14,.9); border: 3px solid var(--gold-d); border-radius: 8px; }
#skillSlots { display: flex; gap: 8px; }
.slot { position: relative; width: 52px; height: 52px; padding: 0; background: #130c08; border: 3px solid var(--wood-l); border-radius: 6px; cursor: pointer; overflow: hidden; }
.slot img { width: 36px; height: 36px; margin: 4px; }
.slot b { position: absolute; left: 3px; bottom: 1px; font-size: 11px; font-weight: normal; color: var(--gold); text-shadow: 1px 1px 0 #000; }
.slot u { position: absolute; right: 3px; bottom: 1px; font-size: 11px; text-decoration: none; text-shadow: 1px 1px 0 #000; }
.slot .cd { position: absolute; inset: 0; background: rgba(0,0,0,.62); transform-origin: bottom; }
.slot.locked { opacity: .35; filter: grayscale(1); cursor: default; } .slot.nomp img { filter: saturate(.2) brightness(.7); }
.slot.ready:not(.locked):hover { border-color: var(--gold); }
.slot.item img { width: 32px; height: 32px; margin: 6px; image-rendering: pixelated; }
.slot.item:disabled { opacity: .4; }

.touch { display: none; position: absolute; inset: auto 0 0 0; height: 0; pointer-events: none; }
.touch .dpad, .touch .tbtns { position: absolute; bottom: 86px; pointer-events: auto; }
.touch .dpad { left: 14px; width: 150px; height: 150px; display: grid; grid-template: "u u" "l r" "d d"; }
.touch .dpad button { position: absolute; width: 50px; height: 50px; background: rgba(32,20,14,.72); border: 3px solid var(--gold-d); border-radius: 50%; color: var(--gold); font-size: 20px; }
.touch .dpad [data-dir=up] { left: 50px; top: 0; } .touch .dpad [data-dir=down] { left: 50px; bottom: 0; }
.touch .dpad [data-dir=left] { left: 0; top: 50px; } .touch .dpad [data-dir=right] { right: 0; top: 50px; }
.touch .tbtns { right: 14px; display: grid; gap: 10px; }
.touch .tbtns button { width: 64px; height: 64px; border-radius: 50%; background: rgba(168,121,58,.8); border: 3px solid var(--gold); color: #1c1008; font-size: 22px; }
@media (pointer: coarse) { .touch { display: block; } .prompt { bottom: 160px; } }

/* ------------------------------------------------------------- dialog */
.dialog { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); width: min(780px, 96vw); display: flex; gap: 14px; padding: 14px;
  background: linear-gradient(var(--paper), var(--paper-d)); color: var(--ink); border: 5px solid var(--wood); outline: 3px solid var(--gold-d); border-radius: 8px; box-shadow: 0 8px 30px rgba(0,0,0,.7); z-index: 30; }
.dialog .face { background-color: #e7d3a0; border-color: var(--wood); }
.dbody { flex: 1; min-width: 0; }
.dname { font-size: 18px; color: #8a4a12; margin-bottom: 4px; } .dname small { color: #6b5a3c; font-size: 13px; margin-left: 8px; }
.dtext { min-height: 54px; font-size: 16px; line-height: 1.35; }
.dopts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.dopts .btn { width: auto; margin: 0; padding: 7px 14px; font-size: 14px; color: var(--text); }

/* ------------------------------------------------------------- modals */
.modal { position: absolute; inset: 0; z-index: 40; background: rgba(8,5,3,.72); display: grid; place-items: center; padding: 10px; }
#settingsModal, #confirmModal { position: fixed; z-index: 90; }
.modal .small-panel { position: relative; left: auto; top: auto; transform: none; }
.big-panel { width: min(920px, 98vw); height: min(620px, 94vh); display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.modal-head .tabs { flex: 1; margin: 0; } .modal-head h3 { flex: 1; margin: 0; } .close { font-size: 26px; flex: none; }
.modal-body { flex: 1; overflow: auto; padding: 4px; min-height: 0; }
.shop-gold { display: flex; align-items: center; gap: 6px; color: var(--gold); } .shop-gold img { width: 22px; height: 22px; }

.split { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; height: 100%; }
.grid-items { display: grid; grid-template-columns: repeat(auto-fill, 56px); gap: 6px; align-content: start; }
.cell { position: relative; width: 56px; height: 56px; background: #130c08; border: 3px solid var(--wood-l); border-radius: 5px; cursor: pointer; padding: 0; }
.cell img { width: 36px; height: 36px; margin: 5px; object-fit: contain; }
.cell em { position: absolute; right: 3px; bottom: 1px; font-style: normal; font-size: 11px; text-shadow: 1px 1px 0 #000; }
.cell.sel { border-color: var(--gold); box-shadow: 0 0 8px rgba(224,180,92,.6); }
.cell.empty { opacity: .45; cursor: default; }
.rar-uncommon { border-color: #4aa86a !important; } .rar-rare { border-color: #4a86d8 !important; } .rar-epic { border-color: #a45ad8 !important; }
.detail { background: rgba(0,0,0,.25); border: 2px solid var(--wood-l); border-radius: 6px; padding: 12px; font-size: 14px; overflow: auto; }
.detail h4 { margin: 0 0 4px; font-weight: normal; font-size: 18px; color: var(--gold); } .detail .meta { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.detail .stat { color: var(--good); } .detail .warn { color: var(--bad); }
.equip-row { display: flex; gap: 8px; margin-bottom: 12px; }
.equip-slot { flex: 1; text-align: center; font-size: 11px; color: var(--muted); } .equip-slot .cell { margin: 2px auto; }
.stats-table { width: 100%; border-collapse: collapse; font-size: 14px; } .stats-table td { padding: 4px 6px; border-bottom: 1px dashed var(--wood-l); } .stats-table td:last-child { text-align: right; color: var(--gold); }
.qgroup { margin-bottom: 14px; } .qgroup h4 { margin: 0 0 6px; font-weight: normal; color: var(--gold); border-bottom: 2px solid var(--wood-l); }
.qrow { padding: 8px 10px; margin-bottom: 6px; background: rgba(0,0,0,.25); border-left: 4px solid var(--wood-l); border-radius: 3px; font-size: 14px; }
.qrow.active { border-left-color: var(--gold); } .qrow.ready { border-left-color: var(--good); } .qrow.complete { opacity: .55; border-left-color: #567; } .qrow.available { border-left-color: #6aa7e0; }
.qrow b { font-weight: normal; color: var(--paper); } .qrow .tag { float: right; font-size: 11px; color: var(--muted); } .qrow p { margin: 3px 0; color: var(--muted); }
.mini-bar { height: 8px; background: #130c08; border: 1px solid #000; border-radius: 2px; margin: 4px 0; overflow: hidden; } .mini-bar i { display: block; height: 100%; background: var(--gold); }
.skill-row { display: flex; gap: 12px; align-items: center; padding: 8px; margin-bottom: 6px; background: rgba(0,0,0,.25); border-radius: 4px; }
.skill-row img { width: 40px; height: 40px; } .skill-row.locked { opacity: .45; } .skill-row small { color: var(--muted); display: block; }
.shop-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; margin-bottom: 5px; background: rgba(0,0,0,.25); border: 2px solid var(--wood-l); border-radius: 4px; }
.shop-row img { width: 32px; height: 32px; } .shop-row .info { flex: 1; font-size: 14px; } .shop-row small { color: var(--muted); display: block; font-size: 12px; }
.shop-row .price { color: var(--gold); min-width: 54px; text-align: right; }
.range-row { display: flex; align-items: center; gap: 10px; margin: 10px 0; } .range-row span { flex: 1; } .range-row input[type=range] { width: 150px; padding: 0; margin: 0; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; } .check input { width: auto; margin: 0; }

.banner { position: absolute; left: 50%; top: 32%; transform: translate(-50%, -50%); z-index: 60; padding: 18px 40px; background: rgba(20,12,8,.92); border: 4px solid var(--gold); border-radius: 8px; font-size: 32px; color: var(--gold); text-shadow: 3px 3px 0 #000; text-align: center; animation: banner 2.6s forwards; pointer-events: none; }
.banner small { display: block; font-size: 15px; color: var(--paper); margin-top: 4px; }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.8); } 12%, 80% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; } }
.fade { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity .35s; z-index: 80; } .fade.on { opacity: 1; }

@media (max-width: 760px) {
  .game-title { font-size: 30px; } .game-title.big { font-size: 38px; }
  .create-grid { grid-template-columns: 1fr; } .create-preview canvas { width: 96px; height: 96px; } .preview-class { min-height: 0; }
  .hud-card { min-width: 0; width: 220px; padding: 5px 7px; } .face { width: 42px; height: 42px; } .tracker { display: none; }
  .slot { width: 44px; height: 44px; } .slot img { width: 30px; height: 30px; } #skillbar { gap: 5px; padding: 5px 6px; bottom: 6px; }
  .split { grid-template-columns: 1fr; } .big-panel { height: 96vh; padding: 12px; } .dialog .face.big { width: 64px; height: 64px; }
  .enemy-bar { width: 52vw; top: 64px; } #toasts { top: 120px; } .dtext { font-size: 14px; }
  #hudTop .hud-pill { display: none; }
}
@media (max-height: 520px) { .hud-card .bar.xp { display: none; } .dialog { padding: 8px; } .dialog .face.big { width: 56px; height: 56px; } .tracker { display: none; } }
