:root {
  --bg-deep:       #0a0604;
  --bg-mid:        #1a0f06;
  --parchment:     #f5e6c8;
  --parchment-dim: #c9a96e;
  --gold:          #d4a017;
  --gold-light:    #f0c040;
  --gold-dark:     #8b6510;
  --red-accent:    #8b1a1a;
  --ink:           #1e0f02;
}

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

body {
  min-height: 100vh;
  background: url('../img/background_menu.png') center center / cover no-repeat fixed;
  background-color: #1a0f06;
  font-family: 'Crimson Text', Georgia, serif;
  color: var(--parchment);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bg-layer {
  display: none;
}

/* ─ Main Screen Container ─ */
.screen {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.mascot-wrap {
  position: relative;
  margin-bottom: -10px;
  animation: mascotFloat 3.5s ease-in-out infinite;
}

@keyframes mascotFloat {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-12px); }
}

.mascot {
  width: 130px;
  height: auto;
  filter: drop-shadow(0 8px 20px rgba(212,160,23,0.4));
}

/* ─ Title Panel ─ */
.title-panel {
  position: relative;
  background: #1e0f04;
  border: 2px solid var(--gold-dark);
  border-radius: 6px;
  padding: 40px 60px 36px;
  text-align: center;
  box-shadow: 0 0 0 1px #d4a01726;
  min-width: min(520px, 90vw);
}

.corner-tl,
.corner-br {
  position: absolute;
  width: 28px;
  height: 28px;
  border-color: var(--gold-dark);
  border-style: solid;
  opacity: 0.5;
}
.corner-tl { top: 8px;    right: 14px; border-width: 2px 2px 0 0; }
.corner-br { bottom: 8px; left: 14px;  border-width: 0 0 2px 2px; }

/* ─ Baybayin Title ─ */
.baybayin-title {
  font-size: clamp(2.8rem, 7vw, 4.5rem);
  letter-spacing: 0.12em;
  color: var(--gold);
  line-height: 1;
  margin-bottom: 6px;
}

.title-en {
  font-family: 'Cinzel Decorative', serif;
  font-size: clamp(0.85rem, 2.5vw, 1.1rem);
  font-weight: 700;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  margin-bottom: 4px;
  color: var(--gold);
}

.subtitle {
  font-family: 'Crimson Text', Georgia, serif;
  font-style: italic;
  font-size: clamp(0.75rem, 2vw, 0.95rem);
  color: rgba(201,169,110,0.65);
  letter-spacing: 0.1em;
  margin-bottom: 32px;
}

.divider {
  width: 60%;
  height: 1px;
  background: #8b6510;
  margin: 0 auto 32px;
}

/* ─ Button Group ─ */
.btn-group {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
}

/* ─ Base Button ─ */
.btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 28px;
  border-radius: 4px;
  cursor: pointer;
  font-family: 'Cinzel Decorative', serif;
  font-size: 0.85rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
  overflow: hidden;
}

.btn:active { transform: scale(0.97); }

.btn-icon {
  font-size: 1.1rem;
  line-height: 1;
}

/* ─ Start Button ─ */
.btn--start {
  background: #c49010;
  color: var(--ink);
}
.btn--start:hover {
  transform: translateY(-3px) scale(1.02);
  filter: brightness(1.1);
  color: var(--gold-light);
}

/* ─ Resume Button ─ */
.btn--resume {
  background: #c49010;
  color: var(--ink);
  border: 1px solid var(--gold-dark);
}
.btn--resume:hover {
  transform: translateY(-3px) scale(1.02);
  border-color: var(--gold);
  color: var(--gold-light);
}
.btn--resume.btn--disabled {
  opacity: 0.38;
  cursor: not-allowed;
  pointer-events: none;
}

/* ─ Settings Button ─ */
.btn--settings {
  background: #c49010;
  color: var(--ink);
  border: 1px solid rgba(139,101,16,0.4);
}
.btn--settings:hover {
  color: var(--parchment-dim);
  border-color: var(--gold-dark);
  filter: brightness(1.1);
}

/* ─ Credits Button ─ */
.btn--credits {
  background: #c49010;
  color: var(--ink);
  border: 1px solid rgba(139,101,16,0.4);
}
.btn--credits:hover {
  color: var(--parchment-dim);
  border-color: var(--gold-dark);
  filter: brightness(1.1);
}

/* ─ Settings Overlay ─ */
.modal-close {
  position: absolute;
  top: 10px; right: 12px;
  background: none;
  border: none;
  color: var(--parchment-dim);
  font-size: 1.1rem;
  cursor: pointer;
  opacity: 0.5;
  line-height: 1;
  padding: 2px 6px;
}
.modal-close:hover { opacity: 1; color: var(--gold-light); }

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.is-open {
  opacity: 1;
  pointer-events: all;
}

/* ─ Modal Box ─ */
.modal {
  background: linear-gradient(160deg, #1e0f04 0%, #110800 100%);
  border: 1px solid var(--gold-dark);
  border-radius: 6px;
  padding: 36px 44px;
  min-width: min(400px, 88vw);
  box-shadow: 0 20px 60px rgba(0,0,0,0.9), 0 0 0 1px rgba(212,160,23,0.1);
  transform: scale(0.92);
  transition: transform 0.25s ease;
  position: relative;
}

.modal-overlay.is-open .modal {
  transform: scale(1);
}

.modal-title {
  font-family: 'Cinzel Decorative', serif;
  font-size: 1rem;
  letter-spacing: 0.25em;
  color: var(--gold);
  margin-bottom: 28px;
  text-align: center;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  color: var(--parchment-dim);
  font-size: 1.2rem;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.15s;
}
.modal-close:hover { opacity: 1; }

/* ─ Setting Rows ─ */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid rgba(139,101,16,0.25);
}
.setting-row:last-of-type { border-bottom: none; }

