/* 「#お戦士ティブ の戦い」 — Dark Gothic Silver & Violet Fantasy Theme */
:root {
  --bg-dark: #130b1f;
  --panel-bg: rgba(20, 12, 34, 0.90);
  --panel-border: #a78bfa;
  --panel-border-dim: rgba(196, 181, 253, 0.35);
  --violet-bright: #c084fc;
  --violet-deep: #6b21a8;
  --emerald: #34d399;
  --gold: #fcd34d;
  --text-main: #f8f5ff;
  --text-sub: #c4b5fd;
  --danger: #fb7185;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-dark);
  color: var(--text-main);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", "Segoe UI", sans-serif;
  user-select: none;
  touch-action: none;
}

#gameRoot {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.hidden {
  display: none !important;
}

/* ==================== HUD ==================== */
.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  padding: max(12px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}

.hud-top-left {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

/* Ornate Hero Portrait Frame */
.portrait-frame {
  position: relative;
  width: 74px;
  height: 74px;
  border-radius: 6px;
  border: 2.5px solid #d8b4fe;
  box-shadow:
    0 0 0 2px #24123a,
    0 0 14px rgba(168, 85, 247, 0.55),
    inset 0 0 10px rgba(0, 0, 0, 0.7);
  background: #1b0f2e;
  overflow: hidden;
  flex-shrink: 0;
  pointer-events: auto;
  cursor: pointer;
}

.portrait-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.level-badge {
  position: absolute;
  bottom: 0;
  right: 0;
  background: rgba(20, 10, 38, 0.9);
  border-top: 1px solid #c084fc;
  border-left: 1px solid #c084fc;
  color: var(--gold);
  font-size: 11px;
  font-weight: 800;
  padding: 1px 5px;
  border-top-left-radius: 5px;
  letter-spacing: 0.03em;
}

.vitals-column {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 2px;
}

/* Purple Hearts Row */
.hearts-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px;
  max-width: 268px;
  filter: drop-shadow(0 2px 3px rgba(15, 6, 30, 0.75));
}

.hearts-row.many-hearts .heart-icon {
  width: 20px;
  height: 20px;
}

.heart-icon {
  width: 24px;
  height: 24px;
  display: inline-flex;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.heart-icon svg {
  width: 100%;
  height: 100%;
}

.heart-icon.full svg path {
  fill: url(#heartGrad);
  fill: #a855f7;
  stroke: #f3e8ff;
  stroke-width: 1.5;
  filter: drop-shadow(0 0 4px rgba(192, 132, 252, 0.7));
}

.heart-icon.empty svg path {
  fill: rgba(22, 14, 34, 0.82);
  stroke: rgba(167, 139, 250, 0.45);
  stroke-width: 1.5;
}

/* Ornate Attack Gauge Bar */
.gauge-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

@media (max-width: 960px) {
  .gauge-wrap {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
}

.gauge-frame {
  position: relative;
  width: 196px;
  height: 15px;
  background: rgba(16, 10, 28, 0.88);
  border: 2px solid #c4b5fd;
  border-radius: 4px;
  box-shadow: 0 0 0 1.5px #221238, 0 3px 8px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.gauge-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #6d28d9 0%, #a855f7 65%, #e9d5ff 100%);
  transition: width 0.05s linear;
}

.gauge-shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.34) 0%, rgba(255,255,255,0) 52%);
  pointer-events: none;
}

.gauge-frame.is-max {
  border-color: #fef08a;
  box-shadow: 0 0 14px rgba(216, 180, 254, 0.95), 0 0 4px #fde047;
  animation: gaugePulse 1s infinite alternate;
}

@keyframes gaugePulse {
  from { filter: brightness(1); }
  to { filter: brightness(1.3); }
}

.gauge-shake {
  animation: shakeX 0.24s ease;
}

