/* === Screens layout === */

.screen {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 1;
}

.screen.active {
  display: flex;
}

/* --- INTRO --- */
#screen-intro {
  background: var(--bg);
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.intro-container {
  max-width: 640px;
  padding: 2em;
  text-align: center;
}

.intro-lines {
  min-height: 300px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.4em;
}

.intro-line {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.25rem;
  color: var(--parch2);
  opacity: 0;
  animation: fade-in 1.2s ease forwards;
  line-height: 1.8;
}

.intro-line:nth-child(1) { animation-delay: 0.5s; }
.intro-line:nth-child(2) { animation-delay: 2.5s; }
.intro-line:nth-child(3) { animation-delay: 5s; }
.intro-line:nth-child(4) { animation-delay: 7s; }
.intro-line:nth-child(5) { animation-delay: 9s; }
.intro-line:nth-child(6) { animation-delay: 11s; }

#btn-skip-intro {
  margin-top: 2em;
  opacity: 0;
  animation: fade-in 0.8s ease forwards;
  animation-delay: 13s;
}

/* --- NAME --- */
#screen-name {
  background: radial-gradient(ellipse at center, var(--bg2) 0%, var(--bg) 70%);
  align-items: center;
  justify-content: center;
  z-index: 90;
}

.name-container {
  text-align: center;
  max-width: 480px;
  padding: 2em;
}

.title-main {
  font-size: 2.6rem;
  margin-bottom: 0.15em;
  text-shadow: 0 0 20px rgba(200,144,58,.3);
}

.title-sub {
  font-family: var(--serif);
  font-style: italic;
  color: var(--parch2);
  font-size: 1.15rem;
  margin-bottom: 2em;
  opacity: 0.7;
}

.name-form {
  margin-bottom: 1.5em;
}

.name-form label {
  display: block;
  font-family: var(--serif);
  font-style: italic;
  color: var(--amber);
  margin-bottom: 0.5em;
  font-size: 1.1rem;
}

.name-form input {
  width: 100%;
  max-width: 320px;
  padding: 0.6em 1em;
  font-family: var(--serif);
  font-size: 1.1rem;
  background: var(--bg2);
  color: var(--parch);
  border: 1px solid var(--border2);
  border-radius: 4px;
  outline: none;
  transition: border-color 0.3s;
}

.name-form input:focus {
  border-color: var(--amber);
  box-shadow: 0 0 8px rgba(200,144,58,.2);
}

.name-form input::placeholder {
  color: rgba(242,232,208,.3);
  font-style: italic;
}

.save-slots {
  margin-bottom: 1.5em;
  text-align: left;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
}

.save-slot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5em 0.8em;
  margin-bottom: 0.4em;
  background: rgba(200,144,58,.06);
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem;
}

.save-slot:hover {
  background: rgba(200,144,58,.14);
  border-color: var(--border2);
}

.save-slot-name {
  color: var(--amber2);
  font-family: var(--display);
  font-size: 0.95rem;
}

.save-slot-info {
  color: var(--parch2);
  font-size: 0.9rem;
  opacity: 0.7;
}

.save-slot-delete {
  background: none;
  border: none;
  color: rgba(200,100,80,.5);
  cursor: pointer;
  font-size: 1rem;
  padding: 0 0.3em;
  transition: color 0.2s;
}

.save-slot-delete:hover {
  color: #cc4040;
}

.btn-enter {
  font-size: 1.15rem;
  padding: 0.7em 2.4em;
}

.copyright {
  margin-top: 2em;
  font-size: 0.75rem;
  color: rgba(242,232,208,.25);
  font-family: var(--mono);
}

/* --- MAIN LAYOUT --- */
#screen-main {
  z-index: 10;
}

.main-layout {
  display: flex;
  width: 100%;
  height: 100%;
}

