:root {
  --bg: #12152e;
  --bg2: #1c2050;
  --panel: #20255a;
  --panel2: #2a3070;
  --line: #3a4190;
  --text: #f3f4ff;
  --muted: #a9aed8;
  --accent: #ffd166;
  --accent2: #ff5d73;
  --good: #7bd389;
  --radius: 18px;
  font-family: 'Fredoka', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; -webkit-tap-highlight-color: transparent; }
body { touch-action: manipulation; overscroll-behavior: none; }
body {
  background: radial-gradient(1200px 700px at 20% -10%, #3b2d80 0%, transparent 60%),
              radial-gradient(900px 600px at 110% 20%, #134e6f 0%, transparent 55%), var(--bg);
  background-attachment: fixed;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
h1, h2, h3 { margin: 0 0 0.5em; font-weight: 600; }
h3 small, h2 small { color: var(--muted); font-weight: 400; font-size: 0.75em; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.hidden { display: none !important; }

.screen { max-width: 1240px; margin: 0 auto; padding: 16px 20px 40px; }
.panel { background: linear-gradient(180deg, var(--panel2), var(--panel)); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3); }
.row { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.row.end { justify-content: flex-end; }
.row.center { justify-content: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }

.btn { background: #343b85; border: 1px solid #4b53a8; border-radius: 12px; padding: 10px 16px; font-weight: 500; transition: transform 0.08s, background 0.15s; }
.btn:hover:not(:disabled) { background: #3f479b; transform: translateY(-1px); }
.btn.primary { background: linear-gradient(180deg, #ffd166, #ffb703); color: #2a1a00; border-color: #ffcf5a; font-weight: 600; }
.btn.danger { background: #8a2a3d; border-color: #b23a52; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.07); }
.btn.small { padding: 6px 12px; font-size: 0.88rem; border-radius: 10px; }
.btn.huge { font-size: 1.5rem; padding: 14px 48px; border-radius: 16px; margin-top: 18px; }
.btn.icon { padding: 8px 12px; }
.text { background: #151937; border: 1px solid var(--line); color: var(--text); border-radius: 12px; padding: 10px 12px; font: inherit; width: 100%; }
select.text { width: 100%; }
.mini { font-size: 0.8rem; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.coin { background: rgba(255, 209, 102, 0.15); color: var(--accent); padding: 2px 10px; border-radius: 999px; font-weight: 600; white-space: nowrap; }

/* top bar */
.topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin-bottom: 18px; }
.topbar h1 { margin: 0; font-size: 1.6rem; text-align: center; }
.topbar > :first-child { justify-self: start; }
.topbar > :last-child { justify-self: end; }
.chip { display: inline-flex; align-items: center; gap: 8px; background: rgba(0, 0, 0, 0.25); padding: 5px 6px 5px 5px; border-radius: 999px; border: 1px solid var(--line); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--pc); color: #1a1a2e; display: grid; place-items: center; font-weight: 700; }
.avatar.big { width: 46px; height: 46px; font-size: 1.3rem; }

/* title */
.logo { font-size: clamp(3rem, 9vw, 6.5rem); font-weight: 700; letter-spacing: 0.06em; margin: 0; text-align: center;
  background: linear-gradient(180deg, #fff3c4, #ffd166 45%, #ff7b54); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 6px 0 #7a2e57) drop-shadow(0 14px 24px rgba(0, 0, 0, 0.4)); }
.logo.small { font-size: 2rem; filter: drop-shadow(0 3px 0 #7a2e57); }
.tag { text-align: center; color: var(--muted); font-size: 1.2rem; margin: 6px 0 28px; }
.title-screen { max-width: 620px; padding-top: 7vh; }
.profile-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.profile-row { display: flex; gap: 6px; align-items: center; }
.profile-card { flex: 1; display: flex; align-items: center; gap: 14px; background: #181c45; border: 2px solid transparent; border-radius: 14px; padding: 10px 14px; text-align: left; }
.profile-card:hover { border-color: var(--pc); }
.pinfo { flex: 1; display: flex; flex-direction: column; }
.pinfo small { color: var(--muted); }

/* hub */
.hub-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; }
.hub-stage { padding: 0; overflow: hidden; display: flex; flex-direction: column; min-height: 460px; }
.stage3d { flex: 1; position: relative; min-height: 380px; background: radial-gradient(circle at 50% 60%, #34407e, #1a1e48 70%); }
.stage-cap { padding: 12px 18px; color: var(--muted); }
.stage-cap b { color: var(--text); }
.hub-menu { display: flex; flex-direction: column; gap: 12px; }
.big-btn { display: flex; align-items: center; gap: 14px; text-align: left; font-size: 1.25rem; font-weight: 600; padding: 18px 22px; border-radius: 18px; border: 1px solid var(--line); background: linear-gradient(180deg, var(--panel2), var(--panel)); transition: transform 0.1s, border-color 0.15s; }
.big-btn span { font-size: 1.6rem; width: 36px; text-align: center; }
.big-btn small { margin-left: auto; background: rgba(0, 0, 0, 0.3); border-radius: 999px; padding: 2px 10px; font-size: 0.9rem; color: var(--muted); }
.big-btn:hover { transform: translateX(4px); border-color: var(--accent); }
.big-btn.start { font-size: 2rem; padding: 24px; justify-content: center; background: linear-gradient(180deg, #ff7b8d, #ff3f5e); border-color: #ff9aa8; box-shadow: 0 8px 0 #9c2238, 0 14px 30px rgba(255, 63, 94, 0.35); letter-spacing: 0.08em; }
.big-btn.start:hover { transform: translateY(-2px); }
.big-btn.start:active { transform: translateY(4px); box-shadow: 0 4px 0 #9c2238; }

/* 3D containers */
.stage3d canvas, .preview3d canvas, .shop3d canvas, .show3d canvas, .mk3d canvas, .winner-3d canvas { width: 100%; height: 100%; display: block; position: absolute; inset: 0; }
.preview3d, .shop3d, .show3d, .mk3d, .winner-3d { position: relative; border-radius: 14px; overflow: hidden; background: radial-gradient(circle at 50% 60%, #34407e, #1a1e48 70%); }
.empty-3d { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 20px; z-index: 1; pointer-events: none; }

/* editor */
.editor { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px; }
.ed-left, .ed-right { display: flex; flex-direction: column; gap: 12px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; }
.tool-group { display: flex; gap: 6px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 5px; }
.tool { background: transparent; border: 0; border-radius: 8px; padding: 6px 10px; }
.tool:hover { background: rgba(255, 255, 255, 0.08); }
.tool.active { background: var(--accent); color: #2a1a00; }
.check input { accent-color: var(--accent); }
.palettes { display: flex; gap: 16px; flex-wrap: wrap; }
.palettes > div { display: flex; align-items: center; gap: 8px; }
.swatches { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.sw { width: 24px; height: 24px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.25); padding: 0; }
.sw.on { outline: 3px solid var(--accent); outline-offset: 1px; }
.swatches input[type=color] { width: 28px; height: 28px; border: 0; background: none; padding: 0; cursor: pointer; }
.canvas-wrap { position: relative; aspect-ratio: 1; width: 100%; border-radius: 16px; overflow: hidden; touch-action: none;
  background: #fff; background-image: radial-gradient(#dfe3f5 1.2px, transparent 1.2px); background-size: 22px 22px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); }
.canvas-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#draw { cursor: crosshair; }
.mirror-line { position: absolute; left: 50%; top: 0; bottom: 0; border-left: 2px dashed rgba(123, 97, 255, 0.35); pointer-events: none; display: none; }
.canvas-wrap.mirror .mirror-line { display: block; }
.canvas-hint { position: absolute; bottom: 12px; left: 0; right: 0; text-align: center; color: #8a90b8; pointer-events: none; font-size: 0.95rem; }
.canvas-wrap.has-ink .canvas-hint { display: none; }
.preview3d { aspect-ratio: 1.15; }
.ed-stats .arch { font-weight: 600; color: var(--accent); margin-bottom: 6px; }
.tip { color: var(--muted); font-size: 0.85rem; margin: 0; }

.statbars { display: flex; flex-direction: column; gap: 6px; }
.sb { display: grid; grid-template-columns: 110px 1fr 40px; align-items: center; gap: 8px; font-size: 0.9rem; }
.sb .bar { height: 10px; background: #151937; border-radius: 999px; overflow: hidden; }
.sb .bar i { display: block; height: 100%; background: linear-gradient(90deg, #7bd389, #ffd166); border-radius: 999px; transition: width 0.3s; }
.sb b { text-align: right; }

/* modes */
.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 4vh; }
.mode-card { text-align: center; padding: 30px 22px; border-radius: 22px; border: 2px solid var(--line); background: linear-gradient(180deg, var(--panel2), var(--panel)); transition: transform 0.12s, border-color 0.15s; display: flex; flex-direction: column; align-items: center; }
.mode-card:hover { transform: translateY(-6px); border-color: var(--accent); }
.mode-ic { font-size: 3.6rem; margin-bottom: 10px; }
.mode-card p { color: var(--muted); flex: 1; }
.reward { margin-top: 8px; }

/* setup */
.slots { display: grid; gap: 16px; grid-template-columns: repeat(2, 1fr); }
.slots.n4 { grid-template-columns: repeat(4, 1fr); }
.slot { border-top: 5px solid var(--pc); display: flex; flex-direction: column; gap: 8px; }
.slot.off { opacity: 0.6; }
.slot-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.slot-head h3 { margin: 0; }
.slot-head select { width: auto; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; max-height: 320px; overflow: auto; padding: 2px; }
.pick { background: #181c45; border: 2px solid transparent; border-radius: 14px; padding: 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 0.85rem; min-width: 0; }
.pick span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.pick small { color: var(--muted); }
.pick.on { border-color: var(--accent); background: #262b63; }
.pick.sm { flex: 0 0 86px; }
.thumb { width: 100%; aspect-ratio: 1; border-radius: 10px; background: radial-gradient(circle, #3a4590, #22285c); display: grid; place-items: center; overflow: hidden; }
.thumb img { width: 90%; height: 90%; object-fit: contain; }
.cpu-face { font-size: 4rem; text-align: center; padding: 10px 0; }
.seg { display: flex; background: #151937; border-radius: 12px; padding: 4px; gap: 4px; flex-wrap: wrap; }
.seg button { flex: 1; background: transparent; border: 0; border-radius: 9px; padding: 7px 10px; }
.seg button.on { background: var(--accent); color: #2a1a00; font-weight: 600; }

/* arena */
#battle { position: fixed; inset: 0; }
.arena { position: absolute; inset: 0; overflow: hidden; user-select: none; }
.arena-canvas canvas { display: block; }
.hud { position: absolute; top: 14px; left: 14px; right: 14px; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; pointer-events: none; }
.hud-card { display: flex; gap: 10px; align-items: center; background: rgba(12, 14, 36, 0.75); border: 2px solid var(--pc); border-radius: 16px; padding: 6px 12px 6px 6px; min-width: 220px; backdrop-filter: blur(6px); transition: opacity 0.3s; }
.hud-card img { width: 48px; height: 48px; object-fit: contain; background: rgba(255, 255, 255, 0.06); border-radius: 10px; }
.hud-card.out { opacity: 0.4; filter: grayscale(1); }
.hud-info { flex: 1; }
.hud-name { font-weight: 600; }
.hud-name small { color: var(--muted); font-weight: 400; }
.hp { height: 12px; background: rgba(255, 255, 255, 0.12); border-radius: 999px; overflow: hidden; margin-top: 4px; }
.hp { position: relative; }
.hp i { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; border-radius: 999px; }
.hp i.chip { background: #fff; opacity: 0.75; }
.hp i.fill { background: linear-gradient(90deg, #7bd389, #b6f29a); transition: width 0.12s; }
.hp i.fill.low { background: linear-gradient(90deg, #ff5d73, #ff9f43); animation: pulse 0.6s infinite alternate; }
@keyframes pulse { to { filter: brightness(1.4); } }
.sp-ready { font-size: 1.1rem; color: #555b8f; transition: 0.2s; }
.sp-ready.ready { color: var(--accent); text-shadow: 0 0 10px var(--accent); animation: pulse 0.5s infinite alternate; }
.arena-help { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); background: rgba(12, 14, 36, 0.7); padding: 8px 16px; border-radius: 999px; color: var(--muted); font-size: 0.9rem; white-space: nowrap; }
.arena-help b { color: var(--text); background: rgba(255, 255, 255, 0.1); border-radius: 6px; padding: 0 6px; }
.arena-help .sep { display: inline-block; width: 1px; height: 14px; background: var(--line); margin: 0 12px; vertical-align: middle; }
.banner { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; opacity: 0; transition: opacity 0.2s; }
.banner.show { opacity: 1; }
.banner span { font-size: clamp(3rem, 10vw, 8rem); font-weight: 700; color: #fff; text-shadow: 0 6px 0 #7a2e57, 0 12px 40px rgba(0, 0, 0, 0.6); animation: pop 0.35s ease-out; }
.banner .go { color: var(--accent); }
.banner .win { font-size: clamp(2.4rem, 7vw, 5.5rem); color: var(--accent); }
@keyframes pop { from { transform: scale(1.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.popups { position: absolute; inset: 0; pointer-events: none; }
.popup { position: absolute; left: 0; top: 0; font-weight: 700; font-size: 1.5rem; color: #fff; text-shadow: 0 3px 0 #000a; white-space: nowrap; }
.popup.crit { color: #ffd166; font-size: 2rem; }
.popup.big { color: #ff5d73; font-size: 2.6rem; }
.loading { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 18px; align-items: center; justify-content: center; font-size: 1.4rem; background: var(--bg); z-index: 5; }
.spinner { width: 54px; height: 54px; border-radius: 50%; border: 6px solid #2c3270; border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.pause-btn { position: absolute; top: 12px; right: 12px; width: 44px; height: 44px; border-radius: 14px; border: 1px solid var(--line); background: rgba(12, 14, 36, 0.7); font-size: 0.9rem; z-index: 3; }
.banner .intro { font-size: 1rem; animation: none; text-shadow: none; }
.vs { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: center; justify-content: center; padding: 0 16px; }
.vs span { display: flex; flex-direction: column; align-items: center; font-size: clamp(1.4rem, 4vw, 2.6rem); font-weight: 700; color: #fff; padding: 10px 18px; border-radius: 18px; background: rgba(12, 14, 36, 0.75); border: 3px solid var(--pc); animation: pop 0.4s ease-out both; text-shadow: 0 3px 0 #0008; }
.vs span small { font-size: 0.45em; font-weight: 500; color: var(--muted); }
.vs b { font-size: clamp(1.8rem, 5vw, 3.4rem); color: var(--accent2); text-shadow: 0 4px 0 #7a2e57; }
.pause { position: absolute; inset: 0; background: rgba(6, 8, 24, 0.6); display: grid; place-items: center; backdrop-filter: blur(4px); }
.pause .panel { text-align: center; min-width: 300px; }

/* results */
.results { max-width: 640px; padding-top: 5vh; }
.result-card { text-align: center; }
.winner-3d { height: 320px; margin: 10px 0; }
.rewards { display: flex; flex-direction: column; gap: 8px; margin: 14px 0; }
.reward-line { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: #181c45; border-left: 5px solid var(--pc); border-radius: 10px; padding: 10px 14px; }
.reward-line .gain { color: var(--accent); font-weight: 700; }

/* shop */
.shop { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 20px; }
.shop-left { display: flex; flex-direction: column; gap: 12px; }
.strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.shop3d { aspect-ratio: 1.2; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tabs button { flex: 1; background: #181c45; border: 1px solid var(--line); border-radius: 12px; padding: 10px; font-weight: 600; }
.tabs button.on { background: var(--accent); color: #2a1a00; border-color: var(--accent); }
.filters { margin-bottom: 12px; }
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.item { background: #181c45; border: 2px solid transparent; border-radius: 14px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.item.equipped { border-color: var(--good); }
.item.previewing { border-color: var(--accent); }
.item-face { background: transparent; border: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; }
.item-face .ic { font-size: 2.2rem; }
.item-face small { color: var(--muted); }
.ups { display: flex; flex-direction: column; gap: 10px; }
.up-row { display: flex; align-items: center; gap: 12px; background: #181c45; border-radius: 14px; padding: 12px; }
.up-row .ic { font-size: 1.8rem; }
.up-row small { color: var(--muted); }
.pips { display: flex; gap: 4px; margin-top: 6px; }
.pips i { width: 22px; height: 8px; border-radius: 4px; background: #2c3270; }
.pips i.on { background: var(--accent); }

/* collection */
.collection { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 20px; }
.showcase { display: flex; flex-direction: column; gap: 14px; }
.show3d { aspect-ratio: 1.3; }
.grid-wrap { display: flex; flex-direction: column; gap: 12px; align-self: start; }
.cgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.empty { text-align: center; padding: 40px; }

/* market */
.market { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; }
.market-list { display: flex; flex-direction: column; gap: 8px; align-self: start; }
.listing { display: flex; align-items: center; gap: 12px; background: #181c45; border: 2px solid transparent; border-radius: 14px; padding: 8px; cursor: pointer; }
.listing.on { border-color: var(--accent); }
.listing .thumb { width: 60px; flex: none; }
.listing small { display: block; color: var(--muted); }
.price { color: var(--accent); font-weight: 700; }
.badge { font-size: 0.7rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: rgba(76, 201, 240, 0.18); color: #8fdcf5; vertical-align: middle; }
.badge.player { background: rgba(123, 211, 137, 0.18); color: #9fe3a9; }
.market-side { display: flex; flex-direction: column; gap: 14px; align-self: start; }
.mk3d { aspect-ratio: 1.1; }
.adopt { background: #181c45; border-radius: 14px; padding: 14px; }

/* modal + toast */
.modal-bg { position: fixed; inset: 0; background: rgba(5, 6, 20, 0.6); display: grid; place-items: center; z-index: 50; backdrop-filter: blur(3px); padding: 16px; }
.modal { width: min(440px, 100%); }
.modal-body { color: var(--muted); margin-bottom: 12px; }
#toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 30px); background: #fff; color: #1a1a2e; padding: 10px 20px; border-radius: 999px; font-weight: 600; opacity: 0; transition: 0.25s; pointer-events: none; z-index: 60; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .hub-grid, .editor, .shop, .collection, .market, .modes { grid-template-columns: 1fr; }
  .slots, .slots.n4 { grid-template-columns: 1fr 1fr; }
  .arena-help { white-space: normal; text-align: center; width: 92%; border-radius: 14px; }
}
@media (max-width: 560px) {
  .slots, .slots.n4 { grid-template-columns: 1fr; }
  .topbar h1 { font-size: 1.2rem; }
}

/* ---------- new UI bits ---------- */
.top-right { display: flex; align-items: center; gap: 6px; justify-self: end; }
.btn.mute { font-size: 1.1rem; padding: 6px 10px; }
.tbadge { display: inline-flex; align-items: center; gap: 4px; font-size: 0.72rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: color-mix(in srgb, var(--tc) 22%, transparent); color: var(--tc); vertical-align: middle; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn { background: #181c45; border: 2px solid transparent; border-radius: 999px; padding: 6px 12px; font-size: 0.88rem; }
.chip-btn.on { border-color: var(--accent); background: #262b63; }
.look { display: flex; flex-direction: column; gap: 10px; background: rgba(0, 0, 0, 0.18); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.look-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.look-row > .mini { width: 38px; }
.text.slim { width: auto; flex: 1; min-width: 160px; padding: 8px 10px; }
.type-blurb { color: var(--muted); font-size: 0.88rem; margin: 2px 0 10px; }
.type-blurb b { color: var(--text); }
.ed-stats .arch small { color: var(--muted); font-weight: 400; font-size: 0.75rem; }
.type-card { display: flex; gap: 14px; align-items: center; background: color-mix(in srgb, var(--tc) 14%, #181c45); border: 1px solid color-mix(in srgb, var(--tc) 45%, transparent); border-radius: 16px; padding: 12px 14px; margin-bottom: 14px; }
.type-card .ti { font-size: 2.4rem; }
.type-card p { margin: 2px 0; color: var(--muted); font-size: 0.9rem; }
.type-card small { color: var(--accent); }
.shop-body h3 { margin: 16px 0 8px; }

/* ---------- touch controls ---------- */
.touchpad { position: absolute; inset: 0; pointer-events: none; display: none; z-index: 2; }
.touchpad.show { display: block; }
.tp-zone { position: absolute; bottom: 0; top: 30%; width: 50%; pointer-events: auto; touch-action: none; }
.tp-zone.left { left: 0; } .tp-zone.right { right: 0; }
.touchpad:not(.two) .tp-zone.left { width: 58%; }
.tp-stick { position: absolute; left: 22%; top: 70%; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; background: rgba(255, 255, 255, 0.08); border: 2px solid rgba(255, 255, 255, 0.25); opacity: 0.55; transition: opacity 0.15s; }
.tp-zone.right .tp-stick { left: 78%; }
.tp-zone.active .tp-stick { opacity: 1; }
.tp-knob { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%; background: rgba(255, 255, 255, 0.55); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4); }
.tp-hint { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center; font-size: 0.75rem; color: rgba(255, 255, 255, 0.4); pointer-events: none; }
.tp-btns { position: absolute; bottom: 18px; right: 18px; width: 190px; height: 190px; pointer-events: none; }
.tp-btns.two.left { right: auto; left: calc(50% - 205px); }
.tp-btns.two.right { right: auto; left: calc(50% + 15px); }
.tp-btn { position: absolute; pointer-events: auto; touch-action: none; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.5); color: #fff; font-size: 1.6rem; font-weight: 700; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4); user-select: none; -webkit-user-select: none; }
.tp-btn.down { transform: scale(0.9); filter: brightness(1.3); }
.tp-btn.atk { width: 92px; height: 92px; right: 0; bottom: 0; background: rgba(255, 93, 115, 0.8); }
.tp-btn.sp { width: 68px; height: 68px; right: 104px; bottom: 6px; background: rgba(255, 183, 3, 0.8); }
.tp-btn.dodge { width: 60px; height: 60px; right: 14px; bottom: 104px; background: rgba(76, 201, 240, 0.75); font-size: 1.3rem; }
.tp-btns.two .tp-btn.atk { width: 74px; height: 74px; }
.tp-btns.two .tp-btn.sp { width: 56px; height: 56px; right: 82px; }
.tp-btns.two .tp-btn.dodge { width: 50px; height: 50px; bottom: 84px; right: 10px; }
.arena.is-touch .arena-help { display: none; }

/* ---------- phones & tablets ---------- */
@media (max-width: 900px) {
  .screen { padding: 12px 14px 32px; }
  .hub-stage { min-height: 320px; }
  .stage3d { min-height: 260px; }
  .big-btn { padding: 14px 18px; font-size: 1.1rem; }
  .big-btn.start { font-size: 1.6rem; padding: 18px; }
  .hud { top: 8px; left: 8px; right: 64px; gap: 6px; justify-content: flex-start; }
  .hud-card { min-width: 0; flex: 1 1 140px; max-width: 220px; padding: 4px 8px 4px 4px; gap: 6px; }
  .hud-card img { width: 34px; height: 34px; }
  .hud-name { font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .hud-name small { display: none; }
  .popup { font-size: 1.15rem; } .popup.big { font-size: 1.9rem; } .popup.crit { font-size: 1.5rem; }
  .canvas-wrap { max-width: 560px; margin: 0 auto; }
  .preview3d { aspect-ratio: 1.4; }
}
@media (max-width: 560px) {
  .topbar { grid-template-columns: auto 1fr auto; gap: 6px; }
  .topbar h1 { font-size: 1.05rem; }
  .pname { display: none; }
  .chip { padding: 3px 6px 3px 3px; }
  .btn { padding: 9px 12px; }
  .tool { padding: 6px 7px; font-size: 0.85rem; }
  .sw { width: 22px; height: 22px; }
  .modes { margin-top: 1vh; }
  .mode-card { padding: 18px 14px; }
  .mode-ic { font-size: 2.6rem; }
  .items { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
  .sb { grid-template-columns: 92px 1fr 34px; font-size: 0.82rem; }
  .tabs button { padding: 8px 4px; font-size: 0.85rem; }
  .tp-btns { transform: scale(0.85); transform-origin: bottom right; }
  .tp-btns.two { transform: scale(0.72); transform-origin: bottom center; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .hud { top: 4px; } .hud-card img { width: 28px; height: 28px; }
  .tp-btns { transform: scale(0.8); transform-origin: bottom right; }
}