@keyframes shakeX {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.special-ready-tag {
  font-size: 11px;
  font-weight: 800;
  color: #fef08a;
  background: rgba(88, 28, 135, 0.88);
  border: 1px solid #fde047;
  border-radius: 99px;
  padding: 2px 8px;
  text-shadow: 0 1px 4px #000;
  white-space: nowrap;
  animation: floatPulse 0.9s ease-in-out infinite alternate;
}

@keyframes floatPulse {
  from { transform: scale(1); }
  to { transform: scale(1.06); }
}

/* EXP Bar */
.exp-bar-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.exp-label {
  font-size: 10px;
  font-weight: 800;
  color: #bae6fd;
  text-shadow: 0 1px 3px #000;
}

.exp-track {
  width: 158px;
  height: 6px;
  background: rgba(15, 10, 28, 0.82);
  border: 1px solid rgba(147, 197, 253, 0.45);
  border-radius: 99px;
  overflow: hidden;
}

.exp-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #38bdf8, #818cf8);
  transition: width 0.25s ease;
}

/* Boss HP Bar — positioned cleanly below the top HUD & EXP bar so it never overlaps! */
.boss-bar-wrap {
  position: absolute;
  top: calc(max(12px, env(safe-area-inset-top)) + 104px);
  left: 50%;
  transform: translateX(-50%);
  width: min(540px, 72vw);
  text-align: center;
  background: rgba(18, 10, 32, 0.86);
  border: 1.5px solid #d8b4fe;
  border-radius: 10px;
  padding: 8px 16px 10px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.72), 0 0 18px rgba(244, 63, 94, 0.25);
}

@media (max-width: 960px) {
  .boss-bar-wrap {
    top: calc(max(12px, env(safe-area-inset-top)) + 118px);
    width: min(520px, 84vw);
  }
}

.boss-name {
  font-size: clamp(16px, 2.2vw, 21px);
  font-weight: 900;
  color: #fff1f2;
  letter-spacing: 0.06em;
  margin-bottom: 7px;
  text-shadow: 0 0 12px rgba(244, 63, 94, 0.85), 0 2px 5px #000;
}

.boss-hp-frame {
  width: 100%;
  height: 15px;
  background: #1a0d29;
  border: 1.5px solid #f472b6;
  border-radius: 99px;
  overflow: hidden;
}

.boss-hp-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #be123c, #f43f5e, #fb7185);
  transition: width 0.14s ease;
}

/* Final Boss Phase 2 Awakened Crimson-Gold HP Bar */
.boss-bar-wrap.phase2 {
  background: rgba(28, 6, 36, 0.92);
  border-color: #fb7185;
  box-shadow: 0 0 22px rgba(244, 63, 94, 0.65), 0 0 42px rgba(192, 132, 252, 0.45);
}

.boss-bar-wrap.phase2 .boss-name {
  color: #fef08a;
  text-shadow: 0 0 14px rgba(244, 63, 94, 0.95), 0 0 26px rgba(192, 132, 252, 0.85), 0 2px 5px #000;
}

.boss-bar-wrap.phase2 .boss-hp-frame {
  border-color: #fde047;
  box-shadow: inset 0 0 10px rgba(244, 63, 94, 0.55);
}

.boss-bar-wrap.phase2 .boss-hp-fill {
  background: linear-gradient(90deg, #9f1239, #e11d48, #d946ef, #fde047);
}

.boss-bar-wrap.refilling .boss-hp-fill {
  transition: none;
  box-shadow: 0 0 16px #fde047;
}

/* Top-Right Compact Chips (No Minimap!) */
.hud-top-right {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.hud-chip,
.hud-icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(20, 12, 34, 0.85);
  border: 1.5px solid rgba(196, 181, 253, 0.55);
  border-radius: 8px;
  color: var(--text-main);
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45);
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
}

.hud-chip:hover,
.hud-icon-btn:hover {
  border-color: #e9d5ff;
  background: rgba(42, 24, 68, 0.94);
  transform: translateY(-1px);
}

.hud-chip {
  padding: 5px 10px;
}

.weapon-chip-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.15;
}

