@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;700;900&family=Cinzel:wght@700;900&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box
}

/* Splash */
#splash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  transition: opacity .5s ease
}

#splash.fade-out {
  opacity: 0;
  pointer-events: none
}

.splash-title {
  font-family: 'Cinzel', serif;
  font-weight: 900;
  font-size: 28px;
  color: var(--gold);
  letter-spacing: 4px;
  text-shadow: 0 0 30px rgba(240, 192, 64, .3)
}

@keyframes dotPulse {

  0%,
  100% {
    opacity: .3
  }

  50% {
    opacity: 1
  }
}

.splash-loading {
  font-size: 12px;
  color: var(--dim);
  letter-spacing: 3px;
  animation: dotPulse 1.2s ease-in-out infinite
}

:root {
  --bg: #0a0e1a;
  --panel: #111827;
  --gold: #f0c040;
  --gold-d: #a08020;
  --blue: #3b82f6;
  --red: #ef4444;
  --green: #22c55e;
  --text: #e2e8f0;
  --dim: #64748b
}

html,
body {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Sans KR', sans-serif;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent
}

/* ═══ Custom Scrollbar (Game Theme) ═══ */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--gold-d) rgba(10, 14, 26, .6)
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px
}

::-webkit-scrollbar-track {
  background: rgba(10, 14, 26, .6);
  border-left: 1px solid rgba(240, 192, 64, .08)
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--gold), var(--gold-d));
  border-radius: 3px;
  border: 1px solid rgba(240, 192, 64, .3)
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #f5d060, var(--gold))
}

::-webkit-scrollbar-corner {
  background: transparent
}

#app {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column
}

/* ═══ Modal ═══ */
#modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0, 0, 0, .75);
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px)
}

#modal-overlay.show {
  display: flex
}

#modal-box {
  background: linear-gradient(180deg, #151d30, #111827);
  border: 2px solid var(--gold-d);
  border-radius: 12px;
  padding: 28px 32px;
  text-align: center;
  box-shadow: 0 0 40px rgba(240, 192, 64, .12), 0 8px 32px rgba(0, 0, 0, .5);
  max-width: 340px;
  width: 90%;
  max-height: 85dvh;
  overflow-y: auto
}

#modal-title {
  font-family: 'Cinzel', serif;
  font-weight: 900;
  font-size: 24px;
  margin-bottom: 8px
}

#modal-title.win {
  color: var(--gold)
}

#modal-title.lose {
  color: var(--red)
}

#modal-sub {
  color: var(--text);
  font-size: 12px;
  margin-bottom: 16px;
  max-height: 60dvh;
  overflow-y: auto
}

.modal-btn {
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 12px;
  background: linear-gradient(135deg, var(--gold), #d4a017);
  color: #1a1a2e;
  border: none;
  padding: 8px 22px;
  border-radius: 6px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: all .2s;
  margin: 3px
}

.modal-btn:hover {
}

.modal-btn:disabled,
.modal-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
  transform: none
}

.modal-btn.secondary {
  background: linear-gradient(135deg, #475569, #334155);
  color: #e2e8f0
}

/* ═══ Common Layout (non-battle) ═══ */
body:not([data-page="battle"]) {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden
}

#top-nav {
  height: 48px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  position: relative;
  background: linear-gradient(180deg, #151d30, var(--panel));
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  box-shadow: 0 1px 8px rgba(0, 0, 0, .3);
  z-index: 10
}

#nav-back {
  position: absolute;
  left: 12px;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0
}

#nav-back svg {
  width: 20px;
  height: 20px;
  stroke: var(--text);
  stroke-width: 2.5;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round
}

#nav-back.hidden {
  visibility: hidden
}

#nav-title {
  width: 100%;
  text-align: center;
  font-family: 'Cinzel', serif;
  font-weight: 900;
  font-size: 16px;
  color: var(--gold);
  letter-spacing: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

#nav-settings {
  position: absolute;
  right: 12px;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  color: var(--dim);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0
}

#nav-settings svg {
  width: 20px;
  height: 20px;
  stroke: var(--dim);
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round
}

#nav-settings.hidden {
  visibility: hidden
}

#content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: radial-gradient(ellipse at 50% 20%, #1e2d4a, #0a0e1a);
  position: relative
}

#bottom-nav {
  height: 56px;
  flex-shrink: 0;
  display: flex;
  background: var(--panel);
  border-top: 1px solid rgba(240, 192, 64, .1);
  z-index: 10
}

.bnav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--dim);
  cursor: pointer;
  transition: color .2s
}

