/* ============================================================
   THE NIGHT SASUKE LEAVES — mobile-first visual novel styles
   Style follows the world's visual style: bold cel-shaded 2000s
   action anime, orange-black palette, blue/red chakra glow.
   ============================================================ */

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0b0a14;
  color: #f0e8d8;
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#game {
  position: fixed;
  inset: 0;
  max-width: 560px;
  margin: 0 auto;
  overflow: hidden;
  background: #0b0a14;
}

.hidden { display: none !important; }

/* ---------- Shared background layers ---------- */
.bg-layer {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 0.9s ease;
  z-index: 0;
}
.bg-layer.show { opacity: 1; }

.vignette {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 38%, rgba(0,0,0,0) 40%, rgba(4,3,10,0.45) 100%),
    linear-gradient(180deg, rgba(6,5,14,0.35) 0%, rgba(6,5,14,0) 22%, rgba(6,5,14,0) 55%, rgba(6,5,14,0.72) 100%);
}

/* ---------- Screens ---------- */
.screen {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: none;
  overflow: hidden;
}
.screen.active { display: flex; }

/* ============================================================
   TITLE SCREEN
   ============================================================ */
#screen-title {
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.title-art {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: saturate(1.08) brightness(0.82);
}
.title-art::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 62% 34%, rgba(255,122,26,0.22) 0%, transparent 52%),
    radial-gradient(ellipse at 30% 72%, rgba(52,104,224,0.18) 0%, transparent 55%),
    linear-gradient(180deg, rgba(10,9,18,0.5) 0%, rgba(12,9,22,0.28) 38%, rgba(9,8,18,0.88) 100%);
}

.title-shade { position: absolute; inset: 0; }

.title-content {
  position: relative;
  z-index: 2;
  padding: 2rem 1.6rem calc(1.4rem + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  animation: fadeUp 0.9s ease both;
}

.title-eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: #ff9f3c;
  text-shadow: 0 2px 10px rgba(0,0,0,0.8);
  margin-bottom: 0.9rem;
}

.title-main {
  font-size: clamp(2.5rem, 11vw, 3.8rem);
  font-weight: 900;
  line-height: 1.08;
  letter-spacing: 0.01em;
  color: #ff7b1a;
  text-shadow:
    0 0 46px rgba(255,120,20,0.55),
    0 3px 10px rgba(0,0,0,0.85);
  margin-bottom: 0.9rem;
}

.title-tagline {
  font-size: 0.88rem;
  color: #cfc3d8;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
  max-width: 300px;
  line-height: 1.5;
  margin-bottom: 2.4rem;
}

.title-endings {
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  color: #9a8fb0;
  margin-top: 1rem;
  text-transform: uppercase;
}

.title-credit {
  font-size: 0.66rem;
  color: #6f6486;
  margin-top: 0.8rem;
  letter-spacing: 0.06em;
}

/* ---------- Buttons ---------- */
.btn {
  display: block;
  width: 100%;
  max-width: 280px;
  margin: 0.5rem auto;
  padding: 0.95rem 1.6rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.96); }

.btn-primary {
  background: linear-gradient(135deg, #e85d04 0%, #c22602 100%);
  box-shadow: 0 6px 26px rgba(220,47,2,0.4), inset 0 1px 0 rgba(255,255,255,0.22);
}
.btn-primary:hover { transform: scale(1.02); box-shadow: 0 8px 32px rgba(220,47,2,0.55); }

.btn-secondary {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.16);
  color: #d8cbe8;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 0.8rem 1.6rem;
}
.btn-secondary:hover { background: rgba(255,255,255,0.12); }

/* ============================================================
   GAME SCREEN
   ============================================================ */
#screen-game { background: #0d0c18; }

/* ---------- Meter ---------- */
.meter {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  left: 14px;
  right: 14px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(10,8,20,0.55);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.5s ease, transform 0.5s ease;
  pointer-events: none;
}
.meter.visible { opacity: 1; transform: translateY(0); }

.meter-label {
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: #ff9f3c;
  white-space: nowrap;
  text-transform: uppercase;
}
.meter-track {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  width: 50%;
  background: linear-gradient(90deg, #4a6fe0 0%, #b85de0 45%, #ff8c1a 78%, #ffd23c 100%);
  border-radius: 3px;
  box-shadow: 0 0 12px rgba(255,140,26,0.55);
  transition: width 0.7s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.meter-value {
  font-size: 0.62rem;
  font-weight: 800;
  color: #ffd9a8;
  min-width: 20px;
  text-align: right;
}

/* ---------- Chapter label ---------- */
.chapter {
  position: absolute;
  top: calc(46px + env(safe-area-inset-top));
  left: 0;
  right: 0;
  z-index: 19;
  text-align: center;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: #ffd9a8;
  text-shadow: 0 2px 12px rgba(0,0,0,0.9);
  opacity: 0;
  transition: opacity 0.6s ease;
  pointer-events: none;
}
.chapter.show { opacity: 1; }

/* ---------- Portrait ---------- */
.portrait-wrap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 26%;
  height: 47%;
  z-index: 3;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  pointer-events: none;
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 0.45s ease, transform 0.45s ease;
}
.portrait-wrap.show { opacity: 1; transform: translateY(0); }

#portrait {
  max-height: 100%;
  max-width: 86%;
  object-fit: contain;
  object-position: bottom center;
  filter: drop-shadow(0 0 34px rgba(0,0,0,0.65)) saturate(1.05);
}

/* ---------- Choices ---------- */
.choices {
  position: absolute;
  left: 14px;
  right: 14px;
  top: 45%;
  transform: translateY(-50%);
  z-index: 12;
  display: flex;
  flex-direction: column;
  gap: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}
