/* ============================================
   JUJUTSU KAISEN — CURSED CHRONICLES
   Vanilla CSS Game Styles
   ============================================ */

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

:root {
  --bg:        #0b0d14;
  --bg2:       #11141f;
  --bg3:       #181c2a;
  --border:    #232840;
  --text:      #dde3f0;
  --muted:     #5a6080;
  --primary:   #4a8cff;
  --secondary: #e0395a;
  --accent:    #9b59d0;
  --gold:      #f0b429;
  --green:     #3ecf7c;
  --font-d:    'Noto Serif JP', serif;
  --font-b:    'Space Grotesk', sans-serif;
  --radius:    4px;
}

body { background: var(--bg); color: var(--text); font-family: var(--font-b); min-height: 100vh; }

#root { display: none !important; }

#game-root { min-height: 100vh; }

/* ---- Screens ---- */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; }

/* ---- Title Screen ---- */
#screen-title {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 2rem;
  text-align: center;
}
.title-kanji {
  font-family: var(--font-d);
  font-size: clamp(8rem, 20vw, 16rem);
  color: rgba(74,140,255,0.04);
  position: absolute;
  bottom: -2rem;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  white-space: nowrap;
  animation: breathe 5s ease-in-out infinite;
}
@keyframes breathe { 0%,100%{opacity:.04} 50%{opacity:.09} }
.title-sub {
  font-family: var(--font-d);
  font-size: 1.1rem;
  color: var(--muted);
  letter-spacing: .5em;
  margin-bottom: 1rem;
}
.title-main {
  font-family: var(--font-d);
  font-size: clamp(3rem, 10vw, 6rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -.02em;
}
.title-main span { color: var(--primary); }
.title-tagline {
  font-size: .75rem;
  color: var(--muted);
  letter-spacing: .3em;
  text-transform: uppercase;
  margin-top: 1.5rem;
}
.title-divider {
  width: 6rem;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  margin: 2rem auto;
}
.title-buttons { display: flex; flex-direction: column; align-items: center; gap: .75rem; margin-top: 1rem; }
.save-info { font-size: .7rem; color: var(--muted); margin-top: .25rem; }

/* Particles */
.particle {
  position: absolute;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--primary);
  opacity: 0;
  pointer-events: none;
  animation: float-up var(--dur, 5s) var(--delay, 0s) infinite;
}
@keyframes float-up {
  0%   { transform: translateY(0);    opacity: 0; }
  20%  { opacity: .6; }
  100% { transform: translateY(-60vh); opacity: 0; }
}

/* ---- Creation Screen ---- */
#screen-creation {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}
.creation-box { width: 100%; max-width: 680px; }
.creation-step { display: none; }
.creation-step.active { display: block; }
.creation-label {
  font-family: var(--font-d);
  font-size: .7rem;
  color: var(--muted);
  letter-spacing: .3em;
  text-transform: uppercase;
  margin-bottom: .5rem;
}
.creation-title {
  font-family: var(--font-d);
  font-size: clamp(1.5rem, 5vw, 2.2rem);
  font-weight: 700;
  margin-bottom: 2rem;
}
.name-input {
  display: block;
  width: 100%;
  max-width: 380px;
  margin: 0 auto 1.5rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-b);
  font-size: 1.1rem;
  padding: .85rem 1rem;
  border-radius: var(--radius);
  text-align: center;
  outline: none;
  transition: border-color .2s;
}
.name-input:focus { border-color: var(--primary); }

/* Technique cards grid */
.tech-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: .75rem; margin-bottom: 2rem; }
.tech-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s;
  text-align: left;
}
.tech-card:hover { border-color: rgba(74,140,255,.4); }
.tech-card.selected { border-color: var(--primary); box-shadow: 0 0 20px rgba(74,140,255,.12); }
.tech-name { font-family: var(--font-d); font-weight: 700; font-size: .95rem; margin-bottom: .3rem; }
.tech-desc { font-size: .75rem; color: var(--muted); line-height: 1.5; margin-bottom: .8rem; }
.tech-stats { display: grid; grid-template-columns: 1fr 1fr; gap: .3rem .75rem; }
.stat-row { display: flex; align-items: center; gap: .4rem; font-size: .7rem; color: var(--muted); }
.pip-row { display: flex; gap: 2px; margin-left: auto; }
.pip { width: 6px; height: 6px; border-radius: 50%; background: var(--bg3); }
.pip.filled { background: var(--primary); }