.weapon-chip-info strong {
  font-size: 12px;
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.weapon-chip-info small {
  font-size: 10px;
  color: var(--text-sub);
}

.heal-chip {
  padding: 7px 10px;
  font-size: 13px;
}

.heal-chip.is-elixir,
.t-sub.is-elixir {
  border-color: #6ee7a8;
  box-shadow: 0 0 12px rgba(110, 231, 168, 0.55);
  color: #d1fae5;
}

.hud-icon-btn {
  width: 38px;
  height: 38px;
  justify-content: center;
  font-size: 17px;
}

/* Loot Pickup Toast */
.loot-toast {
  position: absolute;
  top: 76px;
  right: max(14px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(350px, 88vw);
  background: rgba(20, 12, 34, 0.94);
  border: 1.5px solid #c084fc;
  border-radius: 10px;
  padding: 9px 12px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.6);
  pointer-events: auto;
  animation: slideInRight 0.25s ease;
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

.loot-toast-title {
  font-size: 13px;
  font-weight: 800;
}

.loot-toast-sub {
  font-size: 11px;
  color: #ddd6fe;
  margin-top: 2px;
}

.btn-quick-equip {
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  border: 1px solid #f3e8ff;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}

/* Bottom-Right Ornate Stage Nameplate */
.stage-plate {
  position: absolute;
  bottom: max(14px, env(safe-area-inset-bottom));
  right: max(16px, env(safe-area-inset-right));
  min-width: 190px;
  background: linear-gradient(180deg, rgba(24, 15, 40, 0.92), rgba(14, 8, 24, 0.95));
  border: 2px solid #c4b5fd;
  border-radius: 6px;
  padding: 7px 14px 8px;
  box-shadow: 0 0 0 2px #1a0d2c, 0 6px 16px rgba(0, 0, 0, 0.6);
}

.stage-plate-top {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #f5f3ff;
}

.stage-compass {
  color: #d8b4fe;
  font-size: 16px;
}

.stage-progress-track {
  margin-top: 5px;
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 99px;
  overflow: hidden;
}

.stage-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #34d399, #c084fc);
}

/* ==================== Mobile Touch Controls ==================== */
.touch-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(14px, env(safe-area-inset-bottom));
  padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
}

.touch-left,
.touch-right {
  pointer-events: auto;
}

.touch-left {
  display: flex;
  gap: 12px;
}

.touch-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 54px; /* leave breathing room above stage plate */
}

.touch-row-top,
.touch-row-bottom {
  display: flex;
  gap: 10px;
  align-items: center;
}

.t-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 2px solid rgba(216, 180, 254, 0.65);
  background: rgba(20, 12, 36, 0.62);
  color: #f8f5ff;
  font-weight: 800;
  backdrop-filter: blur(4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  touch-action: none;
  transition: transform 0.08s ease, background 0.1s ease;
}

.t-btn.active {
  transform: scale(0.92);
  background: rgba(147, 51, 234, 0.78);
  border-color: #ffffff;
}

.t-dir {
  width: 62px;
  height: 62px;
  font-size: 22px;
}

.t-attack {
  width: 72px;
  height: 72px;
  font-size: 16px;
  background: rgba(126, 34, 206, 0.68);
  border-color: #e9d5ff;
}

.t-jump {
  width: 58px;
  height: 58px;
  font-size: 15px;
  background: rgba(16, 120, 90, 0.62);
  border-color: #6ee7b7;
}

.t-special {
  width: 56px;
  height: 56px;
  font-size: 13px;
  opacity: 0.65;
}

.t-special.ready {
  opacity: 1;
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.9), rgba(236, 72, 153, 0.9));
  border-color: #fef08a;
  box-shadow: 0 0 16px rgba(233, 213, 255, 0.9);
  animation: floatPulse 0.8s ease-in-out infinite alternate;
}

.t-sub {
  width: 50px;
  height: 50px;
  font-size: 12px;
  line-height: 1.1;
}

.t-sub em {
  font-style: normal;
  font-size: 11px;
  color: #d8b4fe;
}

.t-sub.empty {
  opacity: 0.48;
}

/* ==================== Modals & Title Screen ==================== */
.overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 6, 20, 0.58);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 30;
}

.gothic-panel {
  background: var(--panel-bg);
  border: 2px solid var(--panel-border);
  border-radius: 14px;
  box-shadow:
    0 0 0 3px rgba(18, 8, 34, 0.92),
    0 16px 48px rgba(0, 0, 0, 0.72),
    0 0 30px rgba(147, 51, 234, 0.3);
  color: var(--text-main);
}

.title-panel {
  max-width: 650px;
  width: 100%;
  padding: 24px 24px 22px;
  text-align: center;
}

.title-eyebrow {
  display: inline-block;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #6ee7b7;
  border: 1px solid rgba(110, 231, 183, 0.45);
  background: rgba(6, 78, 59, 0.45);
  border-radius: 99px;
  padding: 3px 12px;
  margin-bottom: 10px;
}