.choices.active { opacity: 1; pointer-events: auto; }

.choice-btn {
  display: block;
  width: 100%;
  padding: 0.85rem 1rem;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.42;
  text-align: left;
  color: #f2e9da;
  background: rgba(16,12,30,0.86);
  border: 1px solid rgba(255,140,40,0.3);
  border-left: 3px solid #ff8c1a;
  border-radius: 8px;
  cursor: pointer;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
  animation: choiceIn 0.32s ease both;
}
.choice-btn:nth-child(2) { animation-delay: 0.07s; }
.choice-btn:nth-child(3) { animation-delay: 0.14s; }
.choice-btn:hover { background: rgba(46,30,64,0.92); border-color: rgba(255,140,40,0.7); }
.choice-btn:active { transform: scale(0.97); }

@keyframes choiceIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Dialogue ---------- */
.dialogue {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  padding: 30px 18px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg,
    rgba(12,10,22,0) 0%,
    rgba(12,10,22,0.9) 16%,
    rgba(12,10,22,0.97) 100%);
  border-top: 1px solid rgba(255,255,255,0.07);
  cursor: pointer;
  min-height: 132px;
}

.speaker {
  display: none;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #ff9f3c;
  margin-bottom: 0.42rem;
  align-items: center;
  gap: 8px;
}
.speaker.visible { display: flex; }
.speaker::before {
  content: "";
  width: 14px;
  height: 2px;
  background: linear-gradient(90deg, #ff8c1a, transparent);
}

.text {
  font-size: clamp(0.9rem, 4vw, 1.02rem);
  line-height: 1.58;
  min-height: 3.1em;
  color: #efe7d8;
  text-shadow: 0 1px 6px rgba(0,0,0,0.7);
}

.adv {
  position: absolute;
  bottom: calc(10px + env(safe-area-inset-bottom));
  right: 18px;
  font-size: 0.72rem;
  color: rgba(255,255,255,0.5);
  opacity: 0;
  animation: bounce 0.9s ease-in-out infinite;
  pointer-events: none;
  transition: opacity 0.3s;
}
.adv.visible { opacity: 1; }

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

/* ---------- Skip tip ---------- */
.skip-tip {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 30;
  font-size: 1.05rem;
  font-weight: 900;
  letter-spacing: 0.3em;
  color: rgba(255,150,40,0.75);
  text-shadow: 0 0 18px rgba(255,120,20,0.5);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.skip-tip.visible { opacity: 1; }

/* ============================================================
   ENDING SCREEN
   ============================================================ */
#screen-ending {
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.ending-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
}
.ending-bg::after {
  content: "";
  position: absolute;
  inset: 0;
}
.ending-bg.best::after {
  background:
    radial-gradient(ellipse at 50% 30%, rgba(255,150,30,0.28) 0%, transparent 60%),
    linear-gradient(180deg, rgba(52,18,2,0.62) 0%, rgba(16,8,4,0.88) 100%);
}
.ending-bg.bitter::after {
  background:
    radial-gradient(ellipse at 50% 30%, rgba(70,110,200,0.24) 0%, transparent 60%),
    linear-gradient(180deg, rgba(6,14,32,0.68) 0%, rgba(5,7,16,0.9) 100%);
}
.ending-bg.chase::after {
  background:
    radial-gradient(ellipse at 50% 30%, rgba(140,90,200,0.22) 0%, transparent 60%),
    linear-gradient(180deg, rgba(24,10,44,0.66) 0%, rgba(10,6,20,0.9) 100%);
}

.ending-content {
  position: relative;
  z-index: 2;
  padding: 2rem 1.8rem calc(1.6rem + env(safe-area-inset-bottom));
  max-width: 440px;
  width: 100%;
  animation: fadeUp 0.9s ease both;
}

.ending-kicker {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: #b9a9d0;
  margin-bottom: 0.7rem;
}

.ending-title {
  font-size: clamp(1.7rem, 7vw, 2.5rem);
  font-weight: 900;
  line-height: 1.15;
  margin-bottom: 0.4rem;
  text-shadow: 0 4px 18px rgba(0,0,0,0.8);
}
.ending-content.best .ending-title { color: #ff9f1c; }
.ending-content.bitter .ending-title { color: #8fb8e0; }
.ending-content.chase .ending-title { color: #c3a4ec; }

.ending-sub {
  font-size: 0.82rem;
  font-style: italic;
  color: #cfc3d8;
  margin-bottom: 1.2rem;
}

.ending-desc {
  font-size: 0.88rem;
  line-height: 1.62;
  color: #e2d8c8;
  text-shadow: 0 1px 8px rgba(0,0,0,0.8);
  margin-bottom: 1.2rem;
}

.ending-stats {
  font-size: 0.74rem;
  line-height: 1.6;
  color: #a99bb8;
  border-top: 1px solid rgba(255,255,255,0.12);
  border-bottom: 1px solid rgba(255,255,255,0.12);
  padding: 0.7rem 0;
  margin-bottom: 1rem;
}

.ending-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: #8b7fa0;
  margin-bottom: 1.4rem;
}
.ending-list .found { color: #ffc97a; }
.ending-list .missed { color: #5c5470; }

/* ---------- Animations ---------- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   SMALL SCREENS
   ============================================================ */
@media (max-width: 380px) {
  .dialogue { padding: 26px 14px calc(14px + env(safe-area-inset-bottom)); }
  .choice-btn { font-size: 0.8rem; padding: 0.78rem 0.9rem; }
  .ending-desc { font-size: 0.84rem; }
}