/* Prodigy display in creation */
.prodigy-reveal {
  background: var(--bg2);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}
.prodigy-reveal-label { font-size: .65rem; color: var(--gold); letter-spacing: .3em; text-transform: uppercase; margin-bottom: .25rem; }
.prodigy-reveal-name { font-family: var(--font-d); font-size: 1.1rem; font-weight: 700; color: var(--gold); margin-bottom: .2rem; }
.prodigy-reveal-desc { font-size: .75rem; color: var(--muted); line-height: 1.5; }

/* ---- Game Screen ---- */
#screen-game {
  flex-direction: column;
  min-height: 100vh;
}
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.game-header-title { font-family: var(--font-d); font-size: 1rem; font-weight: 700; }
.game-header-sub  { font-size: .65rem; color: var(--muted); letter-spacing: .2em; text-transform: uppercase; }
.header-actions { display: flex; align-items: center; gap: 1rem; }
.autosave-dot { font-size: .65rem; color: var(--muted); display: flex; align-items: center; gap: .35rem; }
.autosave-dot::before { content:''; display:inline-block; width:6px; height:6px; border-radius:50%; background:var(--green); }

.game-body {
  display: flex;
  flex: 1;
  gap: 1.5rem;
  padding: 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}
.game-main { flex: 1; min-width: 0; }
.game-sidebar { width: 240px; flex-shrink: 0; }
@media (max-width: 768px) {
  .game-body { flex-direction: column; padding: 1rem; }
  .game-sidebar { width: 100%; }
}

/* ---- Story Scene ---- */
.story-scene {}
.story-chapter-label { font-size: .65rem; color: var(--muted); letter-spacing: .3em; text-transform: uppercase; margin-bottom: .3rem; }
.story-title { font-family: var(--font-d); font-size: clamp(1.3rem, 4vw, 2rem); font-weight: 700; margin-bottom: .75rem; }
.story-divider { width: 4rem; height: 1px; background: rgba(74,140,255,.4); margin-bottom: 1.5rem; }
.story-text { font-size: .9rem; line-height: 1.85; color: rgba(221,227,240,.9); margin-bottom: 2rem; }
.story-text p { margin-bottom: .75rem; }
.story-text strong { color: var(--primary); font-weight: 600; }
.story-text em { color: var(--muted); font-style: italic; }
.choices { display: flex; flex-direction: column; gap: .6rem; border-top: 1px solid rgba(255,255,255,.06); padding-top: 1.25rem; }
.choice-btn {
  display: flex;
  align-items: center;
  gap: .75rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .8rem 1rem;
  color: rgba(221,227,240,.8);
  font-family: var(--font-b);
  font-size: .85rem;
  cursor: pointer;
  text-align: left;
  transition: border-color .2s, background .2s, color .2s;
}
.choice-btn:hover { border-color: rgba(74,140,255,.5); background: rgba(74,140,255,.05); color: var(--text); }
.choice-arrow { color: rgba(74,140,255,.5); flex-shrink: 0; transition: color .2s; }
.choice-btn:hover .choice-arrow { color: var(--primary); }
.ending-msg { text-align: center; padding: 3rem 0; }
.ending-msg p { font-family: var(--font-d); font-size: 1.3rem; color: var(--primary); margin-bottom: .5rem; }
.ending-msg small { color: var(--muted); font-size: .8rem; }

/* ---- Battle Scene ---- */
.battle-scene {}
.battle-enemy-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}
.battle-enemy-name { font-family: var(--font-d); font-size: 1.1rem; font-weight: 700; }
.battle-enemy-grade { font-size: .7rem; color: var(--secondary); margin-bottom: .5rem; }
.hp-bar-wrap { background: var(--bg3); border-radius: 2px; height: 8px; overflow: hidden; margin-bottom: .3rem; }
.hp-bar-fill { height: 100%; background: var(--secondary); border-radius: 2px; transition: width .4s ease; }
.hp-label { font-size: .7rem; color: var(--muted); }