.game-title {
  font-size: clamp(26px, 5vw, 40px);
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #ffffff;
  text-shadow: 0 0 18px rgba(168, 85, 247, 0.85), 0 3px 6px rgba(0, 0, 0, 0.85);
}

.game-title span {
  color: #d8b4fe;
}

.title-desc {
  margin-top: 10px;
  font-size: 13.5px;
  line-height: 1.65;
  color: #e9d5ff;
}

.title-rules {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}

.rule-badge {
  font-size: 12px;
  background: rgba(124, 58, 237, 0.22);
  border: 1px solid rgba(196, 181, 253, 0.35);
  border-radius: 8px;
  padding: 5px 10px;
  color: #f3e8ff;
}

.title-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
}

/* ==================== Difficulty Picker (Title Screen) ==================== */
.difficulty-picker {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.diff-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 9px 6px;
  border-radius: 10px;
  background: rgba(24, 14, 44, 0.85);
  border: 1.5px solid rgba(196, 181, 253, 0.28);
  color: #e9d5ff;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.diff-btn:hover {
  transform: translateY(-2px);
  border-color: rgba(216, 180, 254, 0.7);
}

.diff-btn-top {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.03em;
}

.diff-btn small {
  font-size: 10px;
  color: #c4b5fd;
  line-height: 1.25;
}

.diff-btn.active {
  background: linear-gradient(155deg, rgba(124, 58, 237, 0.55), rgba(45, 20, 82, 0.95));
  border-color: #f5f3ff;
  box-shadow: 0 0 18px rgba(168, 85, 247, 0.55);
  color: #ffffff;
}

.diff-btn[data-diff="easy"].active {
  border-color: #6ee7b7;
  box-shadow: 0 0 16px rgba(110, 231, 183, 0.45);
}

.diff-btn[data-diff="normal"].active {
  border-color: #60a5fa;
  box-shadow: 0 0 16px rgba(96, 165, 250, 0.45);
}

.diff-btn[data-diff="hard"].active {
  border-color: #fb923c;
  box-shadow: 0 0 16px rgba(251, 146, 60, 0.48);
}

.diff-btn[data-diff="extra"].active {
  border-color: #e879f9;
  box-shadow: 0 0 18px rgba(232, 121, 249, 0.6);
}

.difficulty-detail {
  margin-top: 9px;
  padding: 7px 12px;
  border-radius: 9px;
  background: rgba(14, 8, 28, 0.76);
  border: 1px solid rgba(196, 181, 253, 0.28);
  font-size: 11.5px;
  font-weight: 700;
  color: #f3e8ff;
  line-height: 1.5;
}

