:root {
  --bg: #0f1b2d;
  --panel: #1b2a41;
  --panel-2: #24364f;
  --line: rgba(255, 255, 255, 0.08);
  --text: #eef3ff;
  --muted: #9fb0c8;
  --accent: #ffb02e;
  --accent-2: #ff8a2e;
  --good: #4cd964;
  --bad: #ff5a5a;
  --gem: #a58cff;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --nav-h: 64px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  position: fixed; inset: 0; overflow: hidden;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 15px; line-height: 1.35;
  overscroll-behavior: none; -webkit-user-select: none; user-select: none;
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; }
b { font-weight: 700; }
h2, h3 { margin: 0; }
p { margin: 8px 0; }
svg { display: inline-block; vertical-align: middle; }

#app { position: absolute; inset: 0; overflow: hidden; }
#island { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ---------- HUD ---------- */
#hud {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  padding: calc(var(--sat) + 8px) calc(var(--sar) + 10px) 8px calc(var(--sal) + 10px);
  display: flex; align-items: center; gap: 8px;
  background: linear-gradient(to bottom, rgba(6, 14, 28, 0.9), rgba(6, 14, 28, 0.45) 70%, transparent);
  pointer-events: none;
}
#hud > * { pointer-events: auto; }
.player { position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 6px 10px; min-width: 74px; }
.lvl-badge { font-weight: 800; font-size: 14px; color: var(--accent); white-space: nowrap; }
.xpbar { display: block; height: 6px; background: rgba(255, 255, 255, 0.12); border-radius: 3px; overflow: hidden; }
.xpbar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #4fc3ff, #7ee0ff); border-radius: 3px; transition: width 0.4s; }
.badge { position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--bad); color: #fff; font-size: 12px; font-weight: 800; line-height: 20px; text-align: center; border: 2px solid #0f1b2d; }
.resources { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.res { display: flex; align-items: center; gap: 5px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px 6px 7px; font-weight: 700; font-size: 14px; position: relative; }
.res svg { width: 20px; height: 20px; }
.res small { position: absolute; right: 10px; bottom: -13px; font-size: 10px; color: #ffe082; font-weight: 600; text-shadow: 0 1px 2px #000; }

#side-buttons { position: absolute; right: calc(var(--sar) + 10px); top: calc(var(--sat) + 74px); z-index: 4; display: flex; flex-direction: column; gap: 10px; }
.round-btn { width: 46px; height: 46px; border-radius: 50%; background: var(--panel); border: 1px solid var(--line); display: grid; place-items: center; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35); position: relative; }
.round-btn svg { width: 26px; height: 26px; }
.round-btn.ready::after { content: ''; position: absolute; top: 2px; right: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--bad); border: 2px solid var(--panel); animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: 0.35; } }

