/* ============ Kül Kulesi — Ashspire UI kit ============ */
:root {
  --coal: #0a0610;
  --coal-2: #14101f;
  --panel: #171126;
  --panel-2: #1f1833;
  --ember: #b94ee0;        /* purple ember */
  --ember-hot: #e673ff;
  --cinder: #ff5a3c;       /* crimson cinder */
  --ice: #6fd4ff;          /* cold ice blue */
  --ash: #b9a9c9;
  --text: #e8def2;
  --dim: #8d7fa3;
  --gold: #ffd76a;
}

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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--coal);
  color: var(--text);
  font-family: 'VT323', 'Courier New', monospace;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#game-root {
  position: fixed; inset: 0;
  width: 100vw; height: 100dvh;
  overflow: hidden;
  background: var(--coal);
}

#game-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
}

.hidden { display: none !important; }

/* ============ Wordmark ============ */
.wordmark {
  font-family: 'Cinzel', Georgia, serif;
  font-weight: 900;
  letter-spacing: 0.18em;
  color: var(--ember-hot);
  text-shadow: 0 0 18px rgba(185,78,224,.8), 0 0 42px rgba(255,90,60,.35), 0 2px 0 #2a1038;
  text-align: center;
  font-size: clamp(34px, 9vw, 64px);
  line-height: 1.05;
}
.wordmark.small { font-size: clamp(22px, 5vw, 38px); letter-spacing: 0.14em; }
.subtitle {
  font-family: 'Cinzel', Georgia, serif;
  letter-spacing: 0.6em;
  text-align: center;
  color: var(--cinder);
  font-size: clamp(10px, 2.2vw, 15px);
  margin-top: 4px;
  text-shadow: 0 0 12px rgba(255,90,60,.7);
}

/* ============ Screens ============ */
.screen {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, rgba(40,20,60,.55), rgba(6,4,10,.92) 70%);
  z-index: 40;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}
.screen-inner { width: min(560px, 94vw); display: flex; flex-direction: column; gap: 18px; align-items: center; }

.panel {
  background: linear-gradient(160deg, var(--panel-2), var(--panel) 60%);
  border: 1px solid var(--ember);
  box-shadow: 0 0 0 1px #0a0610, 0 0 24px rgba(185,78,224,.25), inset 0 0 34px rgba(0,0,0,.55);
  padding: 26px 26px 22px;
  border-radius: 2px;
  position: relative;
}
.panel::before {
  content: ""; position: absolute; inset: 4px;
  border: 1px solid rgba(185,78,224,.28);
  pointer-events: none; border-radius: 1px;
}

#menu-bg {
  position: absolute; inset: 0;
  background-size: cover; background-position: center 30%;
  opacity: .9;
  filter: saturate(1.05);
}
#screen-menu .screen-inner { position: relative; z-index: 2; background: linear-gradient(180deg, rgba(10,6,16,.35), rgba(10,6,16,.72)); padding: 30px 20px; border-radius: 2px; }