@media (max-width: 600px) {
  .difficulty-picker {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.title-key-hint {
  margin-top: 16px;
  font-size: 11.5px;
  color: #c4b5fd;
  line-height: 1.5;
}

.btn-primary,
.btn-secondary,
.btn-danger,
.btn-close,
.btn-mini {
  border-radius: 9px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.15s ease;
}

.btn-primary {
  background: linear-gradient(135deg, #7c3aed, #a855f7, #c084fc);
  border: 1.5px solid #f5f3ff;
  color: #ffffff;
  font-size: 16px;
  padding: 12px 26px;
  box-shadow: 0 4px 18px rgba(147, 51, 234, 0.55);
}

.btn-secondary {
  background: rgba(34, 20, 56, 0.9);
  border: 1.5px solid #a78bfa;
  color: #ede9fe;
  font-size: 14px;
  padding: 11px 18px;
}

.btn-danger {
  background: rgba(159, 18, 57, 0.85);
  border: 1.5px solid #fda4af;
  color: #fff1f2;
  font-size: 13px;
  padding: 10px 18px;
}

.btn-close {
  background: rgba(42, 26, 68, 0.85);
  border: 1px solid rgba(196, 181, 253, 0.5);
  color: #ede9fe;
  font-size: 13px;
  padding: 6px 12px;
}

.btn-mini {
  background: rgba(124, 58, 237, 0.45);
  border: 1px solid #c4b5fd;
  color: #fff;
  font-size: 12px;
  padding: 5px 10px;
}

.btn-mini:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary:hover,
.btn-secondary:hover,
.btn-danger:hover,
.btn-mini:not(:disabled):hover {
  transform: translateY(-1px);
  filter: brightness(1.12);
}

/* Modal Layout */
.modal-panel {
  width: min(640px, 95vw);
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--panel-border-dim);
  background: rgba(30, 16, 52, 0.7);
}

.modal-header h2 {
  font-size: 18px;
  color: #f3e8ff;
}

.modal-scroll {
  padding: 16px 18px 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-section {
  margin-bottom: 18px;
}

.modal-section h3 {
  font-size: 13.5px;
  color: #c4b5fd;
  margin-bottom: 9px;
  letter-spacing: 0.04em;
}

.section-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.section-head-row h3 {
  margin-bottom: 0;
}

.preset-btns {
  display: flex;
  gap: 6px;
}

.helper-note {
  font-size: 11.5px;
  color: #a5b4fc;
  margin-bottom: 10px;
}

/* Stats & Inventory Grids */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 8px;
}

.stat-pill {
  background: rgba(34, 20, 58, 0.72);
  border: 1px solid rgba(196, 181, 253, 0.28);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-pill span {
  font-size: 11px;
  color: #c4b5fd;
}

.stat-pill strong {
  font-size: 15px;
  color: #ffffff;
}

.heal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
}

.heal-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(28, 18, 48, 0.78);
  border: 1px solid rgba(196, 181, 253, 0.3);
  border-radius: 9px;
  padding: 10px 12px;
}

.item-name {
  font-size: 13.5px;
  font-weight: 800;
}

.count-tag {
  color: #ffffff;
  margin-left: 4px;
}

.item-desc {
  font-size: 11.5px;
  color: #d8b4fe;
  margin-top: 2px;
}

.weapon-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.weapon-card {
  background: rgba(26, 16, 44, 0.85);
  border: 1.5px solid rgba(180, 155, 225, 0.25);
  border-radius: 10px;
  padding: 10px 12px;
}

.weapon-card.is-equipped {
  background: rgba(54, 28, 92, 0.55);
}

.weapon-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.rarity-pill {
  font-size: 10.5px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 99px;
}

.weapon-name {
  font-size: 14.5px;
  flex: 1;
}

.equipped-badge {
  font-size: 11px;
  font-weight: 800;
  background: #7c3aed;
  color: #fff;
  padding: 2px 8px;
  border-radius: 99px;
}

.diff-up { color: #6ee7b7; font-size: 12px; font-weight: 800; }
.diff-down { color: #fda4af; font-size: 12px; font-weight: 800; }
.diff-eq { color: #cbd5e1; font-size: 12px; }

.weapon-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  color: #e2e8f0;
  margin-top: 6px;
}

.weapon-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 7px;
}

.weapon-desc {
  font-size: 11.5px;
  color: #c4b5fd;
}

/* Keybinds & Settings */
.keybind-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(245px, 1fr));
  gap: 8px;
}

.keybind-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(28, 16, 48, 0.8);
  border: 1px solid rgba(196, 181, 253, 0.25);
  border-radius: 8px;
  padding: 7px 10px;
}

.keybind-label {
  font-size: 12.5px;
  color: #ede9fe;
}

.keybind-btn {
  min-width: 84px;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid #a78bfa;
  background: rgba(66, 36, 112, 0.75);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.keybind-btn.waiting {
  border-color: #fde047;
  background: rgba(161, 98, 7, 0.8);
  color: #fef08a;
  animation: floatPulse 0.7s infinite alternate;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(196, 181, 253, 0.14);
  font-size: 13px;
}

.gothic-select {
  background: #1f1236;
  color: #f5f3ff;
  border: 1px solid #a78bfa;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12.5px;
}

.modal-footer-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 8px;
}

.modal-wide {
  width: min(780px, 96vw);
}

.stage-select-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
}

.stage-select-card {
  text-align: left;
  background: rgba(24, 14, 42, 0.88);
  border: 1.5px solid rgba(196, 181, 253, 0.4);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text-main);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.stage-select-card:hover {
  transform: translateY(-2px);
  background: rgba(46, 26, 78, 0.94);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}

.stage-select-card.is-current {
  background: rgba(66, 34, 112, 0.88);
  box-shadow: 0 0 14px rgba(192, 132, 252, 0.5);
}

