:root {
  --bg: #12161c;
  --panel: #171b27;
  --panel-2: #22283a;
  --face: #2a3146;
  --line: #2c3348;
  --text: #f3f6ff;
  --muted: #c5cce0;
  --gold: #ffd369;
  --mint: #5eead4;
  --mint-hi: #8fe3c1;
  --ink: #08110e;
  --danger: #ff4d6d;
  --shadow: 0 16px 50px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #12161c;
  color: var(--text);
  font-family: "Segoe UI", "Apple SD Gothic Neo", sans-serif;
  user-select: none;
  touch-action: none;
}

#app {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: minmax(36px, 8vh) 1fr minmax(36px, 8vh);
  grid-template-columns: 1fr;
}

.app-mid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  min-height: 0;
  align-items: center;
}

.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  letter-spacing: 0.18em;
  font-size: 12px;
  background: #171b27;
  border: 1px solid #2c3348;
}

.ad-side { height: 100%; min-width: 0; }

#game-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 8px;
}

#game-viewport {
  position: relative;
  width: min(84vh, calc(100vw - 220px), 820px);
  height: auto;
  aspect-ratio: 1 / 1;
  background: #1a2330;
  border: 2px solid #2c3348;
  box-shadow: 0 0 0 4px #12161c;
  overflow: hidden;
  border-radius: 10px;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#hud, #toast-layer, #overlay-root, #joystick-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#overlay-root { z-index: 20; }
#toast-layer { z-index: 15; }
#hud { z-index: 10; }
#joystick-layer { z-index: 12; }

#sound-dock {
  position: fixed;
  right: 14px;
  bottom: 12px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 14px;
  background: rgba(20, 24, 36, 0.82);
  border: 1px solid #2c3348;
  border-radius: 12px;
  padding: 8px 12px;
  box-shadow: none;
}
.sound-dock-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.reset-dock-btn {
  display: none;
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 10px;
  opacity: 0.82;
}
#app.lobby-ui .reset-dock-btn { display: inline-flex; }