/* ============ Buttons ============ */
.btn {
  font-family: 'Cinzel', Georgia, serif;
  font-weight: 700;
  letter-spacing: 0.14em;
  font-size: clamp(13px, 2.6vw, 17px);
  color: var(--text);
  background: linear-gradient(180deg, #241a3a, #191228);
  border: 1px solid var(--ember);
  padding: 12px 30px;
  cursor: pointer;
  border-radius: 2px;
  text-transform: uppercase;
  transition: transform .06s, box-shadow .12s, background .12s;
  min-height: 46px;
  min-width: 210px;
  box-shadow: 0 0 12px rgba(185,78,224,.18), inset 0 1px 0 rgba(255,255,255,.08);
}
.btn:hover { box-shadow: 0 0 20px rgba(185,78,224,.5); background: linear-gradient(180deg, #2d2149, #1e1733); }
.btn:active { transform: scale(.96); }
.btn.primary {
  background: linear-gradient(180deg, var(--ember) 0%, #7a2aa8 100%);
  color: #160a20;
  border-color: var(--ember-hot);
  box-shadow: 0 0 26px rgba(185,78,224,.55);
}
.btn.primary:hover { box-shadow: 0 0 34px rgba(230,115,255,.7); }
.btn.small { font-size: 12px; padding: 8px 16px; min-width: 0; min-height: 38px; }

.menu-buttons { display: flex; flex-direction: column; gap: 12px; align-items: center; width: 100%; }
.menu-foot { display: flex; gap: 14px; align-items: center; justify-content: center; margin-top: 6px; flex-wrap: wrap; }
.credit { color: var(--dim); font-size: 13px; letter-spacing: .1em; }

#menu-souls, #relic-souls {
  font-size: 22px; color: var(--gold);
  text-shadow: 0 0 10px rgba(255,215,106,.5);
  letter-spacing: .08em;
}

/* ============ HUD ============ */
#hud {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 20;
  padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  display: flex; justify-content: space-between; align-items: flex-start;
}
#hud-left { display: flex; flex-direction: column; gap: 6px; }
#hp-wrap { display: flex; flex-direction: column; gap: 3px; }
#hp-bar {
  position: relative;
  width: clamp(150px, 30vw, 240px); height: 16px;
  background: #0d0714;
  border: 1px solid var(--ember);
  box-shadow: 0 0 10px rgba(185,78,224,.25);
}
#hp-fill {
  position: absolute; inset: 1px; width: 100%;
  background: linear-gradient(90deg, #7a2aa8, var(--cinder));
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.35);
  transition: width .15s;
}
#hp-text {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: #fff; text-shadow: 0 1px 2px #000;
}
#flask-pips { display: flex; gap: 5px; }
.pip {
  width: 16px; height: 14px;
  border: 1px solid var(--cinder);
  background: linear-gradient(180deg, #7a1d10, #3a0e06);
  box-shadow: 0 0 6px rgba(255,90,60,.4);
}
.pip.empty { background: #1a1020; border-color: #4a3558; box-shadow: none; }
#soul-display { display: flex; align-items: center; gap: 6px; font-size: 20px; color: var(--gold); text-shadow: 0 0 8px rgba(255,215,106,.5); }
#soul-icon {
  width: 14px; height: 14px;
  background: radial-gradient(circle at 35% 35%, #ffd76a, #b94ee0 70%);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(185,78,224,.9);
}

#hud-center { display: flex; flex-direction: column; align-items: center; gap: 5px; }
#floor-label {
  font-family: 'Cinzel', Georgia, serif;
  font-size: clamp(13px, 2.4vw, 17px);
  letter-spacing: .22em;
  color: var(--ember-hot);
  text-shadow: 0 0 10px rgba(185,78,224,.7);
}
#floor-pips { display: flex; gap: 4px; }
.fpip {
  width: 22px; height: 6px;
  background: #221632; border: 1px solid #4a3558;
}
.fpip.done { background: var(--ember); box-shadow: 0 0 8px rgba(185,78,224,.8); border-color: var(--ember-hot); }
.fpip.now { background: var(--cinder); border-color: var(--cinder); box-shadow: 0 0 8px rgba(255,90,60,.8); }

#hud-right { display: flex; align-items: center; gap: 8px; }
#weapon-box {
  display: flex; align-items: center; gap: 8px;
  background: rgba(13,7,20,.8);
  border: 1px solid var(--ember);
  padding: 4px 10px 4px 4px;
  box-shadow: 0 0 12px rgba(185,78,224,.2);
}
#weapon-icon {
  width: 30px; height: 30px;
  background-size: contain; background-repeat: no-repeat; background-position: center;
  image-rendering: pixelated;
}
#weapon-name { font-size: 17px; letter-spacing: .05em; color: var(--text); max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  pointer-events: auto;
  width: 42px; height: 42px;
  background: rgba(13,7,20,.85);
  border: 1px solid var(--ember);
  color: var(--ember-hot);
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(185,78,224,.25);
}

#boss-bar-wrap {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  width: min(440px, 70vw);
}
#boss-name { font-family: 'Cinzel', Georgia, serif; letter-spacing: .24em; font-size: 15px; color: var(--cinder); text-shadow: 0 0 10px rgba(255,90,60,.7); }
#boss-bar {
  width: 100%; height: 12px;
  background: #0d0714; border: 1px solid var(--cinder);
  box-shadow: 0 0 14px rgba(255,90,60,.4);
}
#boss-fill { position: absolute; inset: 1px; width: 100%; background: linear-gradient(90deg, #ff5a3c, #ffd76a); }

#toast {
  position: absolute; bottom: max(18px, env(safe-area-inset-bottom) + 8px);
  left: 50%; transform: translateX(-50%);
  font-size: 22px; color: var(--ember-hot);
  text-shadow: 0 0 12px rgba(185,78,224,.9);
  letter-spacing: .06em;
  background: rgba(10,6,16,.7);
  border: 1px solid var(--ember);
  padding: 6px 16px;
  opacity: 0; transition: opacity .25s;
  white-space: nowrap;
}
#toast.show { opacity: 1; }