.stage-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.stage-num {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.stage-ico {
  font-size: 15px;
}

.stage-card-name {
  font-size: 15px;
  font-weight: 800;
  color: #ffffff;
}

.stage-card-en {
  font-size: 11px;
  color: #c4b5fd;
  margin-top: 1px;
}

.stage-card-boss {
  font-size: 10.5px;
  color: #fbcfe8;
  margin-top: 6px;
  padding-top: 5px;
  border-top: 1px solid rgba(196, 181, 253, 0.18);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Result Panels */
.result-panel {
  max-width: 520px;
  width: 95vw;
  padding: 24px 22px;
  text-align: center;
}

.result-badge {
  display: inline-block;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.14em;
  padding: 4px 14px;
  border-radius: 99px;
  margin-bottom: 10px;
}

.result-badge.fail {
  background: rgba(190, 18, 60, 0.4);
  border: 1px solid #fb7185;
  color: #fecdd3;
}

.result-badge.clear {
  background: rgba(16, 185, 129, 0.35);
  border: 1px solid #6ee7b7;
  color: #d1fae5;
}

.result-sub {
  font-size: 13px;
  color: #ddd6fe;
  margin: 8px 0 16px;
  line-height: 1.55;
}

.result-actions {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

/* ==================== Responsive Mobile Adjustments ==================== */
@media (max-width: 720px) {
  .portrait-frame {
    width: 56px;
    height: 56px;
  }
  .heart-icon {
    width: 18px;
    height: 18px;
  }
  .gauge-frame {
    width: 140px;
    height: 12px;
  }
  .exp-track {
    width: 112px;
  }
  .weapon-chip-info strong {
    max-width: 82px;
  }
  .stage-plate {
    min-width: 145px;
    padding: 5px 10px 6px;
  }
  .stage-plate-top {
    font-size: 13px;
  }
  .boss-bar-wrap {
    top: calc(max(10px, env(safe-area-inset-top)) + 108px);
    width: 88vw;
  }
  .t-dir {
    width: 56px;
    height: 56px;
  }
  .t-attack {
    width: 64px;
    height: 64px;
  }
  .t-jump {
    width: 52px;
    height: 52px;
  }
}

/* ==================== Stage Loading Transition Overlay ==================== */
.stage-loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 42%, #241342 0%, #120923 55%, #07040e 100%);
  opacity: 1;
  transition: opacity 0.28s ease;
  pointer-events: all;
}

.stage-loading-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.stage-loading-box {
  text-align: center;
  max-width: 440px;
  width: 100%;
  padding: 32px 28px 28px;
  border-radius: 16px;
  background: rgba(18, 10, 34, 0.85);
  border: 1.5px solid rgba(196, 181, 253, 0.45);
  box-shadow:
    0 0 0 3px rgba(10, 5, 22, 0.9),
    0 20px 60px rgba(0, 0, 0, 0.78),
    0 0 36px rgba(147, 51, 234, 0.35);
}

.stage-loading-icon {
  font-size: 38px;
  line-height: 1;
  margin-bottom: 10px;
  text-shadow: 0 0 22px rgba(216, 180, 254, 0.8);
  animation: loadingFloat 1.6s ease-in-out infinite;
}

.stage-loading-eyebrow {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.22em;
  color: #c4b5fd;
  margin-bottom: 6px;
}

.stage-loading-title {
  font-size: clamp(24px, 4.5vw, 32px);
  font-weight: 900;
  color: #ffffff;
  letter-spacing: 0.06em;
  text-shadow: 0 0 18px rgba(168, 85, 247, 0.85), 0 3px 8px rgba(0, 0, 0, 0.9);
}

.stage-loading-en {
  margin-top: 4px;
  font-size: 12.5px;
  letter-spacing: 0.12em;
  color: #a78bfa;
  text-transform: uppercase;
}

.stage-loading-bar {
  position: relative;
  height: 7px;
  margin: 22px auto 10px;
  max-width: 260px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(196, 181, 253, 0.35);
  overflow: hidden;
}

.stage-loading-bar-fill {
  position: absolute;
  inset: 0;
  width: 48%;
  border-radius: 99px;
  background: linear-gradient(90deg, #7c3aed, #d8b4fe, #6ee7b7);
  box-shadow: 0 0 14px rgba(192, 132, 252, 0.9);
  animation: loadingSlide 0.95s ease-in-out infinite alternate;
}

.stage-loading-caption {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: #d8b4fe;
  text-transform: uppercase;
}

@keyframes loadingSlide {
  0% { transform: translateX(-25%); }
  100% { transform: translateX(135%); }
}

@keyframes loadingFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

/* ==================== Weapon Encyclopedia / Codex Modal ==================== */
.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.codex-panel {
  max-width: 820px;
  width: 100%;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}

.codex-panel .modal-header h2 small {
  font-size: 13px;
  font-weight: 700;
  color: #c4b5fd;
  margin-left: 6px;
}

.codex-top-bar {
  padding: 12px 18px 10px;
  border-bottom: 1px solid rgba(196, 181, 253, 0.22);
  background: rgba(16, 8, 30, 0.55);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.codex-progress-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
  margin-bottom: 6px;
}

.codex-progress-labels strong {
  color: #f3e8ff;
}

.codex-progress-labels span {
  color: #ffd166;
  font-weight: 700;
  font-size: 12px;
}

.codex-progress-track {
  height: 9px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(196, 181, 253, 0.32);
  overflow: hidden;
}

.codex-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, #7c3aed, #c084fc, #6ee7b7);
  box-shadow: 0 0 12px rgba(192, 132, 252, 0.75);
  transition: width 0.35s ease;
}

.codex-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.codex-status-tabs {
  display: flex;
  gap: 6px;
}

.codex-tab {
  background: rgba(34, 20, 56, 0.85);
  border: 1px solid rgba(196, 181, 253, 0.32);
  color: #c4b5fd;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 99px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.codex-tab.active,
.codex-tab:hover {
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  border-color: #f5f3ff;
  color: #ffffff;
}

.codex-select {
  font-size: 12.5px;
  padding: 5px 10px;
}

.codex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
  padding: 14px 16px 20px;
}

.codex-card {
  position: relative;
  overflow: hidden;
  border-radius: 11px;
  padding: 11px 12px;
  background: rgba(24, 14, 44, 0.88);
  border: 1.5px solid rgba(196, 181, 253, 0.25);
  display: flex;
  flex-direction: column;
  gap: 7px;
  transition: transform 0.14s ease, border-color 0.15s ease, box-shadow 0.18s ease;
}

.codex-card.discovered.art-unlocked {
  cursor: pointer;
  box-shadow: 0 0 18px rgba(255, 209, 102, 0.25);
}

.codex-card.discovered.art-locked {
  cursor: default;
}

.codex-card.discovered.art-unlocked:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 26px rgba(255, 209, 102, 0.42);
}

.codex-card-art-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 22%;
  opacity: 0.22;
  filter: saturate(0.95);
  pointer-events: none;
  z-index: 0;
  transition: opacity 0.22s ease, transform 0.28s ease;
}