.a2hs { position: absolute; left: 10px; right: 10px; bottom: calc(var(--nav-h) + var(--sab) + 10px); z-index: 6; background: #fff3cd; color: #4a3600; border-radius: 12px; padding: 10px 12px; display: flex; align-items: center; gap: 8px; font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,.3); }
.a2hs .icon-btn { color: #4a3600; }

/* ---------- bottom nav ---------- */
#bottom-nav {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; padding: 6px calc(var(--sar) + 6px) calc(var(--sab) + 6px) calc(var(--sal) + 6px);
  background: linear-gradient(to top, #0a1424 70%, rgba(10, 20, 36, 0.85)); border-top: 1px solid var(--line);
}
#bottom-nav button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; background: none; border: 0; border-radius: 12px; color: var(--muted); font-size: 10px; font-weight: 700; min-width: 0; }
#bottom-nav button svg { width: 26px; height: 26px; }
#bottom-nav button:active { background: rgba(255, 255, 255, 0.08); color: #fff; }
body.placing #bottom-nav { opacity: 0.3; pointer-events: none; }

#placement-bar { position: absolute; left: 10px; right: 10px; bottom: calc(var(--nav-h) + var(--sab) + 12px); z-index: 7; display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
#placement-bar[hidden] { display: none; }
.pl-text { flex: 1; text-align: center; }
.pl-name { font-weight: 800; }
.pl-hint { font-size: 12px; color: var(--muted); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font-weight: 700; cursor: pointer; transition: transform 0.08s, filter 0.15s; }
.btn:active { transform: scale(0.97); filter: brightness(1.15); }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn.primary { background: linear-gradient(180deg, #ffc857, var(--accent-2)); color: #3a2000; border-color: #ffd97a; box-shadow: 0 3px 0 #b85c10; }
.btn.ghost { background: transparent; }
.btn.danger { color: #ff8080; border-color: rgba(255, 90, 90, 0.4); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.btn.wide { width: 100%; }
.btn.grow { flex: 1; }
.btn .elicon, .btn svg { width: 16px; height: 16px; }
.icon-btn { background: none; border: 0; color: var(--text); font-size: 26px; line-height: 1; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; }
.icon-btn.tiny { width: 30px; height: 30px; font-size: 16px; background: var(--panel-2); }
.link { background: none; border: 0; color: #7ecbff; text-decoration: underline; font-weight: 600; padding: 0; }

/* ---------- modals ---------- */
#modal-root { position: absolute; inset: 0; z-index: 20; pointer-events: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(4, 10, 22, 0); display: flex; align-items: flex-end; justify-content: center; pointer-events: auto; transition: background 0.2s; }
.modal-backdrop.open { background: rgba(4, 10, 22, 0.55); }
.modal-backdrop.closing { background: rgba(4, 10, 22, 0); }
.sheet { width: 100%; max-width: 560px; max-height: calc(100% - var(--sat) - 40px); background: var(--panel); border-radius: 22px 22px 0 0; display: flex; flex-direction: column; transform: translateY(40px); opacity: 0; transition: transform 0.22s ease-out, opacity 0.2s; box-shadow: 0 -10px 40px rgba(0,0,0,.5); }
.sheet.full { height: calc(100% - var(--sat) - 40px); }
.modal-backdrop.open .sheet { transform: translateY(0); opacity: 1; }
.modal-backdrop.closing .sheet { transform: translateY(40px); opacity: 0; }
.modal-backdrop.center { align-items: center; padding: 16px; }
.modal-backdrop.center .sheet { border-radius: 20px; max-height: calc(100% - 32px); transform: scale(0.94); }
.modal-backdrop.center.open .sheet { transform: scale(1); }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 14px 8px 8px 18px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { flex: 1; font-size: 19px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 14px calc(var(--sab) + 16px); flex: 1; }
.modal-backdrop.center .sheet-body { padding-bottom: 16px; }
.celebrate .sheet { border: 2px solid var(--accent); box-shadow: 0 0 40px rgba(255, 176, 46, 0.35); }
.dialog-text { font-size: 15px; }
.reward-line { font-size: 17px; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---------- toasts ---------- */
#toast-root { position: absolute; bottom: calc(var(--nav-h) + var(--sab) + 14px); left: 0; right: 0; z-index: 30; display: flex; flex-direction: column-reverse; align-items: center; gap: 6px; pointer-events: none; }
.toast { background: rgba(20, 32, 52, 0.95); border: 1px solid var(--line); color: #fff; padding: 9px 14px; border-radius: 12px; font-weight: 600; font-size: 14px; max-width: 92%; text-align: center; opacity: 0; transform: translateY(8px); transition: all 0.25s; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.good { border-color: rgba(76, 217, 100, 0.5); }
.toast.bad { border-color: rgba(255, 90, 90, 0.6); background: rgba(70, 20, 25, 0.95); }
.toast svg { width: 16px; height: 16px; }

/* ---------- lists & cards ---------- */
.tabs { display: flex; gap: 4px; background: rgba(0,0,0,.25); border-radius: 12px; padding: 4px; margin-bottom: 10px; overflow-x: auto; }
.tab { flex: 1; min-height: 38px; border: 0; background: transparent; color: var(--muted); border-radius: 9px; font-weight: 700; font-size: 13px; white-space: nowrap; padding: 0 10px; }
.tab.active { background: var(--panel-2); color: #fff; }
.card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin: 10px 0; }
.card h3 { margin-bottom: 6px; }
.row { display: flex; align-items: center; }
.row.gap { gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.center { justify-content: center; }
.center-text { text-align: center; }
.hint { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); font-weight: 500; }
.bad { color: var(--bad); }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: rgba(255,255,255,.12); }
.tag.good { background: rgba(76, 217, 100, 0.25); color: #9ef0a8; }
.group-title { font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin: 14px 0 6px; }
.cost { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; }
.cost svg { width: 16px; height: 16px; }
.cost.no { color: var(--bad); }
.cost.free { color: var(--good); }
.elbadge { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--el, #666); vertical-align: middle; margin-right: 2px; }
.elbadge.phys { background: #6b7a8c; color: #fff; font-size: 14px; }
.badges { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin: 3px 0; }
.badges.center { justify-content: center; }
.rarity { font-size: 12px; font-weight: 700; }
.list-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 8px 10px; margin: 6px 0; color: var(--text); }
.list-item.tappable:active { filter: brightness(1.15); }
.list-item.selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.list-item.locked { opacity: 0.55; }
.list-item.empty { border-style: dashed; background: transparent; }
.list-item .thumb { width: 66px; height: 66px; flex: none; display: grid; place-items: center; }
.list-item .thumb svg { width: 100%; height: 100%; }
.list-item .thumb.egg svg { width: 42px; height: 50px; }
.list-item .info { flex: 1; min-width: 0; }
.list-item .name { font-weight: 800; font-size: 15px; }
.list-item .desc { color: var(--muted); font-size: 12px; }
.list-item .meta { font-size: 12px; color: var(--muted); margin-top: 2px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chev { color: var(--muted); font-size: 24px; }
.pick-mark { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #3a2000; font-weight: 800; display: grid; place-items: center; }
.list-item:not(.selected) .pick-mark { background: rgba(255,255,255,.1); }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 10px 0; }
.stat-grid div { background: rgba(0,0,0,.2); border-radius: 10px; padding: 8px; font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }
.stat-grid b { color: #fff; font-size: 14px; }
.level-row { text-align: center; margin: 8px 0 4px; font-size: 16px; }
.dragon-hero { display: flex; justify-content: center; }
.dragon-hero svg { width: 170px; height: 170px; filter: drop-shadow(0 8px 12px rgba(0,0,0,.4)); }
.dragon-hero.unknown svg { filter: brightness(0.15) saturate(0) drop-shadow(0 0 0 #000); opacity: .8; }
.moves-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.move-chip { background: rgba(0,0,0,.2); border-radius: 999px; padding: 4px 10px 4px 6px; font-size: 13px; display: inline-flex; align-items: center; gap: 4px; }
.big-icon { font-size: 48px; text-align: center; margin: 6px 0; }
.big-icon svg { width: 56px; height: 56px; }
.timer { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; margin: 6px 0; }
.input { -webkit-user-select: text; user-select: text; width: 100%; background: rgba(0,0,0,.3); border: 1px solid var(--line); color: #fff; border-radius: 10px; padding: 10px; font-size: 16px; margin-bottom: 10px; }
.input.code { height: 120px; font-family: ui-monospace, Menlo, monospace; font-size: 11px; word-break: break-all; }
textarea.input { resize: none; }
.howto { padding-left: 4px; list-style: none; margin: 10px 0; }
.howto li { margin: 8px 0; display: flex; gap: 8px; align-items: flex-start; }
.howto li svg { flex: none; margin-top: 2px; }
.actions-row { margin-top: 14px; }
.sticky-bottom { position: sticky; bottom: 0; padding-top: 10px; background: linear-gradient(to top, var(--panel) 70%, transparent); }

.bar { height: 10px; background: rgba(0,0,0,.35); border-radius: 5px; overflow: hidden; margin: 6px 0; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #4fc3ff, #7ee0ff); border-radius: 5px; transition: width 0.4s; }
.bar.gold .bar-fill { background: linear-gradient(90deg, #ffb02e, #ffe082); }
.bar.time .bar-fill { background: linear-gradient(90deg, #7c4dff, #b39dff); }
.bar.xp .bar-fill { background: linear-gradient(90deg, #4fc3ff, #7ee0ff); }
.bar.hp { height: 12px; }
.bar.hp .bar-fill.ok { background: linear-gradient(90deg, #43d16b, #8ef0a8); }
.bar.hp .bar-fill.warn { background: linear-gradient(90deg, #ffb02e, #ffe082); }
.bar.hp .bar-fill.low { background: linear-gradient(90deg, #ff4d4d, #ff9a9a); }
.bar.hp.mini { height: 6px; margin: 4px 0 0; }

/* dragon book grid */
.grid-book { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.book-cell { background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 6px 4px; color: var(--text); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.book-cell .thumb svg { width: 64px; height: 64px; }
.book-cell.unknown .thumb svg { filter: brightness(0.12) saturate(0); opacity: .75; }
.cell-name { font-size: 11px; font-weight: 700; text-align: center; }

/* breeding */
.breed-stage { display: flex; align-items: center; justify-content: space-around; gap: 6px; padding: 12px 0; }
.parent { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 120px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 16px; padding: 8px 4px; color: var(--text); }
.parent svg { width: 90px; height: 90px; }
.parent.pick { border-style: dashed; min-height: 130px; justify-content: center; }
.parent .plus { font-size: 40px; color: var(--muted); }
.parent .cap { font-size: 12px; font-weight: 700; text-align: center; }
.heart-big { display: grid; place-items: center; }
.heart-big svg { width: 44px; height: 44px; }
.heart-big.pulse svg { animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.2); } }
.outcomes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.outcome { display: flex; align-items: center; gap: 6px; background: var(--panel-2); border-radius: 12px; padding: 6px; }
.outcome .thumb svg { width: 48px; height: 48px; }
.outcome.unknown .thumb svg { filter: brightness(0.12) saturate(0); opacity: .8; }
.outcome .name { font-size: 12px; font-weight: 700; }
.outcome .info { min-width: 0; }

/* campaign */
.stage-num { width: 34px; height: 34px; border-radius: 50%; background: rgba(0,0,0,.3); display: grid; place-items: center; font-weight: 800; flex: none; }
.stage.done .stage-num { background: var(--good); color: #063; }
.stage.next .stage-num { background: var(--accent); color: #3a2000; }
.stage.boss { border-color: rgba(255, 90, 90, 0.5); }
.stage.locked { opacity: 0.5; }
.team-preview { display: flex; gap: 6px; margin: 4px 0; flex-wrap: wrap; }
.team-preview .mini { position: relative; display: inline-flex; flex-direction: column; align-items: center; }
.team-preview .mini svg { width: 34px; height: 34px; }
.team-preview .mini i { position: absolute; right: -4px; bottom: 10px; font-style: normal; font-size: 10px; font-weight: 800; background: #000a; border-radius: 6px; padding: 0 4px; }
.team-preview.big .mini svg { width: 56px; height: 56px; }
.team-preview.big .mini i { bottom: 16px; }
.team-preview .mini em { font-style: normal; font-size: 10px; color: var(--muted); }
.team-preview .mini.dim { filter: brightness(0.3) saturate(0.3); }

/* ---------- battle screen ---------- */
#battle-root { position: absolute; inset: 0; z-index: 15; }
#battle-root[hidden] { display: none; }
.battle-screen { position: absolute; inset: 0; display: flex; flex-direction: column; background: radial-gradient(ellipse at 50% 30%, #2f4a72, #101c30 70%); }
.battle-head { display: flex; align-items: center; gap: 10px; padding: calc(var(--sat) + 10px) 12px 8px; font-weight: 800; }
.battle-head .title { flex: 1; }
.battle-head .round { color: var(--muted); font-size: 13px; }
.battle-field { flex: 1; position: relative; min-height: 220px; overflow: hidden; }
.battle-field::before { content: ''; position: absolute; left: -20%; right: -20%; bottom: 8%; height: 40%; background: radial-gradient(ellipse at center, #3f6b4a 0%, #2c4a3a 45%, transparent 70%); opacity: .8; }
.fighter { position: absolute; width: 50%; display: flex; flex-direction: column; }
.fighter.enemy { top: 4%; right: 2%; align-items: flex-end; }
.fighter.player { bottom: 2%; left: 2%; align-items: flex-start; }
.hp-box { background: rgba(8, 16, 30, 0.85); border: 1px solid var(--line); border-radius: 12px; padding: 6px 10px; width: 100%; max-width: 210px; }
.hp-name { font-weight: 800; font-size: 13px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.hp-name .lv { color: var(--muted); font-weight: 600; }
.hp-name .elbadge { width: 18px; height: 18px; }
.hp-num { font-size: 11px; color: var(--muted); text-align: right; }
.sprite-wrap { position: relative; width: 170px; height: 170px; }
.fighter.enemy .sprite-wrap { width: 150px; height: 150px; margin-right: 10px; }
.sprite-wrap .shadow { position: absolute; left: 20%; right: 20%; bottom: 6px; height: 18px; background: rgba(0,0,0,.35); border-radius: 50%; filter: blur(3px); }
.sprite { position: absolute; inset: 0; transition: opacity .3s, transform .3s; }
.sprite svg { width: 100%; height: 100%; }
.sprite.enter { animation: enter .5s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(20px) scale(.8); } }
.sprite.lunge-right { animation: lungeR .5s ease-in-out; }
.sprite.lunge-left { animation: lungeL .5s ease-in-out; }
@keyframes lungeR { 40% { transform: translate(60px, -30px) scale(1.05); } }
@keyframes lungeL { 40% { transform: translate(-60px, 30px) scale(1.05); } }
.sprite.shake { animation: shake .45s; }
@keyframes shake { 20% { transform: translateX(-10px); filter: brightness(2); } 40% { transform: translateX(10px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(6px); } }
.sprite.faint { opacity: 0; transform: translateY(40px) rotate(15deg); }
.dmg { position: absolute; left: 50%; top: 30%; transform: translateX(-50%); font-weight: 900; font-size: 26px; color: #fff; text-shadow: 0 2px 4px #000, 0 0 8px #000; animation: rise .9s ease-out forwards; pointer-events: none; }
.dmg.super { color: #ffd54f; font-size: 32px; }
.dmg.crit { color: #ff5252; font-size: 36px; }
.dmg.weak { color: #9fb0c8; font-size: 22px; }
.dmg.miss { color: #cfd8dc; font-size: 20px; }
@keyframes rise { to { transform: translate(-50%, -60px); opacity: 0; } }
.battle-log { padding: 8px 14px; font-weight: 600; min-height: 40px; background: rgba(8, 16, 30, 0.7); border-top: 1px solid var(--line); font-size: 14px; }
.battle-controls { background: #0c1628; padding: 8px 10px calc(var(--sab) + 10px); }
.moves { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.move-btn { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 54px; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--line); border-left: 5px solid var(--el); background: var(--panel-2); color: var(--text); text-align: left; }
.move-btn:disabled { opacity: .5; }
.move-btn.super { background: linear-gradient(180deg, #3b4b2e, #24364f); border-color: #9ef0a8; }
.move-btn.weak { opacity: .8; }
.mv-name { font-weight: 800; font-size: 14px; display: flex; align-items: center; gap: 4px; }
.mv-name .elbadge { width: 18px; height: 18px; }
.mv-meta { font-size: 11px; color: var(--muted); }
.move-btn.super .mv-meta { color: #9ef0a8; }
.team-row { display: flex; gap: 8px; margin-top: 8px; justify-content: center; }
.team-btn { width: 64px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 4px; display: flex; flex-direction: column; align-items: center; }
.team-btn svg { width: 40px; height: 40px; }
.team-btn .bar { width: 100%; }
.team-btn.active { border-color: var(--accent); }
.team-btn.ko { opacity: .4; }
.team-btn.ko svg { filter: saturate(0); }
.result-art { display: flex; justify-content: center; }
.result-art svg { width: 130px; height: 130px; }

@media (min-width: 700px) {
  .sheet { border-radius: 22px; margin-bottom: 20px; }
}

/* ---------- expansion: events, friends, tower, stars ---------- */
.event-banner { position: absolute; left: 10px; top: calc(var(--sat) + 62px); z-index: 4; display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; background: rgba(10, 20, 36, 0.85); border: 1px solid var(--el, var(--accent)); color: #fff; font-size: 12px; font-weight: 600; white-space: nowrap; max-width: calc(100% - 90px); overflow: hidden; text-overflow: ellipsis; box-shadow: 0 4px 12px rgba(0,0,0,.35); }
.event-banner:empty { display: none; }
.stars { color: #ffd54f; font-size: 12px; letter-spacing: -1px; text-shadow: 0 1px 2px rgba(0,0,0,.5); }
.mono { font-family: ui-monospace, Menlo, monospace; letter-spacing: 1px; }
.small { font-size: 11px; }
.col { display: flex; flex-direction: column; }
.col.gap { gap: 6px; }
.input.small { height: 64px; font-size: 12px; font-family: ui-monospace, Menlo, monospace; }
.input.grow { flex: 1; margin-bottom: 0; }
.row.gap .input { margin-bottom: 0; }
.tab-badge { display: inline-block; min-width: 16px; height: 16px; line-height: 16px; border-radius: 8px; background: var(--bad); color: #fff; font-size: 10px; text-align: center; margin-left: 4px; padding: 0 4px; }
.stat-grid.four { grid-template-columns: repeat(4, 1fr); }
.stat-grid.four div { flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; }
.me-card { border-color: rgba(255, 176, 46, 0.45); }
.list-item.friend .rank { width: 30px; height: 30px; border-radius: 50%; background: rgba(0,0,0,.3); display: grid; place-items: center; font-weight: 800; flex: none; }
.list-item.friend.me { border-color: var(--accent); }
.list-item.friend.me .rank { background: var(--accent); color: #3a2000; }
.isle-swatch { width: 44px; height: 44px; border-radius: 12px; flex: none; border: 2px solid rgba(255,255,255,.15); }
.isle-swatch.grass { background: linear-gradient(135deg, #6fbf5a, #2a7fbd); }
.isle-swatch.sky { background: linear-gradient(135deg, #93d68c, #a7dbff); }
.isle-swatch.ember { background: linear-gradient(135deg, #5c4b45, #d0521f); }
.team-row.left { justify-content: flex-start; margin: 8px 0; }
.team-row.left .team-btn { pointer-events: none; }
@media (max-width: 360px) { #bottom-nav button span { font-size: 9px; } .res { padding: 5px 8px 5px 6px; font-size: 13px; } }

/* ---------- 3D art ---------- */
.dimg, .bimg { display: block; object-fit: contain; }
.list-item .thumb .dimg, .list-item .thumb .bimg, .book-cell .thumb .dimg, .outcome .thumb .dimg, .team-preview .mini .dimg, .team-btn .dimg, .parent .dimg, .dragon-hero .dimg, .result-art .dimg { width: 100%; height: 100%; }
.list-item .thumb .bimg { width: 100%; height: auto; max-height: 100%; }
.team-preview .mini .dimg { width: 34px; height: 34px; }
.team-preview.big .mini .dimg { width: 56px; height: 56px; }
.team-btn .dimg { width: 40px; height: 40px; }
.parent .dimg { width: 90px; height: 90px; }
.dragon-hero .dimg { width: 170px; height: 170px; }
.result-art .dimg { width: 130px; height: 130px; }
.book-cell .thumb .dimg { width: 64px; height: 64px; }
.dimg.pending, .bimg.pending { background: radial-gradient(circle at 50% 60%, rgba(255,255,255,.08), transparent 70%); }
.book-cell.unknown .thumb .dimg, .outcome.unknown .thumb .dimg, .dragon-hero.unknown .dimg { filter: brightness(0.12) saturate(0); opacity: .8; }
.dragon-hero.live { position: relative; width: 100%; height: 240px; border-radius: 18px; background: radial-gradient(ellipse at 50% 70%, rgba(255,255,255,.08), rgba(0,0,0,0) 70%); overflow: hidden; }
.viewer-canvas { width: 100%; height: 100%; display: block; touch-action: pan-y; }
.battle-screen.three .battle-field { background: radial-gradient(ellipse at 50% 20%, #34507a, #101c30 75%); }
.battle-screen.three .battle-field::before { display: none; }
.arena-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.battle-screen.three .fighter { pointer-events: none; background: none; border: 0; box-shadow: none; }
.battle-screen.three .fighter.player { top: 3%; left: 3%; bottom: auto; }
.battle-screen.three .fighter.enemy { top: 3%; right: 3%; }
.battle-screen.three .sprite-wrap { display: none; }
.battle-screen.three .battle-field .dmg { position: absolute; transform: translate(-50%, -50%); }
.battle-screen.three .hp-box { max-width: 190px; }