.battle-log {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  height: 180px;
  overflow-y: auto;
  margin-bottom: 1rem;
  scroll-behavior: smooth;
}
.log-entry {
  font-size: .8rem;
  line-height: 1.6;
  padding: .2rem 0;
  border-bottom: 1px solid rgba(255,255,255,.03);
}
.log-entry:last-child { border-bottom: none; }
.log-system  { color: var(--muted); }
.log-player  { color: var(--primary); }
.log-enemy   { color: var(--secondary); }
.log-domain  { color: var(--accent); font-weight: 600; }
.log-victory { color: var(--green); }
.log-defeat  { color: var(--secondary); font-weight: 600; }
.log-warning { color: var(--gold); }

.enemy-wait { text-align: center; font-size: .75rem; color: var(--muted); margin-bottom: .75rem; animation: pulse 1.5s infinite; }
@keyframes pulse { 0%,100%{opacity:.4} 50%{opacity:1} }

.skills-label { font-size: .65rem; color: var(--muted); letter-spacing: .25em; text-transform: uppercase; margin-bottom: .5rem; }
.skills-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-bottom: .75rem; }
.skill-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem .75rem;
  color: var(--text);
  font-family: var(--font-b);
  font-size: .75rem;
  cursor: pointer;
  text-align: left;
  transition: border-color .2s, background .2s;
  display: flex;
  flex-direction: column;
  gap: .15rem;
}
.skill-btn:hover:not(:disabled) { border-color: rgba(74,140,255,.4); background: rgba(74,140,255,.05); }
.skill-btn:disabled { opacity: .4; cursor: not-allowed; }
.skill-btn-name { font-weight: 600; }
.skill-btn-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: .7rem; }
.domain-btn {
  width: 100%;
  background: rgba(155,89,208,.08);
  border: 1px solid rgba(155,89,208,.3);
  border-radius: var(--radius);
  color: var(--accent);
  font-family: var(--font-b);
  font-size: .8rem;
  padding: .75rem 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: .5rem;
  transition: background .2s;
  margin-bottom: .75rem;
}
.domain-btn:hover:not(:disabled) { background: rgba(155,89,208,.15); }
.domain-btn:disabled { opacity: .4; cursor: not-allowed; }
.domain-btn .ce-cost { margin-left: auto; font-size: .72rem; }

.battle-end-btn-wrap { text-align: center; padding-top: 1rem; }

/* ---- Player Sidebar ---- */
.sidebar-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}
.sidebar-label  { font-size: .6rem; color: var(--muted); letter-spacing: .25em; text-transform: uppercase; margin-bottom: .2rem; }
.sidebar-name   { font-family: var(--font-d); font-size: 1.05rem; font-weight: 700; margin-bottom: .1rem; }
.sidebar-tech   { font-size: .72rem; color: var(--primary); margin-bottom: .1rem; }
.sidebar-grade  { font-size: .72rem; font-weight: 600; }

.bar-group { margin-top: .75rem; }
.bar-label-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: .3rem; }
.bar-label { font-size: .7rem; color: var(--muted); display: flex; align-items: center; gap: .35rem; }
.bar-val { font-size: .7rem; }
.bar-track { background: var(--bg3); border-radius: 2px; height: 6px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 2px; transition: width .5s ease; }
.bar-hp  { background: var(--secondary); }
.bar-ce  { background: var(--primary); }
.bar-xp  { background: var(--gold); }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; margin-top: .75rem; padding-top: .75rem; border-top: 1px solid var(--border); }
.stat-item { display: flex; align-items: center; justify-content: space-between; font-size: .72rem; color: var(--muted); }
.stat-item span { color: var(--text); font-weight: 600; }

.prodigy-badge {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  background: rgba(240,180,41,.06);
  border: 1px solid rgba(240,180,41,.2);
  border-radius: var(--radius);
  padding: .6rem .75rem;
  margin-top: .5rem;
  font-size: .72rem;
}
.prodigy-badge-icon { color: var(--gold); font-size: 1rem; flex-shrink: 0; margin-top: .05rem; }
.prodigy-badge-name { color: var(--gold); font-weight: 600; font-size: .72rem; }
.prodigy-badge-desc { color: var(--muted); font-size: .68rem; line-height: 1.4; }

.domain-unlocked { font-size: .72rem; color: var(--accent); display: flex; align-items: center; gap: .4rem; margin-top: .5rem; padding-top: .5rem; border-top: 1px solid var(--border); }