.cellar-area {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.side-panel {
  width: 280px;
  min-width: 240px;
  background: linear-gradient(180deg, var(--bg2) 0%, var(--bg) 100%);
  border-left: 1px solid var(--border);
  padding: 1em;
  display: flex;
  flex-direction: column;
  gap: 0.8em;
  overflow-y: auto;
}

/* Portrait */
.portrait-frame {
  border: 2px solid var(--amber);
  border-radius: 6px;
  padding: 0.5em;
  background: var(--bg);
  text-align: center;
  animation: glow-pulse 4s ease-in-out infinite;
}

.portrait-svg {
  width: 100%;
  max-width: 120px;
  height: auto;
}

/* Health bar */
.health-bar-container {
  text-align: center;
}

.health-bar-label {
  font-family: var(--display);
  font-size: 0.85rem;
  color: var(--amber);
  letter-spacing: 0.1em;
  margin-bottom: 0.3em;
}

.health-bar-track {
  width: 100%;
  height: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
}

.health-bar-fill {
  height: 100%;
  width: 40%;
  background: var(--amber);
  border-radius: 7px;
  transition: width 0.5s ease, background 0.5s ease;
}

.health-bar-fill.health-high { background: #408040; }
.health-bar-fill.health-mid { background: var(--amber); }
.health-bar-fill.health-low { background: #a04040; }
.health-bar-fill.health-critical {
  animation: critical-pulse 1s ease-in-out infinite;
}

.health-bar-value {
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--parch2);
  margin-top: 0.2em;
}

/* Speech box */
.speech-box {
  background: rgba(200,144,58,.05);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.7em;
  min-height: 80px;
  flex: 1;
  overflow-y: auto;
  max-height: 200px;
}

.speech-text {
  font-style: italic;
  font-size: 1rem;
  color: var(--parch2);
  line-height: 1.5;
}

/* Score */
.score-box {
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--amber);
  text-align: center;
  padding: 0.4em;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: rgba(200,144,58,.04);
}

/* --- CHAPTER BROWSER --- */
#screen-chapters {
  background: rgba(13,10,6,.92);
  align-items: center;
  justify-content: center;
  z-index: 50;
  backdrop-filter: blur(4px);
}

.chapters-container {
  max-width: 900px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 2em;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 8px;
  box-shadow: 0 0 40px rgba(0,0,0,.6);
}

.chapters-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5em;
}

.chapters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1em;
}

.chapter-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1em;
  cursor: pointer;
  transition: all 0.25s;
  position: relative;
}

.chapter-card:hover {
  border-color: var(--amber);
  box-shadow: 0 0 12px rgba(200,144,58,.15);
  transform: translateY(-2px);
}

.chapter-card.solved {
  border-color: rgba(64,128,64,.5);
}

.chapter-card.solved::after {
  content: '\2713';
  position: absolute;
  top: 0.5em;
  right: 0.5em;
  color: #60a060;
  font-size: 1.2rem;
}

.chapter-week {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--amber-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.chapter-op {
  font-family: var(--display);
  font-size: 1.05rem;
  color: var(--amber2);
  margin: 0.3em 0 0.2em;
}

.chapter-topic {
  font-size: 0.9rem;
  color: var(--parch2);
  opacity: 0.7;
}

.chapter-obj {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--amber-dim);
  margin-top: 0.4em;
}

/* --- GRIMOIRE --- */
#screen-grimoire {
  background: rgba(13,10,6,.92);
  align-items: center;
  justify-content: center;
  z-index: 50;
  backdrop-filter: blur(4px);
}

.grimoire-container {
  max-width: 800px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 2em;
  background: linear-gradient(180deg, #1a1408 0%, #120e06 100%);
  border: 2px solid var(--amber);
  border-radius: 8px;
  box-shadow: 0 0 40px rgba(200,144,58,.15);
}

.grimoire-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5em;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.8em;
}

.grimoire-empty {
  text-align: center;
  font-style: italic;
  color: var(--parch2);
  opacity: 0.5;
  padding: 3em 0;
}

.grimoire-entry {
  margin-bottom: 2em;
  padding-bottom: 1.5em;
  border-bottom: 1px solid var(--border);
  animation: fade-in 0.5s ease;
}

.grimoire-entry:last-child {
  border-bottom: none;
}

.grimoire-entry-header {
  font-family: var(--display);
  font-size: 1.1rem;
  color: var(--amber2);
  margin-bottom: 0.8em;
}

.grimoire-section {
  margin-bottom: 0.8em;
}

.grimoire-section-label {
  font-family: var(--display);
  font-size: 0.85rem;
  color: var(--amber);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.3em;
}

.grimoire-section-text {
  font-size: 1rem;
  color: var(--parch2);
  line-height: 1.6;
  padding-left: 0.8em;
  border-left: 2px solid var(--border);
}

.grimoire-formula {
  font-family: var(--mono);
  font-size: 0.95rem;
  color: var(--amber3);
  background: rgba(200,144,58,.06);
  padding: 0.5em 1em;
  border-radius: 3px;
  border: 1px solid var(--border);
  display: inline-block;
}

@media print {
  .grimoire-container {
    max-width: 100%;
    max-height: none;
    border: none;
    box-shadow: none;
    background: #fff;
    color: #000;
  }
  .grimoire-header button { display: none; }
  #btn-grimoire-print { display: none !important; }
  .grimoire-entry-header { color: #333; }
  .grimoire-section-text { color: #222; border-left-color: #999; }
  .grimoire-formula { color: #000; background: #f0f0f0; border-color: #ccc; }
}