.setting-label {
  font-size: 0.9rem;
  color: var(--parchment-dim);
  letter-spacing: 0.05em;
}

/* ─ Toggle Switch ─ */
.toggle {
  position: relative;
  width: 46px;
  height: 24px;
  cursor: pointer;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-track {
  position: absolute;
  inset: 0;
  border-radius: 24px;
  background: #2a1505;
  border: 1px solid var(--gold-dark);
  transition: background 0.2s;
}

.toggle input:checked + .toggle-track {
  background: var(--gold-dark);
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--parchment-dim);
  transition: transform 0.2s;
  pointer-events: none;
}

.toggle input:checked ~ .toggle-thumb {
  transform: translateX(22px);
  background: var(--gold-light);
}

/* ─ Volume Slider ─ */
.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100px;
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--gold) 70%, #2a1505 70%);
  outline: none;
  cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gold-light);
  box-shadow: 0 0 6px rgba(212,160,23,0.6);
}

/* ─ Name Entry Modal ─ */
.modal--name {
  min-width: min(360px, 88vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 40px 44px;
}

.name-modal__sub {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 0.9rem;
  color: var(--parchment-dim);
  text-align: center;
  margin-top: -8px;
}

.name-input {
  width: 100%;
  background: #0d0602;
  border: 1px solid var(--gold-dark);
  border-radius: 4px;
  padding: 10px 14px;
  font-family: 'Cinzel', serif;
  font-size: 1rem;
  color: var(--gold-light);
  letter-spacing: 0.08em;
  text-align: center;
  outline: none;
}
.name-input::placeholder {
  color: #5a3a10;
  font-style: italic;
}
.name-input:focus {
  border-color: var(--gold);
}

.name-modal__error {
  font-size: 0.75rem;
  color: #ff6666;
  text-align: center;
  margin-top: -6px;
}

.name-modal__confirm {
  width: 100%;
  margin-top: 4px;
}
/* ─ Study Sheet Button ─ */
.btn--study {
  background: #c49010;
  color: var(--ink);
  border: 1px solid rgba(139,101,16,0.4);
  box-shadow: none;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
}
.btn--study:hover {
  color: var(--parchment-dim);
  border-color: var(--gold-dark);
  filter: brightness(1.1);
}

.study-overlay {
  z-index: 110;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal--study {
  background: linear-gradient(160deg, #1e0f04 0%, #110800 100%);
  border: 1px solid var(--gold-dark);
  border-radius: 8px;
  padding: 28px 28px 24px;
  max-width: min(900px, 94vw);
  width: 100%;
  box-shadow: 0 24px 70px rgba(0,0,0,0.95), 0 0 0 1px rgba(212,160,23,0.12);
  transform: scale(0.92);
  transition: transform 0.25s ease;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.study-overlay.is-open .modal--study {
  transform: scale(1);
}

.study-img-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(139,101,16,0.35);
  border-radius: 6px;
  overflow: hidden;
  background: #f5e6c8;
}

.study-img {
  width: 100%;
  height: auto;
  display: block;
  max-height: 75vh;
  object-fit: contain;
}

/* ─ Resume/Save Modal ─ */
.modal--saves {
  min-width: min(480px, 92vw);
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 36px 36px 32px;
}

.saves-subtitle {
  font-size: 0.85rem;
  color: var(--parchment-dim);
  text-align: center;
  margin-top: -10px;
  font-style: italic;
}

/* ─ Save Slot Cards ─ */
.save-slots {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.save-card {
  border-radius: 5px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.15s, transform 0.12s;
  border: 1px solid rgba(139,101,16,0.4);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.save-card--filled {
  background: rgba(212,160,23,0.07);
}
.save-card--filled:hover {
  background: rgba(212,160,23,0.14);
  transform: translateY(-1px);
  border-color: var(--gold-dark);
}

.save-card--empty {
  background: rgba(0,0,0,0.3);
  opacity: 0.55;
  cursor: default;
}

.save-card__slot {
  font-family: 'Cinzel Decorative', serif;
  font-size: 0.55rem;
  letter-spacing: 0.2em;
  color: var(--gold-dark);
  text-transform: uppercase;
}

.save-card__name {
  font-family: 'Cinzel Decorative', serif;
  font-size: 0.9rem;
  color: var(--gold-light);
  letter-spacing: 0.1em;
}

.save-card__stats {
  display: flex;
  gap: 16px;
  font-size: 0.8rem;
  color: var(--parchment);
}

.save-card__info {
  display: flex;
  gap: 16px;
  font-size: 0.75rem;
  color: var(--parchment-dim);
}

.save-card__date {
  font-size: 0.68rem;
  color: rgba(201,169,110,0.45);
  margin-top: 2px;
}

.save-card__empty-label {
  font-size: 0.85rem;
  color: rgba(201,169,110,0.3);
  font-style: italic;
  text-align: center;
  padding: 8px 0;
}

/* ─ COMIC OVERLAY ─ */
.comic-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.5s ease;
}

.comic-wrap {
  text-align: center;
}

.comic-img {
  max-width: 90vw;
  max-height: 80vh;
  border: 2px solid var(--gold-dark);
  box-shadow: 0 0 30px rgba(212, 160, 23, 0.2);
}

.comic-hint {
  margin-top: 20px;
  font-family: 'Cinzel Decorative', serif;
  color: var(--gold-light);
  letter-spacing: 2px;
  text-transform: uppercase;
  animation: pulse 2s infinite;
}

.hidden { display: none !important; }

@keyframes pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }