:root {
  color-scheme: dark;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

#play-screen.screen.active {
  display: flex;
}

.overlay-card {
  width: 92vw;
  max-width: 560px;
  background: rgba(27, 27, 27, 0.72);
  border: 1px solid rgba(69, 70, 82, 0.4);
  border-radius: 20px;
  backdrop-filter: blur(12px);
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
}

.start-screen-upgraded {
  border-color: rgba(233, 193, 118, 0.35);
}

.setup-panel {
  background: rgba(27, 27, 27, 0.55);
  border: 1px solid rgba(233, 193, 118, 0.18);
  border-radius: 14px;
  padding: 14px;
}

.setup-select {
  color: rgba(229, 226, 225, 0.96);
  font-size: 0.98rem;
  font-weight: 600;
  border-width: 1px;
  border-color: rgba(233, 193, 118, 0.28);
  box-shadow: inset 0 0 0 1px rgba(233, 193, 118, 0.08);
}

.setup-select:focus {
  outline: none;
  border-color: rgba(233, 193, 118, 0.62);
  box-shadow: 0 0 0 3px rgba(233, 193, 118, 0.18);
}

.play-canvas {
  width: 100%;
  max-width: 980px;
}

.hud-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: rgba(233, 193, 118, 0.7);
}

.text-glow {
  text-shadow: 0 0 20px rgba(229, 226, 225, 0.5), 0 0 40px rgba(229, 226, 225, 0.2);
}

.screen-brand {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.28em;
  color: rgba(233, 193, 118, 0.65);
}

.status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2rem;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  border: 1px solid rgba(233, 193, 118, 0.22);
  background: rgba(27, 27, 27, 0.46);
  color: rgba(229, 226, 225, 0.92);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  backdrop-filter: blur(10px);
}

.status-chip-accent {
  color: rgba(233, 193, 118, 0.92);
}

.card-box {
  background: rgba(53, 53, 53, 0.3);
  border: 1px solid rgba(69, 70, 82, 0.4);
  border-radius: 16px;
  padding: 14px 18px;
  backdrop-filter: blur(10px);
}

.scroll-sheet {
  position: relative;
  background: linear-gradient(to right, #d4c19d 0%, #e5d5b7 15%, #e5d5b7 85%, #d4c19d 100%);
  border: 1px solid rgba(102, 76, 40, 0.35);
  border-radius: 6px;
  min-height: 240px;
  padding: 28px 22px;
  box-shadow:
    0 18px 38px rgba(0, 0, 0, 0.45),
    inset 0 0 80px rgba(65, 45, 0, 0.18);
}

.scroll-sheet::before,
.scroll-sheet::after {
  content: "";
  position: absolute;
  width: 46px;
  height: 46px;
  border-color: rgba(138, 99, 53, 0.5);
  pointer-events: none;
}

.scroll-sheet::before {
  top: 8px;
  left: 8px;
  border-top: 2px solid;
  border-left: 2px solid;
}

.scroll-sheet::after {
  right: 8px;
  bottom: 8px;
  border-right: 2px solid;
  border-bottom: 2px solid;
}

.scroll-kicker {
  margin: 0 0 10px;
  text-align: center;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.35em;
  color: rgba(166, 122, 55, 0.92);
  font-weight: 700;
}

.scroll-caption {
  color: rgba(36, 24, 7, 0.94);
  text-shadow: 0 1px 0 rgba(255, 245, 220, 0.18);
}

.scroll-ja {
  margin: 0;
  color: #261900;
  font-size: 1.45rem;
  font-family: "Noto Serif", serif;
  font-weight: 700;
  line-height: 1.5;
}

.scroll-hint {
  margin: 0;
  color: rgba(65, 45, 0, 0.82);
  font-size: 1.02rem;
  line-height: 1.65;
  letter-spacing: 0.12em;
  font-weight: 700;
}

.caption {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: rgba(166, 122, 55, 0.92);
  margin: 0 0 6px;
}

.sr-anchor {
  position: absolute;
  left: -9999px;
}

.feedback.ok {
  color: #8ce5a8;
}

.feedback.error {
  color: #ff9a8f;
}

#feedback {
  line-height: 1.6;
  letter-spacing: 0.01em;
}