/* ============ Mobile controls ============ */
#mobile-controls {
  position: absolute; inset: 0;
  z-index: 30;
  pointer-events: none;
  touch-action: none;
}
#joy-zone {
  position: absolute; left: 0; bottom: 0;
  width: 52%; height: 78%;
  pointer-events: auto;
}
#joy-base {
  position: absolute; width: 128px; height: 128px;
  border-radius: 50%;
  border: 2px solid rgba(185,78,224,.55);
  background: rgba(20,12,32,.35);
  box-shadow: 0 0 18px rgba(185,78,224,.2);
  transform: translate(-50%, -50%);
}
#joy-knob {
  position: absolute; top: 50%; left: 50%;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--ember-hot), var(--ember) 70%);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 14px rgba(185,78,224,.8);
}
#btn-zone {
  position: absolute; right: max(10px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom) + 6px);
  display: flex; align-items: flex-end; gap: 12px;
  pointer-events: auto;
}
.mbtn {
  width: 74px; height: 74px;
  border-radius: 50%;
  border: 2px solid var(--ember);
  background: radial-gradient(circle at 35% 30%, rgba(60,35,90,.85), rgba(18,12,30,.9));
  color: var(--ember-hot);
  font-size: 28px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 16px rgba(185,78,224,.35);
  pointer-events: auto;
  touch-action: none;
}
.mbtn:active { transform: scale(.92); background: radial-gradient(circle, rgba(120,60,170,.9), rgba(40,22,60,.95)); }
#btn-jump { width: 86px; height: 86px; font-size: 30px; }
#btn-atk { width: 80px; height: 80px; }
#btn-dash { width: 62px; height: 62px; font-size: 22px; margin-bottom: 10px; }

/* ============ Relics ============ */
#relic-list { display: flex; flex-direction: column; gap: 10px; width: 100%; max-height: 56dvh; overflow-y: auto; padding: 2px; }
.relic-row {
  display: flex; align-items: center; gap: 12px;
  background: rgba(20,14,34,.8);
  border: 1px solid rgba(185,78,224,.4);
  padding: 8px 10px;
}
.relic-row.locked { opacity: .65; }
.relic-icon { width: 40px; height: 40px; background-size: contain; background-repeat: no-repeat; background-position: center; image-rendering: pixelated; flex: 0 0 40px; }
.relic-info { flex: 1; min-width: 0; }
.relic-name { font-size: 19px; color: var(--text); letter-spacing: .04em; }
.relic-desc { font-size: 15px; color: var(--dim); line-height: 1.25; }
.relic-btn {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 13px;
  letter-spacing: .1em;
  padding: 8px 14px;
  background: linear-gradient(180deg, #2d2149, #1a1328);
  border: 1px solid var(--gold);
  color: var(--gold);
  cursor: pointer;
  min-width: 96px;
}
.relic-btn:disabled { border-color: #3c2f4d; color: #5b4b6e; cursor: default; }

/* ============ Choice cards ============ */
#choice-cards { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.choice-card {
  width: 168px;
  background: linear-gradient(160deg, #221834, #150f24);
  border: 1px solid var(--ember);
  padding: 14px 12px;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  box-shadow: 0 0 16px rgba(185,78,224,.25);
  transition: transform .08s, box-shadow .15s;
}
.choice-card:hover { transform: translateY(-3px); box-shadow: 0 0 26px rgba(230,115,255,.5); }
.choice-icon { width: 46px; height: 46px; border-radius: 50%; background-size: cover; background-position: center; image-rendering: pixelated; }
.choice-name { font-family: 'Cinzel', Georgia, serif; font-size: 15px; letter-spacing: .08em; color: var(--ember-hot); text-align: center; }
.choice-desc { font-size: 15px; color: var(--ash); text-align: center; line-height: 1.3; min-height: 64px; }

/* ============ Story / misc ============ */
.story-text { font-size: clamp(16px, 3.4vw, 20px); line-height: 1.65; color: var(--ash); text-align: center; max-width: 520px; }
.story-text.small { font-size: clamp(14px, 2.8vw, 17px); }
#intro-text::before, #intro-text::after { content: "❖"; display: block; color: var(--ember); margin: 6px 0; font-size: 14px; }
.death-title { color: var(--cinder); text-shadow: 0 0 18px rgba(255,90,60,.8), 0 2px 0 #2a1038; }
#death-stats, #end-stats { font-size: 18px; color: var(--ash); text-align: center; line-height: 1.6; }
#end-title { color: var(--gold); }

#howto-body { font-size: 17px; color: var(--ash); line-height: 1.7; max-width: 520px; }
#howto-body b { color: var(--ember-hot); }
#howto-body .k { color: var(--gold); }

#rotate-hint {
  position: absolute; inset: 0; z-index: 60;
  background: rgba(10,6,16,.92);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
}
#rotate-hint p { font-size: 22px; color: var(--ember-hot); letter-spacing: .08em; }

#menu-progress { position: absolute; bottom: 22px; left: 0; right: 0; text-align: center; color: var(--dim); font-size: 18px; letter-spacing: .2em; }

@media (max-width: 700px) {
  .mbtn { width: 64px; height: 64px; font-size: 24px; }
  #btn-jump { width: 76px; height: 76px; }
  #btn-atk { width: 70px; height: 70px; }
  #btn-dash { width: 54px; height: 54px; font-size: 20px; }
}