.bnav-tab.active {
  color: var(--gold);
  position: relative
}

.bnav-tab.active::after{content:'';position:absolute;bottom:4px;width:16px;height:2px;
  background:var(--gold);border-radius:1px}

.bnav-icon {
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center
}

.bnav-icon img {
  width: 22px;
  height: 22px;
  opacity: .5;
  transition: opacity .2s, filter .2s
}

.bnav-tab.active .bnav-icon img {
  opacity: 1;
  filter: brightness(1) sepia(1) hue-rotate(10deg) saturate(5)
}

.bnav-label {
  font-size: 10px;
  font-weight: 700
}

/* ═══ Gold Badge ═══ */
.gold-badge {
  display: inline-flex;
  align-items: center;
  font-size: 14px;
  color: var(--gold);
  font-weight: 700;
  background: rgba(240, 192, 64, .08);
  border: 1px solid rgba(240, 192, 64, .25);
  border-radius: 20px;
  padding: 4px 16px;
  box-shadow: 0 0 8px rgba(240, 192, 64, .1)
}

.gold-badge img {
  width: 18px;
  height: auto;
  vertical-align: middle;
  margin-right: 4px
}

/* ═══ Screen Common ═══ */
.screen-title {
  font-family: 'Cinzel', serif;
  font-weight: 900;
  font-size: 20px;
  color: var(--gold);
  letter-spacing: 2px;
  margin-bottom: 4px
}

.screen-sub {
  font-size: 11px;
  color: var(--dim);
  margin-bottom: 8px;
  text-align: center
}

.screen-gold {
  font-size: 12px;
  color: var(--gold);
  font-weight: 700;
  margin-bottom: 12px;
  background: rgba(240, 192, 64, .08);
  border: 1px solid rgba(240, 192, 64, .15);
  border-radius: 14px;
  padding: 3px 12px
}

/* ═══ Card List (Generic) ═══ */
.card-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 16px;
  min-height: 60px;
  width: 100%;
}

/* ═══ Unified Tabs ═══ */
.game-tab-wrap{width:100%;display:flex;justify-content:center;padding:8px 0;border-bottom:1px solid rgba(255,255,255,.06)}
.game-tabs{display:flex;flex-wrap:wrap;gap:6px;max-width:330px;width:100%}
.game-tab{flex:1 1 auto;min-width:28%;padding:10px 6px;font-size:11px;font-weight:700;color:var(--dim);
  background:rgba(255,255,255,.04);border:1px solid rgba(255,255,255,.08);border-radius:8px;
  cursor:pointer;transition:all .2s;text-align:center}
.game-tab:hover{color:var(--text);background:rgba(255,255,255,.08);border-color:rgba(255,255,255,.15)}
.game-tab.active{color:#fff;background:rgba(240,192,64,.12);border-color:var(--gold);
  box-shadow:0 0 12px rgba(240,192,64,.1)}

/* ═══ Unified HUD ═══ */
.page-hud{width:100%;display:flex;justify-content:center;padding:12px 0 8px;margin-bottom:4px}

/* ═══ Unified Info Row ═══ */
.page-info-row{width:100%;max-width:330px;padding:12px 0;margin-bottom:8px}
.page-info-title{font-size:14px;font-weight:900;color:var(--text)}

/* ═══ Unified Game Card ═══ */
.game-card{width:100%;max-width:340px;display:flex;align-items:center;gap:10px;
  background:rgba(255,255,255,.04);border:1px solid rgba(255,255,255,.1);border-radius:10px;
  padding:10px 12px;transition:all .2s}
.game-card:hover{border-color:rgba(255,255,255,.2);background:rgba(255,255,255,.06);
  box-shadow:0 4px 12px rgba(0,0,0,.2)}
.game-card-icon{font-size:28px;flex-shrink:0}
.game-card-info{flex:1;min-width:0}
.game-card-name{font-weight:700;font-size:12px}
.game-card-sub{font-size:10px;color:var(--dim);margin-top:2px}

/* ═══ Unified Action Button ═══ */
.game-btn{font-weight:700;font-size:11px;padding:6px 14px;border-radius:6px;border:none;
  cursor:pointer;color:#fff;transition:all .15s;white-space:nowrap;
  box-shadow:0 2px 4px rgba(0,0,0,.2)}