.codex-card.discovered.art-unlocked .codex-card-art-bg {
  opacity: 0.34;
  filter: saturate(1.18);
}

.codex-card.discovered::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(16, 9, 30, 0.62) 0%, rgba(18, 10, 36, 0.45) 50%, rgba(12, 6, 24, 0.82) 100%);
  pointer-events: none;
  z-index: 0;
}

.codex-card.discovered.art-unlocked:hover .codex-card-art-bg {
  opacity: 0.5;
  transform: scale(1.05);
}

.codex-card > *:not(.codex-card-art-bg) {
  position: relative;
  z-index: 1;
}

.codex-tap-hint {
  margin-top: auto;
  padding-top: 3px;
  font-size: 10.5px;
  font-weight: 800;
  color: #fde68a;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
}

.codex-tap-hint.locked {
  color: #a78bfa;
  font-weight: 700;
}

.codex-card.undiscovered {
  background: rgba(14, 9, 26, 0.72);
  border-color: rgba(148, 163, 184, 0.18);
  opacity: 0.78;
}

.codex-card-head {
  display: flex;
  align-items: center;
  gap: 9px;
}

.codex-svg-wrap {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 9px;
  background: radial-gradient(circle at 50% 50%, rgba(124, 58, 237, 0.26), rgba(10, 6, 22, 0.92));
  border: 1px solid rgba(196, 181, 253, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
}

.codex-card.undiscovered .codex-svg-wrap {
  background: rgba(12, 8, 22, 0.9);
  border-color: rgba(148, 163, 184, 0.18);
}

.codex-title-col {
  min-width: 0;
  flex: 1;
}

.codex-no-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 10.5px;
  color: #a78bfa;
  font-weight: 800;
}

