/* Spinwood game screen. One warm wooden look on purpose, so every color is set here. */
:root {
  --ink: #2b170b;
  --cream: #fff3dc;
  --paper: #f2d6a8;
  --walnut: #4a2a14;
  --panel: rgba(38, 22, 10, .94);
  --edge: #8a5a2e;
  --red: #e2453c; --red-d: #9e2a22;
  --green: #4fae4a; --green-d: #2c6e2a;
  --gold: #ffd24a;
  --display: 'Lilita One', 'Arial Rounded MT Bold', 'Trebuchet MS', sans-serif;
  --body: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: #1e120a; color: var(--cream); font-family: var(--body); font-weight: 700; overflow: hidden; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
#app { position: fixed; inset: 0; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
#cv { position: absolute; left: 0; right: 0; top: env(safe-area-inset-top, 0px); bottom: env(safe-area-inset-bottom, 0px); width: 100%; height: calc(100% - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); display: block; touch-action: none; }
button { font: inherit; color: inherit; }
button:focus-visible, a:focus-visible, .card:focus-visible, input:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 8px); left: max(10px, env(safe-area-inset-left, 0px)); right: max(10px, env(safe-area-inset-right, 0px)); z-index: 3; pointer-events: none; display: grid; gap: 6px; }
.hrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hearts, .hh { display: flex; gap: 2px; background: rgba(30,16,6,.7); padding: 6px 9px; border-radius: 999px; }
.ht { width: 20px; height: 20px; display: block; }
.hh .ht { width: 18px; height: 18px; }
.mid { flex: 1; min-width: 0; text-align: center; display: flex; flex-direction: column; align-items: center; }
.mid b { font-family: var(--display); font-weight: 400; font-size: 17px; letter-spacing: .02em; text-shadow: 0 2px 0 rgba(0,0,0,.5); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
#hTimer { font-family: var(--display); font-size: 20px; color: var(--gold); text-shadow: 0 2px 0 #3a1d0b; font-variant-numeric: tabular-nums; }
.right { display: flex; gap: 6px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 5px; background: rgba(30,16,6,.72); padding: 6px 10px; border-radius: 999px; font-family: var(--display); font-weight: 400; font-size: 16px; font-variant-numeric: tabular-nums; white-space: nowrap; border: 0; }
.chip svg { display: block; }
.btnlike { pointer-events: auto; cursor: pointer; }
#pauseBtn { width: 36px; justify-content: center; letter-spacing: -1px; }
#bossBar { position: relative; height: 16px; border-radius: 999px; background: rgba(30,16,6,.8); border: 2px solid #3a1d0b; overflow: hidden; max-width: 420px; width: 100%; justify-self: center; }
#bossFill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(#ff7a5a, #c4321e); transition: width .25s; }
#bossHp { position: absolute; inset: 0; text-align: center; font-size: 11px; line-height: 12px; font-weight: 800; text-shadow: 0 1px 0 #000; }
#fx { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; min-height: 0; }
.pill { font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 999px; background: rgba(20,10,4,.75); color: var(--c); border: 1.5px solid var(--c); text-transform: uppercase; letter-spacing: .04em; }
.pill.combo { font-size: 13px; }

/* ---------- spell hand ---------- */
#hand { position: absolute; left: 0; right: 0; bottom: env(safe-area-inset-bottom, 0px); z-index: 3; padding: 4px max(8px, env(safe-area-inset-right, 0px)) 8px max(8px, env(safe-area-inset-left, 0px)); display: grid; gap: 4px; justify-items: center; }
#manaOrbs { display: flex; gap: 6px; }
.mo { width: 16px; height: 16px; border-radius: 50%; background: rgba(20,10,30,.7); border: 2px solid #6a4a9a; display: grid; place-items: center; overflow: hidden; }
.mo > i { width: 100%; height: 100%; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #f0e0ff, #9a6bdf 60%, #5a2e8a); transform: scale(0); transition: transform .1s linear; }
.mo.full { border-color: #d9c2ff; box-shadow: 0 0 8px #b38bff; }
#handCards { display: flex; gap: 6px; justify-content: center; max-width: 100%; }
.handempty { font-size: 12px; opacity: .7; padding: 30px 0; }

/* ---------- cards ---------- */
.card { position: relative; width: 84px; height: 98px; flex: 0 1 84px; min-width: 64px; border-radius: 10px; padding: 4px 5px 5px; display: flex; flex-direction: column; align-items: center; text-align: center; cursor: pointer; pointer-events: auto;
  background: linear-gradient(180deg, var(--sc) 0 38%, #f6e3bf 38% 100%); border: 2.5px solid var(--sd); color: var(--ink); box-shadow: 0 4px 0 var(--sd), 0 6px 14px rgba(0,0,0,.35); transition: transform .12s, filter .15s; }
.card .cost { position: absolute; top: -7px; left: -7px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-family: var(--display); font-size: 15px; color: #fff; background: radial-gradient(circle at 35% 35%, #d9c2ff, #7a4ac0 70%); border: 2px solid #3a2163; text-shadow: 0 1px 0 #000; }
.card .art { height: 34px; display: grid; place-items: center; filter: drop-shadow(0 2px 0 rgba(0,0,0,.3)); }
.card .nm { font-family: var(--display); font-weight: 400; font-size: 12.5px; line-height: 1.05; margin-top: 3px; }
.card .tx { font-size: 9.5px; line-height: 1.15; font-weight: 700; margin-top: 2px; opacity: .85; }
.card.r-rare { box-shadow: 0 4px 0 var(--sd), 0 0 0 2px #ffd24a, 0 6px 14px rgba(0,0,0,.35); }
.card.ok:active { transform: translateY(3px); }
.card.ok { animation: ready .25s; }
.card.poor { filter: grayscale(.75) brightness(.7); }
.card.shake { animation: shake .3s; }
.card.sold { opacity: .3; pointer-events: none; }
.card.big { width: 140px; height: auto; min-height: 168px; flex: 0 0 140px; padding: 8px 8px 10px; }
.card.big .art { height: 52px; }
.card.big .nm { font-size: 16px; }
.card.big .tx { font-size: 12px; margin-top: 4px; }
.card .meta { margin-top: auto; padding-top: 6px; font-size: 9.5px; text-transform: uppercase; letter-spacing: .08em; opacity: .6; }
.card .price, .relic .price { position: absolute; bottom: -10px; left: 50%; transform: translateX(-50%); background: var(--gold); color: var(--ink); font-family: var(--display); font-size: 14px; padding: 2px 10px; border-radius: 999px; border: 2px solid #8a5a10; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes ready { from { transform: translateY(6px); } }
@media (min-width: 520px) { .card { width: 96px; height: 110px; flex-basis: 96px; } .card .tx { font-size: 10.5px; } .card .nm { font-size: 14px; } }

/* ---------- banner ---------- */
#banner { position: absolute; left: 0; right: 0; top: 34%; text-align: center; pointer-events: none; z-index: 4; opacity: 0; transform: scale(.7); transition: opacity .25s, transform .35s cubic-bezier(.2,1.6,.4,1); padding: 0 16px; }
#banner.show { opacity: 1; transform: none; }
#banner h2 { font-family: var(--display); font-weight: 400; font-size: clamp(36px, 10vw, 60px); line-height: 1; margin: 0; color: var(--cream); text-shadow: 0 4px 0 #3a1d0b, 0 0 24px rgba(0,0,0,.5); text-wrap: balance; }
#banner p { display: inline-block; margin: 10px 0 0; background: rgba(30,16,6,.75); padding: 6px 14px; border-radius: 999px; font-weight: 800; }

/* ---------- panels ---------- */
#overlay { position: absolute; inset: 0; z-index: 10; display: grid; place-items: center; background: rgba(15,8,3,.45); padding: calc(env(safe-area-inset-top, 0px) + 12px) max(12px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 12px) max(12px, env(safe-area-inset-left, 0px)); }
.panel { width: 100%; max-width: 520px; max-height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; background: var(--panel); border: 3px solid var(--edge); border-radius: 22px; padding: 20px 18px 22px; box-shadow: 0 18px 50px rgba(0,0,0,.55); user-select: text; -webkit-user-select: text; }
.panel.wide { max-width: 860px; }
.panel.map { max-width: 600px; }
.panel h1, .panel h2, .panel h3 { font-family: var(--display); font-weight: 400; margin: 0; text-wrap: balance; letter-spacing: .01em; }
.panel h1 { font-size: clamp(30px, 8vw, 44px); text-align: center; }
.panel h2 { font-size: 28px; text-align: center; }
.panel h3 { font-size: 18px; margin: 20px 0 10px; color: var(--paper); }
.lede { text-align: center; margin: 8px auto 14px; max-width: 46ch; line-height: 1.45; font-weight: 600; color: #f0dcc0; }
.small { font-size: 13px; opacity: .75; font-weight: 600; line-height: 1.4; }
.btnrow { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.btn { font-family: var(--display); font-weight: 400; font-size: 20px; letter-spacing: .02em; border: 0; border-radius: 14px; padding: 11px 26px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn.go { background: var(--red); color: #fff; box-shadow: 0 5px 0 var(--red-d); }
.btn.ghost { background: transparent; color: var(--cream); box-shadow: inset 0 0 0 2.5px var(--edge); }
.btn.small { font-size: 15px; padding: 8px 14px; background: #6a4424; color: var(--cream); box-shadow: 0 3px 0 #3a2210; }
.btn:active { transform: translateY(3px); }
.btn:disabled { opacity: .4; cursor: default; transform: none; }
.link { color: var(--paper); text-decoration: none; font-size: 14px; }
.topline { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.dust { display: inline-flex; align-items: center; gap: 5px; color: #d9c2ff; font-size: 14px; }
.dust.big { display: flex; justify-content: center; font-family: var(--display); font-size: 22px; font-weight: 400; margin: 4px 0 12px; }

.lvl { display: grid; justify-items: center; gap: 5px; margin: 10px auto 14px; max-width: 320px; }
.lvl b { font-family: var(--display); font-weight: 400; font-size: 17px; }
.bar { width: 100%; height: 12px; border-radius: 999px; background: rgba(0,0,0,.45); overflow: hidden; border: 1.5px solid var(--edge); }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #9a6bdf, #d9c2ff); }
.lvl small { font-size: 12px; opacity: .75; }

.wizgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.wiz { position: relative; display: flex; gap: 10px; align-items: center; text-align: left; padding: 8px 10px; border-radius: 16px; border: 2.5px solid #5a3a1e; background: rgba(90,58,30,.35); cursor: pointer; }
.wiz.sel { border-color: var(--gold); background: rgba(255,210,74,.12); box-shadow: 0 0 0 3px rgba(255,210,74,.25); }
.wiz.locked { opacity: .55; cursor: default; }
.wiz .pf { width: 76px; height: 76px; flex: none; border-radius: 12px; background: radial-gradient(circle at 50% 70%, rgba(255,240,200,.18), transparent 70%); }
.wt { display: grid; gap: 1px; min-width: 0; }
.wt b { font-family: var(--display); font-weight: 400; font-size: 19px; }
.wt small { font-size: 12px; opacity: .7; }
.wt em { font-style: normal; font-size: 12.5px; line-height: 1.3; margin-top: 3px; font-weight: 600; }
.ws { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.ws .ht { width: 14px; height: 14px; }
.mana { display: flex; gap: 3px; }
.mana i { width: 11px; height: 11px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #f0e0ff, #9a6bdf 60%, #5a2e8a); }
.lk { position: absolute; top: 8px; right: 10px; }
.heat { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; margin-top: 14px; }
.heat > span { font-family: var(--display); font-size: 17px; }
.hb { width: 36px; height: 36px; border-radius: 10px; border: 2px solid var(--edge); background: rgba(0,0,0,.3); cursor: pointer; font-family: var(--display); font-size: 17px; }
.hb.sel { background: #e8553a; border-color: #ffb347; }
.heat small { flex-basis: 100%; text-align: center; font-size: 12px; opacity: .7; }

.uplist { display: grid; gap: 8px; }
.up { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: rgba(90,58,30,.35); }
.up > span { display: grid; gap: 2px; }
.up b { font-family: var(--display); font-weight: 400; font-size: 17px; }
.up small { font-size: 13px; opacity: .8; }
.pips { display: flex; gap: 4px; margin-top: 3px; }
.pips i { width: 14px; height: 6px; border-radius: 3px; background: rgba(0,0,0,.45); }
.pips i.on { background: #d9c2ff; }
.maxed { font-family: var(--display); color: #9fe39a; }

/* map */
.maphead { text-align: center; padding: 4px 0 8px; }
.maphead small { text-transform: uppercase; letter-spacing: .12em; font-size: 11px; color: var(--ac); }
.maphead p { margin: 6px auto 0; max-width: 42ch; font-size: 13.5px; line-height: 1.4; font-weight: 600; opacity: .85; }
.statbar { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 10px 0; }
.statbar .chip { background: rgba(0,0,0,.35); font-size: 15px; padding: 6px 9px; }
.relicrow { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-bottom: 6px; }
.rchip { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,210,74,.12); border: 1.5px solid #8a6a2a; }
.pick { text-align: center; font-size: 13px; opacity: .75; margin: 6px 0 8px; }
.maprows { display: grid; gap: 8px; }
.mrow { display: flex; align-items: stretch; gap: 8px; }
.rn { width: 34px; flex: none; display: grid; place-items: center; font-family: var(--display); font-size: 14px; color: var(--paper); opacity: .7; }
.nodes { flex: 1; min-width: 0; display: grid; grid-template-columns: repeat(var(--n, 2), minmax(0, 1fr)); gap: 8px; }
@media (max-width: 560px) { .node { flex-direction: column; text-align: center; padding: 8px 6px; gap: 4px; } .nt small { font-size: 11px; } .rn { width: 22px; } }
.node { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 14px; border: 2.5px solid transparent; background: rgba(90,58,30,.4); text-align: left; cursor: pointer; min-width: 0; }
.node .ni { width: 38px; height: 38px; flex: none; border-radius: 12px; display: grid; place-items: center; background: var(--nc, #6a4424); box-shadow: inset 0 -3px 0 rgba(0,0,0,.25); }
.nt { display: grid; min-width: 0; }
.nt b { font-family: var(--display); font-weight: 400; font-size: 16px; }
.nt small { font-size: 11.5px; line-height: 1.25; opacity: .75; font-weight: 600; }
.t-round { --nc: #8a5a2e; } .t-elite { --nc: #b8321e; } .t-bonus { --nc: #d9a514; } .t-shop { --nc: #2d8a9e; } .t-rest { --nc: #e8742c; } .t-event { --nc: #7a4ac0; } .t-boss { --nc: #3a1d0b; }
.t-boss .ni { box-shadow: 0 0 0 2px var(--gold); }
.mrow.now .node { border-color: rgba(255,210,74,.6); animation: glow 1.6s ease-in-out infinite; }
.mrow.now .node:hover { background: rgba(255,210,74,.18); }
.mrow.done .node, .mrow.later .node { cursor: default; }
.mrow.done .node:not(.chosen) { opacity: .3; }
.mrow.done .node.chosen { border-color: rgba(159,227,154,.5); }
.mrow.later .node { opacity: .55; }
@keyframes glow { 50% { box-shadow: 0 0 0 4px rgba(255,210,74,.18); } }
@media (prefers-reduced-motion: reduce) { .mrow.now .node, .card.ok { animation: none; } #banner { transition: opacity .2s; } }

/* intro */
.panel.intro { text-align: center; }
.panel.intro p { line-height: 1.45; font-weight: 600; }
.trick { background: rgba(255,210,74,.1); border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.mods { list-style: none; padding: 0; display: grid; gap: 6px; text-align: left; }
.mods li { background: rgba(184,50,30,.25); padding: 8px 12px; border-radius: 10px; font-size: 14px; font-weight: 600; }
.mods b { font-family: var(--display); font-weight: 400; margin-right: 6px; }
.bosspf { display: block; margin: 6px auto 0; width: 140px; }

/* rewards, shop */
.cardgrid { display: flex; flex-wrap: wrap; gap: 16px 12px; justify-content: center; padding: 8px 0 6px; }
.relicgrid { display: grid; gap: 10px; }
.relic { position: relative; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: rgba(255,210,74,.08); border: 2px solid #6a4a1a; text-align: left; }
.relic.pickable { cursor: pointer; }
.relic.pickable:hover { border-color: var(--gold); }
.relic .ri { width: 42px; height: 42px; flex: none; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle at 40% 35%, #8a5a2e, #3a2210); border: 2px solid #c99a3a; }
.relic b { font-family: var(--display); font-weight: 400; font-size: 17px; display: block; }
.relic small { font-size: 13px; font-weight: 600; opacity: .8; }
.relic .price { left: auto; right: 12px; bottom: auto; top: 50%; transform: translateY(-50%); }
.relic.sold { opacity: .3; pointer-events: none; }
.relic.poor { opacity: .6; }
.services { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.choices { display: grid; gap: 10px; margin-top: 12px; }
.choice { display: grid; gap: 3px; text-align: left; padding: 14px 16px; border-radius: 14px; border: 2.5px solid var(--edge); background: rgba(90,58,30,.35); cursor: pointer; }
.choice b { font-family: var(--display); font-weight: 400; font-size: 19px; }
.choice small { font-size: 13px; opacity: .8; font-weight: 600; }
.choice:hover:not(:disabled) { border-color: var(--gold); }
.choice:disabled { opacity: .4; }
.choice.danger { border-color: #8a2a1e; }
.forkgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.fork { display: grid; gap: 6px; text-align: left; padding: 0 0 14px; border-radius: 16px; overflow: hidden; border: 2.5px solid var(--edge); background: rgba(90,58,30,.35); cursor: pointer; }
.fork:hover { border-color: var(--ac); }
.fork .sw { height: 70px; background: linear-gradient(180deg, var(--s2), var(--s1) 70%, var(--h) 70%); }
.fork b, .fork small, .fork em { padding: 0 14px; }
.fork b { font-family: var(--display); font-weight: 400; font-size: 20px; }
.fork small { font-size: 13px; opacity: .8; }
.fork em { font-style: normal; font-size: 13px; color: var(--ac); font-weight: 700; line-height: 1.35; }
.summary { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 14px 0; }
.summary span { display: inline-flex; align-items: center; gap: 6px; background: rgba(0,0,0,.3); padding: 7px 12px; border-radius: 999px; font-size: 14px; }

/* game over */
.over { text-align: center; display: grid; justify-items: center; }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: 11px; opacity: .7; }
.over h1 { font-size: 54px; color: var(--cream); text-shadow: 0 4px 0 #3a1d0b; }
.over.won h1 { color: var(--gold); }
.over .pf { width: 96px; height: 96px; margin: 4px 0; }
.bigscore { display: grid; }
.bigscore small { text-transform: uppercase; letter-spacing: .12em; font-size: 11px; opacity: .7; }
.bigscore b { font-family: var(--display); font-weight: 400; font-size: 48px; line-height: 1; font-variant-numeric: tabular-nums; }
.ups { list-style: none; padding: 0; margin: 4px 0; display: grid; gap: 6px; }
.ups li { background: rgba(154,107,223,.2); border: 1.5px solid #9a6bdf; padding: 8px 14px; border-radius: 12px; font-size: 14px; line-height: 1.4; }
.ups b { font-family: var(--display); font-weight: 400; font-size: 17px; color: #e0c8ff; }
.heatnew { color: #ffb347; font-family: var(--display); font-size: 18px; margin: 6px 0; }
.nameform { display: grid; gap: 6px; margin-top: 10px; width: 100%; max-width: 360px; }
.nameform label { font-size: 13px; opacity: .8; }
.nameform div { display: flex; gap: 8px; }
.nameform input { flex: 1; min-width: 0; width: 0; font: inherit; font-size: 18px; padding: 10px 12px; border-radius: 12px; border: 2.5px solid var(--edge); background: #f6e3bf; color: var(--ink); }
.nameform .btn { font-size: 17px; padding: 10px 14px; }
.saved { color: #9fe39a; font-family: var(--display); font-size: 18px; margin: 10px 0 0; }