.game-btn:hover{filter:brightness(1.1)}
.game-btn:active{transform:scale(.97)}
.game-btn.disabled{opacity:.35;cursor:default;transform:none;filter:none}
.game-btn--gold{background:linear-gradient(135deg,var(--gold),#d4a017);color:#1a1a2e}
.game-btn--purple{background:linear-gradient(135deg,#a855f7,#7c3aed)}
.game-btn--blue{background:linear-gradient(135deg,#60a5fa,#3b82f6)}
.game-btn--green{background:linear-gradient(135deg,#4ade80,#16a34a)}
.game-btn--red{background:linear-gradient(135deg,#ef4444,#dc2626)}

/* ═══ Unified Progress Bar ═══ */
.game-bar{width:100%;height:6px;background:rgba(255,255,255,.08);border-radius:3px;overflow:hidden}
.game-bar-fill{height:100%;border-radius:3px;transition:width .3s}
.game-bar--gold .game-bar-fill{background:linear-gradient(90deg,var(--gold),#d4a017)}
.game-bar--purple .game-bar-fill{background:linear-gradient(90deg,#a78bfa,#7c3aed)}
.game-bar--green .game-bar-fill{background:linear-gradient(90deg,#4ade80,#16a34a)}
.game-bar--red .game-bar-fill{background:linear-gradient(90deg,#ef4444,#dc2626)}

/* ═══ Page Scroll ═══ */
.page-scroll #content{overflow-y:auto;-webkit-overflow-scrolling:touch;padding-bottom:24px}
.page-scroll #content>*{flex-shrink:0}

/* ═══ Utility ═══ */
.hidden{display:none!important}

/* ═══ EXP Bar (Party Card) ═══ */
.cc-exp {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 3px
}

.cc-exp-bar {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, .1);
  border-radius: 2px;
  overflow: hidden
}

.cc-exp-fill {
  height: 100%;
  background: linear-gradient(90deg, #a78bfa, #7c3aed);
  border-radius: 2px;
  transition: width .3s
}

.cc-exp-txt {
  font-size: 7px;
  color: #a78bfa;
  min-width: 30px;
  text-align: right
}

/* ═══ Release Button (Party Card) ═══ */
.cc-release-btn {
  font-weight: 700;
  font-size: 9px;
  padding: 4px 10px;
  margin: 4px 0 0 0;
  border: none;
  border-radius: 4px;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  cursor: pointer;
  transition: all .15s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .2)
}

.cc-release-btn:hover {
  box-shadow: 0 2px 4px rgba(239, 68, 68, .4)
}

.cc-release-btn:active {
  transform: scale(.95)
}

/* ═══ Class Icon (Emoji) ═══ */
.cls-icon {
  display: inline-block;
  vertical-align: middle;
  line-height: 1;
  image-rendering: pixelated;
  border-radius: 3px
}

/* ═══ Skill Sprite Icon ═══ */
.skill-icon {
  display: inline-block;
  width: 20px;
  height: 20px;
  background: url('../image/icon/skill-sprite.png') no-repeat;
  background-size: 160px 140px;
  image-rendering: pixelated;
  vertical-align: middle;
  border-radius: 2px;
  flex-shrink: 0
}

/* ═══ Settings UI ═══ */
.settings-content{width:100%;max-width:300px;display:flex;flex-direction:column;gap:12px;margin-bottom:16px}
.sp-row{display:flex;align-items:center;justify-content:space-between;gap:8px}
.sp-row .sp-label{font-size:11px;font-weight:700;color:var(--text);white-space:nowrap;min-width:60px}
.sp-row .sp-val{font-size:10px;color:var(--dim);min-width:28px;text-align:right}
.sp-row input[type="range"]{flex:1;height:4px;accent-color:var(--gold);cursor:pointer;
  -webkit-appearance:none;appearance:none;background:rgba(255,255,255,.1);border-radius:2px;outline:none}
.sp-row input[type="range"]::-webkit-slider-thumb{-webkit-appearance:none;width:14px;height:14px;
  border-radius:50%;background:var(--gold);cursor:pointer;border:2px solid #1a1a2e}
.sp-row select{flex:1;font-size:11px;font-weight:700;padding:6px 8px;border-radius:6px;
  background:rgba(255,255,255,.08);color:var(--text);border:1px solid rgba(255,255,255,.12);outline:none;cursor:pointer}
.sp-row select:focus{border-color:var(--gold)}
.sp-toggle{display:flex;align-items:center;gap:8px}
.sp-tlabel{font-size:11px;font-weight:700;color:var(--text);flex:1;cursor:default}
.sp-switch{position:relative;width:38px;height:20px;flex-shrink:0}
.sp-switch input{opacity:0;width:0;height:0}
.sp-switch .slider{position:absolute;inset:0;background:rgba(255,255,255,.1);border-radius:10px;transition:.2s;cursor:pointer}
.sp-switch .slider:before{content:'';position:absolute;width:16px;height:16px;border-radius:50%;
  left:2px;bottom:2px;background:#64748b;transition:.2s}
.sp-switch input:checked+.slider{background:rgba(240,192,64,.3)}
.sp-switch input:checked+.slider:before{transform:translateX(18px);background:var(--gold)}
.sp-icon{display:inline-flex;align-items:center;vertical-align:middle;margin-right:5px;font-style:normal}
.sp-icon svg{width:14px;height:14px;stroke:var(--gold);stroke-width:2;fill:none;stroke-linecap:round;stroke-linejoin:round}
.sp-divider{height:1px;background:rgba(255,255,255,.06)}
.sp-btn{font-family:'Noto Sans KR',sans-serif;font-weight:700;font-size:10px;
  padding:5px 14px;border-radius:5px;cursor:pointer;border:1px solid rgba(255,255,255,.12);
  color:var(--text);background:rgba(255,255,255,.06);transition:all .15s}
.sp-btn:hover{background:rgba(255,255,255,.12);border-color:var(--gold)}
.sp-btn.danger{color:var(--red);border-color:rgba(239,68,68,.3)}
.sp-btn.danger:hover{background:rgba(239,68,68,.1)}
.sp-btn.danger .sp-icon svg{stroke:var(--red)}
.sp-link{font-size:10px;color:var(--dim);text-decoration:none;transition:color .15s}
.sp-link:hover{color:var(--gold);text-decoration:underline}

/* ═══ Compendium & Report Pages (Fixed Header) ═══ */
body[data-page^="compendium"],
body[data-page="class-balance-report"],
body[data-page="skill-balance-report"] {
  display: flex !important;
  flex-direction: column !important;
  height: 100dvh;
  overflow: hidden !important;
  padding-top: 0 !important;
}

body[data-page^="compendium"] #top-nav,
body[data-page="class-balance-report"] #top-nav,
body[data-page="skill-balance-report"] #top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  z-index: 1000;
  background: var(--panel);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  display: flex;
  align-items: center;
}

body[data-page^="compendium"] main,
body[data-page="class-balance-report"] main,
body[data-page="skill-balance-report"] main {
  margin-top: 60px;
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 64px 16px;
}

/* ═══ PC (1024px+) Common ═══ */
@media(min-width:1024px) {
  #nav-settings svg {
    width: 26px;
    height: 26px
  }

  #top-nav {
    height: 56px
  }

  #nav-back {
    left: 16px;
    width: 40px;
    height: 40px
  }

  #nav-settings {
    right: 16px;
    width: 40px;
    height: 40px
  }

  #nav-title {
    font-size: 20px
  }

  #bottom-nav {
    height: 64px
  }

  .bnav-icon img {
    width: 26px;
    height: 26px
  }

  .bnav-label {
    font-size: 12px
  }

  #content {
    padding: 24px
  }

  .gold-badge {
    font-size: 18px;
    padding: 6px 22px
  }

  .screen-title {
    font-size: 26px
  }

  .screen-sub {
    font-size: 14px
  }

  .game-tabs{max-width:480px}
  .game-tab{font-size:13px;padding:12px 8px}
  .page-info-row{max-width:480px}
  .page-info-title{font-size:17px}
  .game-card{max-width:460px;padding:14px 16px}

  .settings-content {
    max-width: 380px
  }

  .sp-row .sp-label {
    font-size: 13px
  }

  .sp-row .sp-val {
    font-size: 12px
  }

  .sp-tlabel {
    font-size: 13px
  }

  .sp-btn {
    font-size: 12px;
    padding: 6px 16px
  }

  /* Modal PC */
  #modal-box {
    padding: 38px 44px;
    border-radius: 14px;
    max-width: 420px
  }

  #modal-title {
    font-size: 32px;
    margin-bottom: 10px
  }

  #modal-sub {
    font-size: 16px;
    margin-bottom: 22px
  }

  .modal-btn {
    font-size: 16px;
    padding: 10px 30px;
    border-radius: 8px;
    margin: 4px
  }

  /* Compendium & Report PC */
  body[data-page^="compendium"] #top-nav,
  body[data-page="class-balance-report"] #top-nav,
  body[data-page="skill-balance-report"] #top-nav {
    height: 64px
  }

  body[data-page^="compendium"] main,
  body[data-page="class-balance-report"] main,
  body[data-page="skill-balance-report"] main {
    margin-top: 64px;
    padding: 24px 24px 80px 24px;
  }
}