.cutin-container {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 60;
}

.cutin-container.hidden {
  display: none;
}

.cutin-text {
  font-family: "Noto Serif", serif;
  font-size: 56px;
  font-weight: 700;
  color: #f3d39e;
  text-shadow: 0 0 20px rgba(233, 193, 118, 0.4), 0 8px 25px rgba(0, 0, 0, 0.6);
}

.result-screen-upgraded {
  max-width: 520px;
  border-color: rgba(233, 193, 118, 0.35);
}

.rank-pill {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 999px;
  border: 1px solid rgba(233, 193, 118, 0.42);
  background: rgba(64, 44, 0, 0.32);
  color: rgba(255, 226, 168, 0.96);
}

.result-stat-grid p:nth-child(odd) {
  color: rgba(229, 226, 225, 0.84);
}

.result-stat-grid p:nth-child(even) {
  color: rgba(255, 224, 166, 0.98);
  font-weight: 700;
  text-align: right;
}

.segment-btn {
  color: rgba(229, 226, 225, 0.78);
}

.segment-btn.is-active {
  background: linear-gradient(135deg, rgba(233, 193, 118, 0.98) 0%, rgba(182, 146, 77, 0.95) 100%);
  color: #261900;
  box-shadow: 0 0 15px rgba(233, 193, 118, 0.3);
}

/* Animations */
@keyframes shake {
  0% { transform: translate(1px, 1px) rotate(0deg); }
  10% { transform: translate(-1px, -2px) rotate(-1deg); }
  20% { transform: translate(-3px, 0px) rotate(1deg); }
  30% { transform: translate(3px, 2px) rotate(0deg); }
  40% { transform: translate(1px, -1px) rotate(1deg); }
  50% { transform: translate(-1px, 2px) rotate(-1deg); }
  60% { transform: translate(-3px, 1px) rotate(0deg); }
  70% { transform: translate(3px, 1px) rotate(-1deg); }
  80% { transform: translate(-1px, -1px) rotate(1deg); }
  90% { transform: translate(1px, 2px) rotate(0deg); }
  100% { transform: translate(1px, -2px) rotate(-1deg); }
}

.anim-shake {
  animation: shake 0.5s;
}

@keyframes flash-red {
  0% { background-color: rgba(231, 76, 60, 0); }
  50% { background-color: rgba(231, 76, 60, 0.3); }
  100% { background-color: rgba(231, 76, 60, 0); }
}

.anim-damage {
  animation: flash-red 0.3s;
}

@keyframes hit-effect {
  0% { transform: scale(1); opacity: 1; filter: brightness(1); }
  50% { transform: scale(1.2); opacity: 0.8; filter: brightness(2) sepia(1) hue-rotate(180deg); }
  100% { transform: scale(1); opacity: 1; filter: brightness(1); }
}

.anim-hit {
  animation: hit-effect 0.3s;
}

@keyframes fade-out-up {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-20px); }
}

.anim-defeat {
  animation: fade-out-up 0.8s forwards;
}

@keyframes pop-up {
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
  50% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
  80% { transform: translate(-50%, -50%) scale(0.9); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

@keyframes combo-pop {
  0% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.5); }
  100% { transform: translateX(-50%) scale(1); }
}

.anim-combo {
  animation: combo-pop 0.3s;
}

@media (max-width: 640px) {
  .hud-label {
    font-size: 0.58rem;
    letter-spacing: 0.14em;
  }
  .scroll-sheet {
    min-height: 205px;
    padding: 20px 14px;
  }
  .scroll-ja {
    font-size: 1.2rem;
    line-height: 1.6;
  }
  .scroll-hint {
    font-size: 0.92rem;
    line-height: 1.55;
    letter-spacing: 0.1em;
  }
  .cutin-text {
    font-size: 32px;
  }
  .overlay-card {
    width: 94vw;
    max-width: 560px;
    padding: 18px;
  }
  .segment-btn {
    padding: 0.62rem 0.35rem;
    letter-spacing: 0.08em;
  }
  .screen-brand {
    font-size: 0.6rem;
    letter-spacing: 0.22em;
  }
  .status-chip {
    padding: 0.4rem 0.7rem;
    font-size: 0.64rem;
    letter-spacing: 0.1em;
  }
}