.codex-card-name {
  font-size: 13.5px;
  font-weight: 800;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.codex-card.undiscovered .codex-card-name {
  color: #94a3b8;
  letter-spacing: 0.08em;
}

.codex-rarity-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}

.codex-dot {
  width: 17px;
  height: 15px;
  border-radius: 4px;
  font-size: 9.5px;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.codex-dot.got {
  color: #12081f;
  border-color: rgba(255, 255, 255, 0.7);
  box-shadow: 0 0 8px currentColor;
}

.codex-stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  font-size: 11px;
  color: #ddd6fe;
}

.codex-stat-chip {
  background: rgba(124, 58, 237, 0.18);
  border: 1px solid rgba(196, 181, 253, 0.22);
  border-radius: 6px;
  padding: 2px 6px;
}

.codex-stat-chip b {
  color: #ffffff;
}

.codex-prefix-note {
  font-size: 11px;
  color: #93c5fd;
  font-weight: 700;
}

.codex-desc {
  font-size: 11px;
  color: #c4b5fd;
  line-height: 1.45;
}

.codex-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 36px 16px;
  color: #a78bfa;
  font-size: 13.5px;
}

/* ==================== Full-Screen Service Illustration Lightbox ==================== */
.codex-art-viewer {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}

.codex-art-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 3, 14, 0.86);
  backdrop-filter: blur(8px);
}

.codex-art-frame {
  position: relative;
  z-index: 1;
  max-width: min(94vw, 620px);
  max-height: 94vh;
  display: flex;
  flex-direction: column;
  background: rgba(18, 10, 34, 0.94);
  border: 2px solid rgba(216, 180, 254, 0.65);
  border-radius: 16px;
  box-shadow:
    0 0 0 3px rgba(10, 5, 22, 0.92),
    0 24px 72px rgba(0, 0, 0, 0.85),
    0 0 42px rgba(168, 85, 247, 0.42);
  overflow: hidden;
  animation: codexArtPop 0.18s ease-out;
}

@keyframes codexArtPop {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}

.codex-art-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(196, 181, 253, 0.25);
  background: rgba(12, 6, 24, 0.72);
}

.codex-art-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

.codex-art-no {
  font-size: 11px;
  font-weight: 800;
  color: #c4b5fd;
  background: rgba(124, 58, 237, 0.3);
  border: 1px solid rgba(196, 181, 253, 0.4);
  border-radius: 6px;
  padding: 2px 7px;
}

.codex-art-name {
  font-size: 15px;
  font-weight: 900;
  color: #ffffff;
}

.codex-art-file {
  font-size: 11px;
  color: #94a3b8;
  font-family: monospace;
}

.codex-art-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  background: radial-gradient(circle at 50% 45%, rgba(88, 28, 135, 0.28), rgba(8, 4, 18, 0.95));
  cursor: pointer;
}

.codex-art-img {
  display: block;
  max-width: min(88vw, 560px);
  max-height: 74vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.7);
}

.codex-art-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 14px;
  border-top: 1px solid rgba(196, 181, 253, 0.22);
  background: rgba(12, 6, 24, 0.78);
}

.codex-art-hint {
  font-size: 11px;
  color: #a78bfa;
  text-align: center;
}

@media (max-width: 600px) {
  .codex-art-hint {
    display: none;
  }
}

/* PWA Install Button & Hint */
.btn-install-pwa {
  border-color: rgba(253, 224, 71, 0.72);
  color: #fef08a;
  background: linear-gradient(135deg, rgba(88, 28, 135, 0.78), rgba(159, 18, 57, 0.62));
  box-shadow: 0 0 14px rgba(244, 63, 94, 0.28);
}

.btn-install-pwa:hover {
  border-color: #fde047;
  box-shadow: 0 0 20px rgba(253, 224, 71, 0.42);
}

.pwa-install-hint {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #fde68a;
  text-align: center;
  padding: 6px 12px;
  border-radius: 99px;
  background: rgba(30, 14, 54, 0.78);
  border: 1px solid rgba(253, 224, 71, 0.35);
}
