/* Pawladin: one canvas of meadow and keep, a slim HUD at the top, a pad of big buttons bottom right for the thumb, the
   break bar, the shop, the skill cards and the fall card. Parchment, oak and gold. */
* { box-sizing: border-box; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: #1b2a14; overflow: hidden; overscroll-behavior: none; }
body { color: #fbf3df; font-family: 'Baloo 2', system-ui, sans-serif; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.app { position: fixed; inset: 0; touch-action: none; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
:root { --gold: #ffd25a; --ink: #fbf3df; --soft: #d9c9a4; --oak: rgba(40, 26, 14, .82); --edge: rgba(255, 210, 90, .32); }

#mm, .sg-sheet {
  --sg-bg: radial-gradient(ellipse at 50% 28%, #4f7a34 0%, #2a4419 55%, #14200d 100%);
  --sg-ink: #fbf3df; --sg-ink-soft: #d9c9a4; --sg-title: #ffe7a0; --sg-title-shadow: 0 3px 0 #5a3410, 0 0 26px rgba(255, 200, 80, .35);
  --sg-accent: #ffd25a; --sg-accent-ink: #3a2208; --sg-card: rgba(52, 34, 18, .86); --sg-card-ink: #fbf3df;
  --sg-line: rgba(255, 210, 90, .26); --sg-sheet-bg: #2a1c10; --sg-sheet-ink: #fbf3df;
}

.vignette { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .35s;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 55%, rgba(160, 30, 10, .5) 100%); }
.vignette.on { opacity: 1; transition: none; background: radial-gradient(ellipse at center, rgba(160, 20, 0, .12) 40%, rgba(190, 30, 10, .62) 100%); }
.vignette.low { opacity: .5; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .2; } }

/* ---------- the HUD ---------- */
.hud { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: flex-start; gap: 10px; pointer-events: none;
  padding: var(--sg-corner-top, max(10px, env(safe-area-inset-top))) max(12px, env(safe-area-inset-right)) 0 var(--sg-corner-left, max(10px, env(safe-area-inset-left))); }
.hud > * { pointer-events: auto; }
.hud-me { width: 176px; max-width: 40vw; padding: 4px 9px 7px; border-radius: 12px; background: var(--oak); border: 1px solid var(--edge);
  font-size: 13px; line-height: 1.2; text-shadow: 0 1px 0 #000; }
.hud-me .row { display: flex; justify-content: space-between; align-items: baseline; font-weight: 800; }
.gold { color: var(--gold); font-weight: 800; font-variant-numeric: tabular-nums; }
.gold::before { content: ''; display: inline-block; width: 11px; height: 11px; margin-right: 4px; border-radius: 50%; vertical-align: -1px;
  background: radial-gradient(circle at 35% 35%, #fff3b0 0 20%, #ffc83a 45%, #b8780f 100%); box-shadow: 0 0 0 1px #5a3a08; }
.bar { position: relative; height: 9px; margin-top: 4px; border-radius: 5px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.bar i { display: block; height: 100%; width: 100%; border-radius: 5px; transform-origin: left; transition: transform .15s; }
.bar.hp { height: 14px; }
.bar.hp i { background: linear-gradient(90deg, #4cc25a, #a6ee6a); }
.bar.hp.low i { background: linear-gradient(90deg, #d0402a, #f2a04a); }
.bar.hp span { position: absolute; inset: 0; text-align: center; font-size: 11px; line-height: 14px; font-weight: 800; color: #fff; }
.bar.xp { height: 5px; }
.bar.xp i { background: linear-gradient(90deg, #7fc8ff, #d8f0ff); }
.hud-mid { margin: 0 auto; display: flex; flex-direction: column; align-items: center; font-weight: 800; text-shadow: 0 2px 0 #000; pointer-events: none; }
.hud-mid b { font-size: 16px; letter-spacing: .08em; text-transform: uppercase; color: #ffe7a0; }
.hud-mid span { font-size: 12px; color: var(--soft); }
.gates { display: grid; grid-template-columns: repeat(3, 14px); grid-template-rows: repeat(3, 14px); gap: 2px; margin-top: 3px; }
.gates i { display: block; border-radius: 3px; background: rgba(255, 255, 255, .15); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .4); }
.gates i.k { background: rgba(140, 120, 90, .5); }
.gates i.ok { background: #8bd06a; } .gates i.hurt { background: #f2c14a; } .gates i.bad { background: #f2603a; } .gates i.down { background: #3a0c06; box-shadow: inset 0 0 0 2px #f2603a; }
.gates i.hit { animation: gatehit .3s ease-out; }
@keyframes gatehit { 0% { transform: scale(1.4); } }
@media (max-width: 380px) { .hud-me { width: 140px; font-size: 12px; } .hud-mid b { font-size: 14px; } }

.pill { position: absolute; left: 50%; top: calc(var(--sg-corner-top, 10px) + 64px); transform: translateX(-50%); min-height: 44px; padding: 0 18px;
  border-radius: 999px; border: 2px solid #ffe7a0; background: linear-gradient(#ffd25a, #e8a020); color: #3a2208;
  font: 800 16px/1 'Baloo 2', system-ui, sans-serif; box-shadow: 0 4px 0 #8a5410, 0 0 20px rgba(255, 200, 80, .55); animation: glow 1.4s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 4px 0 #8a5410, 0 0 6px rgba(255, 200, 80, .3); } }

/* ---------- the thumb's pad, bottom right ---------- */
.sticks { position: absolute; inset: 0; pointer-events: none; }
.stick { position: absolute; width: 110px; height: 110px; margin: -55px 0 0 -55px; border-radius: 50%;
  border: 2px solid rgba(255, 240, 200, .35); background: rgba(255, 240, 200, .08); }
.stick i { position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; margin: -24px 0 0 -24px; border-radius: 50%;
  background: rgba(255, 240, 200, .4); }
.stick-hint { position: absolute; left: max(28px, env(safe-area-inset-left)); bottom: max(40px, env(safe-area-inset-bottom)); width: 96px; height: 96px; border-radius: 50%;
  border: 2px dashed rgba(255, 240, 200, .28); pointer-events: none; transition: opacity .3s; display: grid; place-items: center;
  color: rgba(255, 240, 200, .55); font: 700 11px/1.1 'Baloo 2', system-ui, sans-serif; text-align: center; }
.stick-hint.gone { opacity: 0; }
body.breaking .stick-hint { display: none; }
.pad { position: absolute; right: max(10px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); width: 226px; height: 226px; pointer-events: none; }
.pb { position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; pointer-events: auto;
  border-radius: 50%; border: 2px solid rgba(255, 210, 90, .65); background: rgba(40, 26, 14, .62); color: var(--ink);
  font: 800 14px/1 'Baloo 2', system-ui, sans-serif; text-shadow: 0 1px 0 #000; touch-action: none; }
.pb small { font-size: 11px; color: var(--soft); font-weight: 700; margin-top: 1px; }
.pb.held { background: rgba(255, 210, 90, .45); transform: scale(.95); }
.pb.big { right: 8px; bottom: 14px; width: 112px; height: 112px; font-size: 20px; border-width: 3px; background: radial-gradient(circle at 50% 35%, rgba(150, 70, 30, .8), rgba(60, 26, 10, .8)); }
.pb.mid { width: 64px; height: 64px; }
/* the combo on the Strike button: a pip a swing, and a ring that runs down while the next swing still chains */
.pb.big .pips { display: flex; gap: 5px; margin-top: 4px; }
.pb.big .pips b { width: 9px; height: 9px; border-radius: 50%; background: rgba(255, 240, 200, .22); transition: background .08s, transform .08s; }
.pb.big .pips b.on { background: #ffd34a; box-shadow: 0 0 6px #ffb02a; }
.pb.big .pips b.chop { background: #ff7a3a; box-shadow: 0 0 9px #ff5a1a; transform: scale(1.25); }
.combo-ring { position: absolute; inset: -5px; width: calc(100% + 10px); height: calc(100% + 10px); transform: rotate(-90deg); pointer-events: none; }
.combo-ring circle { fill: none; stroke: #ffd34a; stroke-width: 4; stroke-linecap: round; stroke-dasharray: 0 100; opacity: .9; }
.pb.big.chain { animation: chainPulse .18s ease-out; }
@keyframes chainPulse { 0% { transform: scale(.92); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .pb.big.chain { animation: none; } }
#b-swap { right: 130px; bottom: 6px; }
#b-swap canvas { width: 30px; height: 30px; }
#b-swap small { color: var(--ink); font-size: 10px; max-width: 62px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pb.mend { right: 32px; bottom: 140px; border-color: #8bd06a; background: rgba(30, 60, 20, .7); animation: mend 1s ease-in-out infinite; }
@keyframes mend { 50% { box-shadow: 0 0 14px rgba(140, 210, 100, .7); } }
.pb.small { width: 50px; height: 50px; font-size: 12px; }
#b-rally { right: 172px; bottom: 92px; }
#b-heal { right: 120px; bottom: 112px; border-color: #7be08f; }
#b-fury { right: 158px; bottom: 160px; border-color: #ff8a4a; }
.pad.mend-on #b-heal { right: 112px; bottom: 96px; }
/* a first-meet tip by a control the first time it shows */
.tipb { position: absolute; z-index: 6; margin: 0; padding: 8px 12px; border-radius: 12px; background: #fbf3df; color: #2a1c10;
  font: 700 14px/1.3 'Baloo 2', system-ui, sans-serif; box-shadow: 0 8px 20px -8px rgba(0, 0, 0, .7); pointer-events: none; animation: tipin .25s ease-out; }
.tipb::after { content: ""; position: absolute; right: 22px; bottom: -7px; border: 7px solid transparent; border-bottom: 0; border-top-color: #fbf3df; }
@keyframes tipin { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .tipb { animation: none; } }
/* the Lookout: a map of the field with the keep, the gates and every Jay */
.gates.map { display: block; width: 84px; height: 84px; margin-top: 3px; border-radius: 10px; background: rgba(20, 30, 14, .78); border: 1px solid var(--edge); }
.gates.map canvas { display: block; width: 100%; height: 100%; }
/* gold picked up: the HUD's count jumps */
.gold.bump { display: inline-block; animation: goldbump .28s ease-out; }
@keyframes goldbump { 0% { transform: scale(1.3); color: #fff2b0; } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .gold.bump { animation: none; } }

/* ---------- between waves ---------- */
.brk { position: absolute; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(420px, calc(100% - 24px));
  padding: 10px 12px 12px; border-radius: 18px; background: var(--oak); border: 1px solid var(--edge); text-align: center; z-index: 5; }
.brk-line { margin: 0 0 6px; font-size: 14px; font-weight: 700; color: var(--soft); line-height: 1.3; }
/* the break: only Mend stays on the pad (stand by a hurt gate and hold it while the clock runs) */
body.breaking .pad > :not(.mend) { display: none; }
/* the clock to the next wave: it starts by itself (no start button); the shop, the skill cards and menus stop it */
.brk-count { position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; min-height: 48px; min-width: 150px;
  padding: 0 18px; border-radius: 999px; border: 2px solid #ffe7a0; background: rgba(60, 30, 8, .85); color: #ffe7a0; font-weight: 800; font-size: 17px;
  box-shadow: 0 3px 0 #8a5410; font-variant-numeric: tabular-nums; }
.brk-count span { position: relative; }
.brk-fill { position: absolute; inset: 0; transform-origin: left center; background: linear-gradient(#ffd25a, #e8a020); opacity: .55; }
.brk-count.soon { color: #fff; border-color: #ff9a5a; }
.brk-count.soon .brk-fill { background: linear-gradient(#ff9a5a, #d2502a); }
.brk-count.held { opacity: .8; }

.banner { position: absolute; left: 0; right: 0; top: 28%; display: flex; flex-direction: column; align-items: center; pointer-events: none;
  opacity: 0; transform: scale(.9); transition: opacity .25s, transform .25s; text-align: center; padding: 0 16px; }
.banner.on { opacity: 1; transform: scale(1); }
.banner b { font-size: clamp(30px, 8vw, 56px); line-height: 1; letter-spacing: .05em; text-transform: uppercase; color: #ffe7a0;
  text-shadow: 0 4px 0 #5a3410, 0 0 30px rgba(255, 200, 80, .5); }
.banner.boss b { color: #ff6a4a; text-shadow: 0 4px 0 #300, 0 0 34px rgba(255, 60, 30, .6); }
.banner.good b { color: #b8f27a; text-shadow: 0 4px 0 #1a3a08, 0 0 30px rgba(160, 240, 100, .5); }
.banner span { margin-top: 6px; font-size: 16px; font-weight: 700; color: #fff1d0; text-shadow: 0 2px 0 #000; }

/* ---------- cards ---------- */
.card { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(420px, calc(100% - 24px));
  max-height: calc(100% - 24px); overflow: auto; padding: 18px 16px 16px; border-radius: 20px; background: rgba(42, 28, 16, .96);
  border: 1px solid var(--edge); box-shadow: 0 20px 60px rgba(0, 0, 0, .7); text-align: center; z-index: 20; }
.card .kicker { margin: 0; font-size: 13px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: #ff9a6a; }
.card h2 { margin: 2px 0 10px; font-size: 30px; line-height: 1.1; color: #ffe7a0; }
.picks .kicker { color: #7fc8ff; }
.pick-list { display: grid; gap: 10px; }
.pick { display: flex; gap: 12px; align-items: center; width: 100%; min-height: 72px; padding: 10px 12px; border-radius: 16px; text-align: left;
  border: 2px solid rgba(255, 210, 90, .35); background: rgba(255, 240, 200, .06); color: inherit; font: inherit; }
.pick:active { background: rgba(255, 210, 90, .2); }
.pick .ico { flex: none; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 24px; background: rgba(255, 210, 90, .15); }
.pick b { display: block; font-size: 17px; color: #ffe7a0; }
.pick small { display: block; font-size: 14px; color: var(--soft); line-height: 1.25; }
.pick em { font-style: normal; color: #7fc8ff; font-size: 13px; font-weight: 700; }
.over-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; margin: 0 0 8px; text-align: left; }
.over-stats div { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; padding: 4px 8px; border-radius: 8px; background: rgba(255, 255, 255, .05); }
.over-stats dt { color: var(--soft); } .over-stats dd { margin: 0; font-weight: 800; }
.over-best { margin: 4px 0; color: var(--gold); font-weight: 800; min-height: 1em; }
.over-new { list-style: none; margin: 0 0 8px; padding: 0; color: #7fc8ff; font-weight: 700; font-size: 14px; }
.over-new li.next { color: var(--soft); font-weight: 600; font-size: 13px; }
.btns { display: flex; gap: 10px; justify-content: center; margin-top: 8px; }
.btns.col { flex-direction: column; align-items: stretch; }
.btns.col > .btn { width: 100%; }
.btn { min-height: 48px; min-width: 120px; padding: 0 18px; border-radius: 999px; border: 2px solid rgba(255, 210, 90, .55);
  background: transparent; color: var(--ink); font: 800 16px/1 'Baloo 2', system-ui, sans-serif; flex: 1; }
.btn.primary { background: linear-gradient(#ffd25a, #e8a020); color: #3a2208; border-color: #ffe7a0; box-shadow: 0 3px 0 #8a5410; }

.toast { position: absolute; left: 50%; top: 34%; transform: translate(-50%, 10px); margin: 0; max-width: calc(100% - 32px);
  padding: 8px 14px; border-radius: 999px; background: rgba(30, 18, 8, .88); color: #ffe7a0; font-weight: 700; font-size: 14px; text-align: center;
  opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- the shop ---------- */
.shop { position: absolute; inset: 0; z-index: 30; display: flex; flex-direction: column; background: rgba(30, 20, 10, .97);
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
.shop-top { display: flex; align-items: center; gap: 10px; min-height: 48px; }
.shop-top b { font-size: 22px; color: #ffe7a0; flex: 1; }
.shop-top .gold { font-size: 20px; }
.shop-x { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--edge); background: transparent; color: var(--ink); font: 800 18px/1 system-ui; }
.tabs { display: flex; gap: 6px; margin: 6px 0 8px; overflow-x: auto; scrollbar-width: none; }
.tab { flex: 1; min-height: 44px; padding: 0 10px; border-radius: 12px; border: 2px solid rgba(255, 210, 90, .25); background: transparent; color: var(--soft);
  font: 800 15px/1 'Baloo 2', system-ui, sans-serif; white-space: nowrap; }
.tab.on { background: rgba(255, 210, 90, .18); border-color: var(--gold); color: #ffe7a0; }
.shop-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; display: grid; gap: 8px; align-content: start; touch-action: pan-y; padding-bottom: 8px; }
.sh-h { margin: 6px 2px 0; font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--soft); }
.item { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 14px; background: rgba(255, 240, 200, .05); border: 1px solid rgba(255, 210, 90, .14); }
.item.owned { border-color: rgba(140, 210, 100, .45); }
.item .pic { flex: none; width: 48px; height: 48px; border-radius: 10px; background: rgba(0, 0, 0, .25); display: grid; place-items: center; overflow: hidden; }
.item .pic canvas { width: 48px; height: 48px; }
.item .txt { flex: 1; min-width: 0; }
.item b { display: block; font-size: 16px; color: #ffe7a0; line-height: 1.15; }
.item small { display: block; font-size: 13px; color: var(--soft); line-height: 1.25; }
.item .why { color: #ff9a6a; font-weight: 700; }
.item .buy { flex: none; min-width: 84px; min-height: 44px; padding: 0 10px; border-radius: 12px; border: 2px solid var(--gold); background: linear-gradient(#ffd25a, #e8a020);
  color: #3a2208; font: 800 15px/1 'Baloo 2', system-ui, sans-serif; }
.item .buy:disabled { background: transparent; color: var(--soft); border-color: rgba(255, 255, 255, .2); }
.item .buy.alt { background: transparent; color: #ffe7a0; }
.hands { display: flex; gap: 6px; }
.hands .buy { min-width: 64px; font-size: 13px; }

/* sheets: picking a knight, looks */
.kn-pick { display: grid; gap: 10px; }
.kn-row { display: flex; gap: 10px; align-items: center; min-height: 56px; width: 100%; padding: 6px 12px; border-radius: 14px;
  border: 2px solid rgba(255, 210, 90, .2); background: rgba(255, 240, 200, .04); color: inherit; font: inherit; text-align: left; }
.kn-row.on { border-color: var(--gold); background: rgba(255, 210, 90, .14); }
.kn-row:disabled { opacity: .45; }
.kn-row b { display: block; font-size: 16px; }
.kn-row small { display: block; color: var(--soft); font-size: 13px; line-height: 1.25; }
.kn-row canvas, .kn-row .dot { flex: none; width: 44px; height: 44px; }
.kn-row .dot { border-radius: 50%; border: 2px solid rgba(255, 255, 255, .25); }
.kn-h { margin: 8px 0 0; font-size: 13px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--soft); }
.kn-note { margin: 4px 0 0; font-size: 13px; color: var(--soft); line-height: 1.4; }
.kn-art { width: 100%; height: 100%; object-fit: contain; display: block; }
/* the title's knight: fills the menu's art box exactly (a grid item's % height would follow the canvas's own ratio) */
.kn-art.kn-title { position: absolute; inset: 0; max-width: none; max-height: none; }
kbd { display: inline-block; min-width: 20px; padding: 0 5px; border-radius: 5px; background: rgba(255, 255, 255, .14); font: 700 12px/18px ui-monospace, monospace; text-align: center; }
@media (prefers-reduced-motion: reduce) { .banner, .vignette, .toast { transition: none; } .vignette.low, .pill, .pb.mend { animation: none; } .gates i.hit { animation: none; } }