/* ---- Level Up Modal ---- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(11,13,20,.82);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--bg2);
  border: 1px solid rgba(74,140,255,.3);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  max-width: 380px;
  width: 100%;
  text-align: center;
  position: relative;
  box-shadow: 0 0 60px rgba(74,140,255,.12);
  animation: pop-in .35s cubic-bezier(.34,1.56,.64,1);
}
@keyframes pop-in { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-rank-label { font-size: .65rem; color: var(--muted); letter-spacing: .4em; text-transform: uppercase; margin-bottom: .5rem; }
.modal-level { font-family: var(--font-d); font-size: 2.8rem; font-weight: 900; display: flex; align-items: center; justify-content: center; gap: .5rem; }
.modal-level-star { color: var(--primary); font-size: 1.2rem; }
.modal-grade { font-weight: 600; margin-top: .25rem; font-size: .9rem; }
.modal-divider { width: 4rem; height: 1px; background: linear-gradient(90deg, transparent, var(--primary), transparent); margin: 1rem auto; }
.modal-rewards-label { font-size: .65rem; color: var(--muted); letter-spacing: .25em; text-transform: uppercase; text-align: left; margin-bottom: .5rem; }
.modal-reward-item {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  background: rgba(74,140,255,.05);
  border: 1px solid rgba(74,140,255,.1);
  border-radius: var(--radius);
  padding: .5rem .75rem;
  margin-bottom: .4rem;
  text-align: left;
  font-size: .78rem;
  color: rgba(221,227,240,.9);
}
.modal-reward-icon { color: var(--primary); flex-shrink: 0; margin-top: .1rem; }

/* ---- Game Over ---- */
#screen-gameover {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
}
.gameover-sub   { font-family: var(--font-d); font-size: .9rem; color: var(--muted); letter-spacing: .4em; text-transform: uppercase; margin-bottom: 1rem; }
.gameover-title { font-family: var(--font-d); font-size: clamp(3rem, 10vw, 5rem); font-weight: 900; color: var(--secondary); margin-bottom: 1.5rem; }
.gameover-msg   { color: var(--muted); font-size: .85rem; max-width: 400px; line-height: 1.7; margin-bottom: 2rem; }

/* ---- Shared Buttons ---- */
.btn {
  font-family: var(--font-b);
  font-size: .8rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: .75rem 2rem;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .2s, border-color .2s, color .2s, box-shadow .2s;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}
.btn-primary {
  background: rgba(74,140,255,.1);
  border-color: rgba(74,140,255,.35);
  color: var(--primary);
}
.btn-primary:hover { background: rgba(74,140,255,.2); border-color: var(--primary); box-shadow: 0 0 24px rgba(74,140,255,.15); }
.btn-secondary {
  background: rgba(224,57,90,.1);
  border-color: rgba(224,57,90,.3);
  color: var(--secondary);
}
.btn-secondary:hover { background: rgba(224,57,90,.2); }
.btn-ghost {
  background: transparent;
  border-color: rgba(255,255,255,.12);
  color: var(--muted);
}
.btn-ghost:hover { color: var(--text); border-color: rgba(255,255,255,.25); }
.btn-sm { padding: .45rem 1rem; font-size: .72rem; }
.btn-xs { padding: .3rem .7rem; font-size: .68rem; letter-spacing: .08em; }

/* ---- Black Flash streak indicator ---- */
.bf-streak {
  background: rgba(74,140,255,.08);
  border: 1px solid rgba(74,140,255,.25);
  border-radius: var(--radius);
  padding: .4rem .75rem;
  margin-bottom: .6rem;
  font-size: .75rem;
  color: var(--primary);
  font-weight: 600;
  letter-spacing: .05em;
  text-align: center;
  animation: bfPulse 1.5s ease-in-out infinite;
}
@keyframes bfPulse {
  0%,100% { box-shadow: 0 0 0 rgba(74,140,255,0); }
  50% { box-shadow: 0 0 12px rgba(74,140,255,.3); }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ---- Fade animations ---- */
.fade-in { animation: fadeIn .4s ease forwards; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.shake { animation: shake .4s ease; }
@keyframes shake { 0%,100%{transform:translateX(0)} 20%{transform:translateX(-8px)} 40%{transform:translateX(8px)} 60%{transform:translateX(-4px)} 80%{transform:translateX(4px)} }