.sound-toggle, .vol-label {
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.sound-toggle {
  background: #2a3146;
  border: 0;
  border-radius: 12px;
  padding: 8px 10px;
  cursor: pointer;
  color: #eef2ff;
}
.sound-toggle:hover { background: #7cf0e0; color: #08110e; }
.sound-toggle:active { background: #2dd4bf; transform: translateY(1px); }
.sound-toggle.off { opacity: 0.7; }

.vol-label { display: flex; align-items: center; gap: 8px; }
#vol-slider { width: 90px; accent-color: #5eead4; }

.hud-bar {
  position: absolute;
  left: 10px;
  right: 10px;
  top: 8px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  text-shadow: 0 2px 6px rgba(0,0,0,0.7);
}

.hud-left, .hud-right { display: flex; flex-direction: column; gap: 3px; }
.hud-left { max-width: 42%; }
.hud-right { align-items: flex-end; text-align: right; flex-shrink: 0; }
.hud-time { white-space: nowrap; }
.hud-cur-mul { margin-left: 0.2em; font-weight: 800; }
.hud-gold { color: var(--gold); font-weight: 800; }
.cur-amt {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  white-space: nowrap;
}
.cur-amt.ruby-amt, .lobby-ruby { color: #ff6b7a; }
.hp-wrap { width: 180px; max-width: 100%; }
.hp-text { font-weight: 800; margin-bottom: 2px; font-size: 11px; }
.stat-hud {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.28;
  letter-spacing: 0;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85), 0 0 6px rgba(0, 0, 0, 0.55);
  pointer-events: none;
}
.stat-hud-row { color: #fff; white-space: nowrap; }
.stat-hud-row.cap { color: var(--gold); }
.hp-track, .boss-track, .shield-track {
  height: 16px;
  background: rgba(0,0,0,0.45);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 99px;
  overflow: hidden;
}
.hp-fill { height: 100%; background: #42d392; border-radius: 99px; }
.shield-fill { height: 100%; background: #8fe3c1; width: 0; border-radius: 99px; }
.boss-hud {
  position: absolute;
  left: 22%;
  right: 22%;
  top: 40px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: #ffe1e6;
}
.boss-name { font-weight: 800; letter-spacing: 0.18em; margin-bottom: 4px; color: #ff4d6d; font-size: 14px; }
.boss-fill { height: 100%; background: #ef4444; border-radius: 99px; }
.skill-strip {
  position: absolute;
  left: 8px;
  bottom: 8px;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 5px;
  max-width: 46%;
  pointer-events: none;
}
.skill-chip {
  width: 42px;
  height: 50px;
  border-radius: 10px;
  background: #171b27;
  border: 1px solid #2c3348;
  box-shadow: inset 0 3px 0 var(--acc, #8fe3c1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  pointer-events: none;
}
.skill-chip-ico {
  width: 22px;
  height: 22px;
}
.skill-chip-ico svg { width: 22px; height: 22px; display: block; }
.skill-chip-lv {
  font-size: 10px;
  font-weight: 800;
  color: #eef2ff;
  line-height: 1;
}

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(8, 10, 16, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

.lobby-overlay {
  align-items: stretch;
  justify-content: stretch;
  padding: 8px;
  background: rgba(8, 10, 16, 0.88);
}

.lobby-shell {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #171b27;
  border: 1px solid #2c3348;
  border-radius: 18px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.4);
  padding: 8px 12px 10px;
  overflow: hidden;
}

.lobby-best {
  position: absolute;
  left: 12px;
  top: 8px;
  color: #c5cce0;
  font-weight: 700;
  font-size: 12px;
  line-height: 1.35;
  letter-spacing: 0.02em;
  z-index: 2;
  pointer-events: none;
  text-align: left;
}
.lobby-gold {
  position: absolute;
  right: 12px;
  top: 10px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--gold);
  font-weight: 800;
  font-size: 16px;
  z-index: 2;
}
.lobby-gold.pulse { animation: goldPulse 0.4s ease; }
.hud-currency { display: flex; align-items: center; gap: 10px; }
.lobby-ruby { color: #ff6b7a; font-weight: 800; }
.ruby-ico {
  width: 14px;
  height: 14px;
  display: inline-block;
  background: #e11d48;
  transform: rotate(45deg);
  border: 1px solid #9f1239;
  box-shadow: none;
}
.ruby-ico.sm { width: 10px; height: 10px; vertical-align: -1px; margin-right: 4px; }
.emerald-amt { color: #34d399; }
.emerald-ico {
  width: 14px;
  height: 14px;
  display: inline-block;
  background: #10b981;
  transform: rotate(45deg);
  border: 1px solid #047857;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.45);
}
.emerald-ico.sm { width: 10px; height: 10px; vertical-align: -1px; margin-right: 4px; }
.hud-ruby { color: #ff8a9a; font-weight: 800; display: flex; align-items: center; }
@keyframes goldPulse {
  0% { transform: scale(1); filter: brightness(1); }
  40% { transform: scale(1.08); filter: brightness(1.35); }
  100% { transform: scale(1); filter: brightness(1); }
}
.coin-ico {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffd166;
  box-shadow: none;
  border: 1.5px solid #c9a227;
}
.coin-ico.sm { width: 12px; height: 12px; border-width: 1px; }

.lobby-train {
  grid-template-columns: 1fr 1fr;
  flex: 0 0 auto;
  overflow: visible;
  align-content: start;
  gap: 6px;
  margin: 4px 0 6px;
  padding-right: 0;
}
.lobby-train .luck-card {
  grid-column: 1 / -1;
}
.lobby-train .train-card { padding: 6px 8px; }
.lobby-shell .panel-title { padding: 0 118px 0; font-size: 22px; font-weight: 700; margin-bottom: 2px; }
.lobby-shell.records-shell .panel-title { padding: 8px 12px 6px; }
.lobby-shell .panel-sub { margin-bottom: 4px; color: #c5cce0; font-size: 13px; }
.start-btn { min-width: 168px; font-size: 16px; padding: 10px 18px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.reset-btn { padding: 8px 12px; font-size: 13px; }
.lobby-actions { margin-top: 6px; gap: 10px; align-items: center; }
.lobby-foot {
  display: grid;
  grid-template-columns: minmax(88px, 1fr) auto minmax(88px, 1fr);
  align-items: center;
  gap: 8px;
  margin-top: auto;
  flex: 0 0 auto;
}
.lobby-foot .records-btn { justify-self: start; }
.lobby-foot .lobby-actions { margin-top: 0; justify-self: center; }
.lobby-foot-spacer { min-width: 1px; }
.records-btn {
  min-width: 0;
  padding: 8px 12px;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.records-shell .panel-title {
  padding: 8px 12px 6px;
  font-size: 24px;
  margin-bottom: 4px;
}
.records-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  flex: 1 1 auto;
  min-height: 0;
  align-content: stretch;
  margin: 4px 0 8px;
}
.records-card {
  background: #1e2434;
  border: 1px solid #2c3348;
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}
.rec-head {
  display: flex;
  align-items: center;
  gap: 6px;
}
.rec-ico, .records-card .btn-ico {
  display: inline-flex;
  align-items: center;
  line-height: 0;
  flex-shrink: 0;
}
.records-card .btn-ico svg { width: 16px; height: 16px; }
.records-card .coin-ico.sm,
.records-card .ruby-ico.sm,
.records-card .emerald-ico.sm {
  width: 12px;
  height: 12px;
}
.rec-label {
  font-size: 12px;
  font-weight: 700;
  color: #c5cce0;
  white-space: nowrap;
}
.rec-val {
  margin-top: 8px;
  font-size: 20px;
  font-weight: 800;
  color: #eef2ff;
  line-height: 1.2;
  letter-spacing: -0.02em;
  word-break: break-word;
}
.btn-ico { display: inline-flex; align-items: center; line-height: 0; }
.game-btn.rebirth-btn {
  background: #ffd369;
  color: #1a1408;
  font-weight: 800;
  min-width: 120px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.game-btn.rebirth-btn:hover { background: #ffe08a; }
.game-btn.rebirth-btn:active { background: #e2b84a; transform: translateY(1px); }
.game-btn.rebirth-btn:disabled { opacity: 0.45; cursor: default; transform: none; background: #ffd369; }
.rebirth-meta {
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
  margin: 2px 0 6px;
  color: #e2e8f0;
}
.rebirth-train { flex: 1 1 auto; min-height: 0; overflow: auto; }
.rebirth-foot {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  margin-top: 2px;
}
.rebirth-cond {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #fbbf24;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
}
.rebirth-warn { color: #ffd369; font-weight: 700; }
.rebirth-fx-overlay { background: rgba(6, 8, 14, 0.55); }
.rebirth-fx {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
}
.rebirth-fx-flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 48%, rgba(255,255,255,0.95) 0%, rgba(255,214,105,0.55) 28%, rgba(16,185,129,0.2) 52%, transparent 70%);
  animation: rbFlash 1.35s ease-out forwards;
}
.rebirth-fx-ring {
  position: absolute;
  left: 50%;
  top: 48%;
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 209, 105, 0.95);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0.2);
  animation: rbRing 1.2s ease-out forwards;
}
.rebirth-fx-wings {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%) scale(0.4);
  filter: drop-shadow(0 0 18px rgba(255,255,255,0.85));
  animation: rbWings 1.15s ease-out forwards;
  color: #fff;
}
.rebirth-fx-gain {
  position: absolute;
  left: 50%;
  top: 62%;
  transform: translate(-50%, -20px);
  font-size: 28px;
  font-weight: 800;
  color: #6ee7b7;
  opacity: 0;
  animation: rbGain 0.9s ease 0.25s forwards;
  display: flex;
  align-items: center;
  gap: 8px;
}
.rebirth-fx-amt { color: #6ee7b7; font-size: 28px; font-weight: 800; }
.rebirth-fx-bits { position: absolute; inset: 0; }
.rebirth-bit {
  position: absolute;
  left: 50%;
  top: 48%;
  width: 8px;
  height: 8px;
  background: #10b981;
  transform: rotate(45deg);
  animation: rbBit 1.1s ease-out forwards;
}
@keyframes rbFlash {
  0% { opacity: 0; }
  18% { opacity: 1; }
  100% { opacity: 0.15; }
}
@keyframes rbRing {
  0% { transform: translate(-50%, -50%) scale(0.15); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(18); opacity: 0; }
}
@keyframes rbWings {
  0% { transform: translate(-50%, -50%) scale(0.25) rotate(-8deg); opacity: 0; }
  35% { opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.15) rotate(0deg); opacity: 1; }
}
@keyframes rbGain {
  0% { opacity: 0; transform: translate(-50%, 12px); }
  100% { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes rbBit {
  0% { transform: translate(0, 0) rotate(45deg); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(45deg); opacity: 0; }
}

.train-card.compact h3 { margin: 0; font-size: 13px; text-align: left; }
.train-card .train-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}
.train-card.compact .train-vals { margin: 0; font-size: 13px; text-align: right; }
.train-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.train-card.compact .train-price { margin: 0; text-align: left; font-size: 13px; display: flex; align-items: center; }
.train-btn { padding: 6px 12px; font-size: 13px; border-radius: 10px; }

.luck-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  margin-bottom: 4px;
}
.luck-copy { flex: 1; min-width: 0; }
.luck-card h3 { text-align: left; margin: 0; font-size: 14px; }
.luck-card .train-desc { text-align: left; font-size: 11px; margin: 2px 0 4px; }
.luck-rates { font-size: 12px; font-weight: 700; line-height: 1.35; }
.luck-card .train-price { margin: 0; text-align: right; }

.card-panel {
  width: min(92%, 560px);
  max-height: 92%;
  overflow: auto;
  background: #171b27;
  border: 1px solid #2c3348;
  border-radius: 18px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.4);
  padding: 18px;
}
.skill-choice-panel { width: min(94%, 720px); }

.panel-title {
  text-align: center;
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 6px;
}
.panel-sub { text-align: center; color: var(--muted); margin-bottom: 14px; font-size: 14px; }

.btn-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.game-btn {
  background: #2a3146;
  color: #eef2ff;
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.08s, background 0.12s;
}
.game-btn:hover { background: #343c54; }
.game-btn.selected { background: #343c54; }
.game-btn:active { transform: translateY(1px); }
.game-btn.gold, .game-btn.start-btn, .start-btn {
  background: #5eead4;
  color: #08110e;
  font-weight: 700;
}
.game-btn.gold:hover, .game-btn.start-btn:hover, .start-btn:hover,
.game-btn.gold.selected, .game-btn.start-btn.selected { background: #7cf0e0; }
.game-btn.gold:active, .game-btn.start-btn:active, .start-btn:active { background: #2dd4bf; transform: translateY(1px); }
.game-btn.danger { background: #2a3146; color: #eef2ff; }
.game-btn.danger:hover { background: #343c54; }
.game-btn:disabled { opacity: 0.45; cursor: default; transform: none; }

.stat-grid, .train-grid, .choice-grid {
  display: grid;
  gap: 8px;
}
.stat-grid { grid-template-columns: 1fr 1fr; margin: 10px 0 14px; }
.over-stats { grid-template-columns: 1fr; }
.stat-row, .choice-card, .train-card {
  background: #22283a;
  border: 0;
  border-radius: 12px;
  padding: 12px;
}
.stat-row { display: flex; justify-content: space-between; font-size: 15px; }
.stat-row b { color: #fff; }
.best-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 2px 0 10px;
  color: #fbbf24;
  font-weight: 800;
  letter-spacing: 0.18em;
  font-size: 15px;
  animation: bestShine 1.4s ease-in-out 2;
}
.best-star {
  font-size: 16px;
  filter: drop-shadow(0 0 6px rgba(251, 191, 36, 0.7));
}
.best-label { text-shadow: 0 0 10px rgba(251, 191, 36, 0.55); }
@keyframes bestShine {
  0%, 100% { opacity: 0.72; filter: brightness(1); }
  40% { opacity: 1; filter: brightness(1.35); }
}

.choice-grid { grid-template-columns: repeat(3, 1fr); margin: 12px 0; }
.choice-card {
  cursor: pointer;
  text-align: left;
  min-height: 210px;
  color: #f3f6ff;
  font-weight: 700;
  position: relative;
  overflow: visible;
  border: 1px solid transparent;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.choice-card.lv3 { border-color: rgba(103, 232, 249, 0.55); }
.choice-card.lv5 { border-color: rgba(251, 191, 36, 0.7); background: #1f2436; }
.choice-card.skill-card { animation: cardIn 0.18s ease both; }
.choice-accent {
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 4px;
  background: var(--acc, #8fe3c1);
}
.skill-ico { width: 28px; height: 28px; margin: 4px 0 6px; }
.skill-ico svg { width: 28px; height: 28px; display: block; }
.choice-card:hover,
.choice-card.selected {
  background: #2a3146;
  transform: translateY(-2px);
  border-color: var(--acc, #8fe3c1);
}
.choice-card:active { filter: brightness(1.12); }
.choice-card.picked { transform: scale(1.06); }
.choice-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #67e8f9;
  margin-bottom: 4px;
}
.choice-badge.max { color: #fbbf24; }
.choice-awaken {
  font-size: 13px;
  font-weight: 800;
  color: var(--acc, #8fe3c1);
  margin-bottom: 6px;
}
.choice-sec { font-size: 11px; color: #8b93a7; font-weight: 800; margin: 8px 0 4px; letter-spacing: 0.04em; }
.choice-chg-label { font-size: 11px; color: #9aa3b8; margin-top: 4px; font-weight: 600; }
.choice-chg { color: var(--acc, #8fe3c1); font-size: 14px; font-weight: 800; margin-bottom: 4px; }
.choice-stat {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: #c5cce0;
  font-weight: 600;
  margin: 2px 0;
  line-height: 1.35;
}
.choice-stat b { color: #f3f6ff; font-weight: 700; }
.choice-line { font-size: 13px; color: #c5cce0; line-height: 1.4; }
.choice-line.chg { color: #8fe3c1; font-weight: 700; font-size: 12px; }
.choice-line.muted { font-size: 12px; color: #8b93a7; font-weight: 600; margin-bottom: 4px; }
@keyframes cardIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; }
}
.chest-panel { border-color: #c9a227; }
.chest-title { color: #ffd166; }
.chest-card { border: 1px solid rgba(255, 209, 102, 0.35); }
.luck-rates { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.luck-row { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; font-weight: 700; }
.luck-row.dim { opacity: 0.55; }
.luck-row .luck-up { font-weight: 800; filter: brightness(1.15); }

.train-grid { grid-template-columns: 1fr 1fr; }
.train-card h3 { text-align: center; margin-bottom: 6px; font-size: 15px; }
.train-vals { text-align: center; font-weight: 800; margin: 6px 0; color: #8fe3c1; font-size: 15px; }
.train-price { text-align: center; color: var(--gold); font-weight: 700; margin-bottom: 8px; }
.train-desc { font-size: 14px; color: var(--muted); text-align: center; margin-bottom: 8px; line-height: 1.4; }

.confirm-box { text-align: center; }
.confirm-box p { margin: 12px 0 18px; line-height: 1.5; }
.pause-panel {
  width: min(94%, 760px);
  text-align: center;
}
.pause-skills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 10px 0 14px;
  text-align: left;
}
.pause-card {
  background: #22283a;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 12px;
  position: relative;
  overflow: hidden;
  flex: 1 1 160px;
  max-width: 240px;
  pointer-events: none;
}
.pause-skills[data-n="1"] .pause-card { flex: 0 1 260px; max-width: 280px; }
.pause-skills[data-n="2"] .pause-card { flex: 1 1 42%; max-width: 300px; }
.pause-skills[data-n="3"] .pause-card { flex: 1 1 30%; }
.pause-skills[data-n="4"] .pause-card { flex: 1 1 42%; max-width: 300px; }
.pause-skills[data-n="5"] .pause-card { flex: 1 1 30%; }

.toast {
  position: absolute;
  left: 50%;
  top: 18%;
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(8, 12, 24, 0.82);
  border: 1px solid #2c3348;
  font-weight: 800;
  text-align: center;
  animation: fadeToast 1.8s ease forwards;
}
.pickup-banner {
  position: absolute;
  left: 50%;
  top: 12%;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 10px;
  background: rgba(8, 12, 24, 0.88);
  border: 1px solid #2c3348;
  text-align: center;
  pointer-events: none;
  animation: fadePickup 1.1s ease forwards;
  z-index: 16;
}
.pickup-title { font-weight: 800; font-size: 18px; line-height: 1.2; }
.pickup-sub { font-weight: 700; font-size: 14px; margin-top: 3px; opacity: 0.95; }
@keyframes fadePickup {
  0% { opacity: 0; transform: translate(-50%, -8px); }
  12% { opacity: 1; transform: translate(-50%, 0); }
  78% { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes fadeToast {
  0% { opacity: 0; transform: translate(-50%, -8px); }
  12% { opacity: 1; transform: translate(-50%, 0); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

.r-advanced { color: #4dff88; }
.r-rare { color: #4da6ff; }
.r-hero { color: #c07bff; }
.r-legend { color: #ffe14d; }

#joystick-base {
  position: absolute;
  left: 18px;
  bottom: 18px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.06);
  pointer-events: none;
}
#joystick-knob {
  position: absolute;
  left: 35px;
  top: 35px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(94, 234, 212, 0.85);
}

@media (max-width: 900px) {
  .ad-side { display: none; }
  .app-mid { grid-template-columns: 1fr; }
  #game-viewport { width: min(92vw, 78vh, 820px); }
  .choice-grid, .stat-grid { grid-template-columns: 1fr; }
  .lobby-train { grid-template-columns: 1fr 1fr; }
  #sound-dock { right: 8px; bottom: 8px; }
  .pause-skills[data-n="3"] .pause-card,
  .pause-skills[data-n="5"] .pause-card { flex-basis: 42%; max-width: 300px; }
  .hud-left { max-width: 48%; }
  .stat-hud { font-size: 11px; }
  .boss-hud { left: 24%; right: 18%; }
}
@media (pointer: coarse) {
  .skill-strip { bottom: 124px; max-width: 58%; }
}
@media (max-width: 520px) {
  .lobby-train { grid-template-columns: 1fr; }
  .lobby-shell { overflow: auto; }
  .stat-hud { font-size: 11px; }
  .hud-left { max-width: 52%; }
  .pause-card { flex-basis: 100%; max-width: none; }
}

#dev-panel {
  position: absolute;
  left: 8px;
  top: 8px;
  z-index: 40;
  width: min(420px, calc(100% - 16px));
  max-height: calc(100% - 16px);
  overflow: auto;
  background: rgba(12, 16, 24, 0.94);
  border: 1px solid #3a4560;
  border-radius: 10px;
  padding: 10px;
  color: #e8eefc;
  font-size: 12px;
  line-height: 1.35;
  user-select: text;
  touch-action: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}
#dev-panel .dev-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
#dev-panel .dev-head strong { color: #5eead4; font-size: 13px; }
#dev-panel .dev-time { margin-left: auto; color: #c5cce0; }
#dev-panel .dev-note { color: #9aa6c2; margin-bottom: 8px; font-size: 11px; }
#dev-panel .dev-skill {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 6px;
  align-items: center;
  padding: 3px 0;
  border-bottom: 1px solid #2a3348;
}
#dev-panel .dev-cur { color: #8fe3c1; min-width: 36px; text-align: right; }
#dev-panel .dev-lvs { display: flex; gap: 3px; }
#dev-panel button {
  background: #2a3146;
  color: #f3f6ff;
  border: 1px solid #3d4863;
  border-radius: 6px;
  padding: 3px 7px;
  cursor: pointer;
  font-size: 11px;
}
#dev-panel button:hover { background: #36405a; }
#dev-panel button.on { background: #1d6b62; border-color: #5eead4; }
#dev-panel .dev-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 8px;
}
#dev-panel .dev-row.tiny button { padding: 2px 6px; font-size: 10px; color: #c5cce0; }

