@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=VT323&display=swap');

:root {
  /* Warm jazz club palette */
  --brick-dark: #4a2c2a;
  --brick-medium: #8b4537;
  --brick-light: #a65d4e;
  --wood-dark: #2d1f1a;
  --wood-medium: #4a3728;
  --cream: #f5e6c8;
  --cream-dark: #e6d4a8;
  --gold: #d4a84b;
  --gold-bright: #ffd966;
  --spotlight: #fff8dc;
  --text-dark: #2d1f1a;
  --text-light: #f5e6c8;
  --menu-bg: #1a1410;
  --menu-border: #8b7355;
  --success: #5a8f5a;
  --danger: #a64444;
  --highlight: #c9a227;
}

body.theme-classic {
  --brick-dark: #4a2c2a;
  --brick-medium: #8b4537;
  --brick-light: #a65d4e;
  --wood-dark: #2d1f1a;
  --wood-medium: #4a3728;
  --cream: #f5e6c8;
  --cream-dark: #e6d4a8;
  --gold: #d4a84b;
  --gold-bright: #ffd966;
  --spotlight: #fff8dc;
  --text-dark: #2d1f1a;
  --text-light: #f5e6c8;
  --menu-bg: #1a1410;
  --menu-border: #8b7355;
  --success: #5a8f5a;
  --danger: #a64444;
  --highlight: #c9a227;
}

body.theme-crystal {
  --brick-dark: #1d2b4f;
  --brick-medium: #3d5a99;
  --brick-light: #627ec7;
  --wood-dark: #0f1830;
  --wood-medium: #22355f;
  --cream: #e8efff;
  --cream-dark: #c5d3ff;
  --gold: #7fd3ff;
  --gold-bright: #c9f0ff;
  --spotlight: #f5fbff;
  --text-dark: #0f1830;
  --text-light: #e8efff;
  --menu-bg: #121c39;
  --menu-border: #5d79c0;
  --success: #6ec1a5;
  --danger: #c46e8c;
  --highlight: #7fd3ff;
}

body.theme-forest {
  --brick-dark: #243d2d;
  --brick-medium: #3f6b4b;
  --brick-light: #5d8c69;
  --wood-dark: #14241a;
  --wood-medium: #2b4734;
  --cream: #eef7e8;
  --cream-dark: #d3e8c7;
  --gold: #b8d36c;
  --gold-bright: #dff39b;
  --spotlight: #f8fff2;
  --text-dark: #14241a;
  --text-light: #eef7e8;
  --menu-bg: #182c1f;
  --menu-border: #5f8a67;
  --success: #72b57b;
  --danger: #b56262;
  --highlight: #9fcb66;
}

* {
  box-sizing: border-box;
  image-rendering: pixelated;
}

/* Retro SNES-style animations */
@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

@keyframes spotlight-sway {
  0%, 100% { 
    background-position: 50% 0%;
    opacity: 0.15;
  }
  50% { 
    background-position: 55% 0%;
    opacity: 0.25;
  }
}

@keyframes float-gentle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@keyframes menu-open {
  from {
    transform: scaleY(0);
    opacity: 0;
  }
  to {
    transform: scaleY(1);
    opacity: 1;
  }
}

@keyframes slide-in {
  from {
    transform: translateX(-10px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes text-appear {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes stat-flash {
  0%, 100% { background-color: transparent; }
  50% { background-color: rgba(212, 168, 75, 0.3); }
}

@keyframes bounce-small {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes shimmer {
  0% { background-position: -100% 0; }
  100% { background-position: 200% 0; }
}

body {
  margin: 0;
  padding: 20px;
  min-height: 100vh;
  /* Brick wall background with warm lighting */
  background: 
    /* Spotlight from above */
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(255, 248, 220, 0.2) 0%, transparent 60%),
    /* Warm ambient */
    linear-gradient(180deg, rgba(74, 44, 42, 0.95) 0%, rgba(45, 31, 26, 0.98) 100%),
    /* Brick pattern */
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 20px,
      rgba(0,0,0,0.1) 20px,
      rgba(0,0,0,0.1) 21px
    ),
    repeating-linear-gradient(
      90deg,
      var(--brick-dark) 0px,
      var(--brick-medium) 40px,
      var(--brick-dark) 80px
    );
  background-attachment: fixed;
  font-family: 'VT323', monospace;
  color: var(--cream);
  overflow-x: hidden;
}

/* Subtle animated spotlight overlay */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 300px;
  background: radial-gradient(ellipse 60% 100% at 50% 0%, rgba(255, 217, 102, 0.15) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
  animation: spotlight-sway 8s ease-in-out infinite;
}

h1 {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(1rem, 5vw, 1.4rem);
  margin: 0;
  padding: 15px;
  text-align: center;
  color: var(--gold-bright);
  text-shadow: 
    2px 2px 0 var(--wood-dark),
    4px 4px 0 rgba(0,0,0,0.3);
  letter-spacing: 2px;
  background: linear-gradient(180deg, var(--wood-dark) 0%, var(--menu-bg) 100%);
  border-bottom: 4px solid var(--menu-border);
}

h2 {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.9rem;
  margin: 0 0 12px 0;
  color: var(--gold);
  text-shadow: 2px 2px 0 var(--wood-dark);
  text-align: center;
}

h3 {
  font-family: 'VT323', monospace;
  font-size: 1.4rem;
  margin: 0;
  color: var(--cream);
}

/* Main game container - SNES window style */
#game {
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
  background: var(--menu-bg);
  border: 4px solid var(--menu-border);
  border-radius: 8px;
  box-shadow: 
    inset 2px 2px 0 rgba(255,255,255,0.1),
    inset -2px -2px 0 rgba(0,0,0,0.3),
    0 8px 32px rgba(0,0,0,0.5);
  overflow: hidden;
  margin-bottom: 20px;
  transition: max-width 0.3s ease;
}

/* Intro Screen */
#introScreen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  text-align: center;
  padding: 24px 20px;
  animation: menu-open 0.3s ease-out;
}

#mentorImg {
  border: 4px solid var(--menu-border);
  border-radius: 50%;
  background: var(--wood-dark);
  padding: 4px;
  box-shadow: 
    inset 2px 2px 0 rgba(255,255,255,0.1),
    0 4px 12px rgba(0,0,0,0.4);
  animation: float-gentle 3s ease-in-out infinite;
  transition: transform 0.2s ease;
  max-width: 100px;
  height: auto;
}

#mentorImg:hover {
  transform: scale(1.05);
}

/* Dialog text box - Pokemon style */
#introText {
  min-height: 100px;
  padding: 16px;
  background: var(--cream);
  border: 4px solid var(--text-dark);
  border-radius: 4px;
  color: var(--text-dark);
  font-size: 1.3rem;
  line-height: 1.5;
  text-align: left;
  position: relative;
  box-shadow: 
    inset -2px -2px 0 rgba(0,0,0,0.2),
    inset 2px 2px 0 rgba(255,255,255,0.5);
}

#introText::after {
  content: '▼';
  position: absolute;
  bottom: 8px;
  right: 12px;
  color: var(--text-dark);
  animation: blink 1s infinite;
  font-size: 0.8rem;
}

#introContinue {
  display: none;
}

/* Name input section */
#nameInput {
  width: 100%;
  text-align: center;
  padding: 10px;
}

#nameInput h3 {
  margin-bottom: 12px;
  color: var(--gold);
}

#playerNameInput {
  width: 80%;
  max-width: 250px;
  padding: 12px 16px;
  font-family: 'VT323', monospace;
  font-size: 1.3rem;
  border: 3px solid var(--menu-border);
  border-radius: 4px;
  background: var(--cream);
  color: var(--text-dark);
  text-align: center;
  margin-bottom: 12px;
}

#playerNameInput:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--gold);
}

#confirmNameBtn {
  display: block;
  margin: 0 auto;
}

#avatarSelection {
  display: none;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
  padding: 10px;
}

.avatar-option {
  border: 4px solid var(--menu-border);
  padding: 12px;
  cursor: pointer;
  background: linear-gradient(180deg, var(--wood-medium) 0%, var(--wood-dark) 100%);
  color: var(--cream);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border-radius: 8px;
  transition: all 0.15s ease;
  box-shadow: 
    inset 2px 2px 0 rgba(255,255,255,0.1),
    inset -2px -2px 0 rgba(0,0,0,0.2),
    0 4px 8px rgba(0,0,0,0.3);
}

.avatar-option:hover {
  transform: translateY(-2px);
  border-color: var(--gold);
  box-shadow: 
    inset 2px 2px 0 rgba(255,255,255,0.1),
    inset -2px -2px 0 rgba(0,0,0,0.2),
    0 6px 16px rgba(0,0,0,0.4),
    0 0 0 2px var(--gold);
}

.avatar-option.selected {
  border-color: var(--gold-bright);
  background: linear-gradient(180deg, var(--brick-medium) 0%, var(--brick-dark) 100%);
  animation: bounce-small 0.3s ease;
}

.avatar-option img {
  border: 2px solid var(--menu-border);
  border-radius: 4px;
}

.hidden {
  display: none !important;
}

/* Main Game Screen */
#screen1 {
  display: block;
  animation: menu-open 0.4s ease-out;
}

/* Player stats panel - Pokemon/SNES RPG style */
#player {
  padding: 12px;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(180deg, var(--wood-medium) 0%, var(--wood-dark) 100%);
  border-bottom: 4px solid var(--menu-border);
}

#avatar {
  border: 3px solid var(--menu-border);
  border-radius: 4px;
  background: var(--menu-bg);
  padding: 2px;
  box-shadow: 
    inset 1px 1px 0 rgba(255,255,255,0.1),
    0 2px 8px rgba(0,0,0,0.3);
  animation: float-gentle 4s ease-in-out infinite;
  transition: transform 0.2s ease;
}

#avatar:hover {
  transform: scale(1.08) rotate(2deg);
}

/* Stats box */
#stats {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  background: var(--menu-bg);
  border: 3px solid var(--menu-border);
  border-radius: 4px;
  padding: 8px;
  box-shadow: 
    inset 2px 2px 0 rgba(255,255,255,0.05),
    inset -2px -2px 0 rgba(0,0,0,0.2);
}

.profile-panel {
  margin-top: 4px;
  padding: 8px 6px;
  border-top: 2px solid rgba(245, 230, 200, 0.12);
  background: linear-gradient(180deg, rgba(74, 55, 40, 0.45) 0%, rgba(26, 20, 16, 0.85) 100%);
  border-radius: 4px;
}

.profile-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  font-size: 0.95rem;
  color: var(--cream);
}

.profile-title strong {
  color: var(--gold-bright);
  font-family: 'Press Start 2P', monospace;
  font-size: 0.55rem;
  text-align: right;
  line-height: 1.3;
}

.profile-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.profile-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.85rem;
  line-height: 1.2;
  border: 1px solid rgba(245, 230, 200, 0.22);
  background: rgba(0, 0, 0, 0.22);
  color: var(--cream);
  white-space: nowrap;
}

.profile-badge-career {
  background: linear-gradient(180deg, rgba(212, 168, 75, 0.35) 0%, rgba(166, 93, 78, 0.35) 100%);
  border-color: rgba(255, 217, 102, 0.45);
  color: var(--gold-bright);
}

.profile-badge-feature {
  background: rgba(90, 143, 90, 0.28);
  border-color: rgba(90, 143, 90, 0.5);
}

.profile-badge-milestone {
  background: rgba(166, 68, 68, 0.26);
  border-color: rgba(166, 68, 68, 0.5);
}

.profile-badge-perk {
  background: rgba(0, 0, 0, 0.24);
}

.profile-badge-overflow {
  opacity: 0.8;
}

.stat {
  font-size: 1rem;
  color: var(--cream);
  display: flex;
  justify-content: space-between;
  padding: 2px 4px;
  border-radius: 2px;
  transition: background-color 0.3s ease;
}

.stat strong {
  color: var(--gold);
  font-family: 'Press Start 2P', monospace;
  font-size: 0.6rem;
}

.stat-updated {
  animation: stat-flash 0.5s ease;
}

/* Action buttons - SNES menu style */
#btnDivUp {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 130px;
}

button {
  cursor: pointer;
  font-family: 'VT323', monospace;
  font-size: 1.1rem;
  padding: 8px 12px;
  border: 3px solid var(--menu-border);
  border-radius: 4px;
  position: relative;
  transition: all 0.1s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
  background: linear-gradient(180deg, var(--cream) 0%, var(--cream-dark) 100%);
  color: var(--text-dark);
  box-shadow: 
    inset 1px 1px 0 rgba(255,255,255,0.5),
    inset -1px -1px 0 rgba(0,0,0,0.1),
    0 2px 0 var(--wood-dark);
}

button:hover {
  background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold) 100%);
  transform: translateY(-1px);
  box-shadow: 
    inset 1px 1px 0 rgba(255,255,255,0.5),
    inset -1px -1px 0 rgba(0,0,0,0.1),
    0 3px 0 var(--wood-dark);
}

button:active {
  transform: translateY(2px);
  box-shadow: 
    inset 1px 1px 0 rgba(0,0,0,0.1),
    inset -1px -1px 0 rgba(255,255,255,0.3),
    0 0px 0 var(--wood-dark);
}

#btnDivUp button {
  font-size: 0.95rem;
  padding: 6px 8px;
}

/* Main content area - stage/club view */
#blackScreen {
  background: 
    /* Spotlight effect */
    radial-gradient(ellipse 80% 60% at 50% 20%, rgba(255, 248, 220, 0.08) 0%, transparent 50%),
    linear-gradient(180deg, var(--menu-bg) 0%, #0f0c0a 100%);
  padding: 16px;
  min-height: 300px;
  position: relative;
}

#title {
  font-size: 0.85rem;
  margin-bottom: 12px;
  animation: slide-in 0.3s ease-out;
}

#locationImg {
  display: block;
  margin: 0 auto 12px;
  max-width: 380px;
  width: 100%;
  border: 4px solid var(--menu-border);
  border-radius: 4px;
  box-shadow: 
    0 4px 16px rgba(0,0,0,0.5),
    inset 0 0 20px rgba(0,0,0,0.3);
  transition: all 0.3s ease;
  animation: menu-open 0.4s ease-out;
}

#locationImg:hover {
  transform: scale(1.02);
  box-shadow: 
    0 6px 24px rgba(0,0,0,0.6),
    0 0 0 2px var(--gold);
}

/* Character image - smaller for NPCs like Prof Carvalho */
#locationImg.character-image {
  max-width: 180px;
  border-radius: 50%;
  border: 3px solid var(--gold);
  box-shadow: 
    0 4px 16px rgba(0,0,0,0.5),
    0 0 0 3px var(--menu-border),
    0 0 20px rgba(212, 168, 75, 0.3);
}

#locationImg.character-image:hover {
  transform: scale(1.05);
}

/* Narration text box - Pokemon dialog style */
#text {
  font-size: 1.2rem;
  line-height: 1.6;
  color: var(--text-dark);
  padding: 14px;
  background: var(--cream);
  border: 4px solid var(--text-dark);
  border-radius: 4px;
  margin: 12px 0;
  min-height: 50px;
  box-shadow: 
    inset -2px -2px 0 rgba(0,0,0,0.15),
    inset 2px 2px 0 rgba(255,255,255,0.4);
  animation: menu-open 0.3s ease-out;
}

#subTitle {
  color: var(--gold);
  font-size: 1.3rem;
  text-align: center;
  margin: 12px 0;
  text-shadow: 1px 1px 0 var(--wood-dark);
}

/* Joke List - RPG inventory style */
#jokeList {
  margin: 12px 0;
  padding: 0;
  display: none;
  list-style: none;
  max-height: 300px;
  overflow-y: auto;
  background: var(--menu-bg);
  border: 3px solid var(--menu-border);
  border-radius: 4px;
  padding: 8px;
}

#jokeList::-webkit-scrollbar {
  width: 12px;
}

#jokeList::-webkit-scrollbar-track {
  background: var(--wood-dark);
  border-radius: 4px;
}

#jokeList::-webkit-scrollbar-thumb {
  background: var(--menu-border);
  border-radius: 4px;
  border: 2px solid var(--wood-dark);
}

.joke-item {
  border: 2px solid var(--wood-medium);
  padding: 10px 12px;
  margin-bottom: 6px;
  background: linear-gradient(180deg, var(--wood-medium) 0%, var(--wood-dark) 100%);
  color: var(--cream);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-radius: 4px;
  transition: all 0.15s ease;
  animation: slide-in 0.3s ease-out backwards;
  box-shadow: 
    inset 1px 1px 0 rgba(255,255,255,0.1),
    inset -1px -1px 0 rgba(0,0,0,0.2);
}

.joke-item:nth-child(1) { animation-delay: 0.05s; }
.joke-item:nth-child(2) { animation-delay: 0.1s; }
.joke-item:nth-child(3) { animation-delay: 0.15s; }
.joke-item:nth-child(4) { animation-delay: 0.2s; }
.joke-item:nth-child(5) { animation-delay: 0.25s; }
.joke-item:nth-child(6) { animation-delay: 0.3s; }

.joke-item:hover {
  border-color: var(--gold);
  background: linear-gradient(180deg, var(--brick-medium) 0%, var(--brick-dark) 100%);
  transform: translateX(4px);
}

.joke-item.read-only {
  cursor: default;
}

.joke-item.read-only:hover {
  transform: none;
}

.joke-item.selected {
  border-color: var(--gold-bright);
  background: linear-gradient(180deg, var(--highlight) 0%, #9a7a1c 100%);
  color: var(--text-dark);
  box-shadow: 
    0 0 0 2px var(--gold-bright),
    inset 1px 1px 0 rgba(255,255,255,0.2);
}

.joke-item.selected strong {
  color: var(--text-dark);
}

.joke-item.set-focused {
  border-color: var(--gold-bright);
  box-shadow:
    0 0 0 2px rgba(255, 217, 102, 0.45),
    inset 1px 1px 0 rgba(255,255,255,0.2);
}

.joke-item strong {
  color: var(--gold);
  font-size: 1.1rem;
}

.joke-item span {
  font-size: 1rem;
  color: var(--cream-dark);
}

.joke-history {
  font-size: 1.2rem;
  letter-spacing: 3px;
  padding: 3px 0;
}

.joke-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.95rem;
  color: var(--cream-dark);
  padding-top: 4px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.joke-item .actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 6px;
}

.rewrite-btn, .delete-btn {
  font-size: 0.9rem;
  padding: 4px 10px;
}

.rewrite-btn {
  background: linear-gradient(180deg, var(--success) 0%, #4a7a4a 100%);
  color: var(--cream);
  border-color: #3a5a3a;
}

.rewrite-btn:hover {
  background: linear-gradient(180deg, #6aaf6a 0%, var(--success) 100%);
}

.delete-btn {
  background: linear-gradient(180deg, var(--danger) 0%, #863333 100%);
  color: var(--cream);
  border-color: #662222;
}

.delete-btn:hover {
  background: linear-gradient(180deg, #c65555 0%, var(--danger) 100%);
}

/* Legend */
#legend {
  display: none;
  font-size: 1rem;
  color: var(--cream-dark);
  margin: 8px 0;
  padding: 8px;
  background: var(--wood-dark);
  border: 2px solid var(--menu-border);
  border-radius: 4px;
  text-align: center;
}

/* Dialog Box - RPG event window */
#dialogBox {
  padding: 16px;
  margin: 12px 0;
  background: var(--cream);
  border: 4px solid var(--text-dark);
  border-radius: 4px;
  color: var(--text-dark);
  animation: menu-open 0.25s ease-out;
  box-shadow: 
    0 8px 24px rgba(0,0,0,0.5),
    inset -2px -2px 0 rgba(0,0,0,0.15),
    inset 2px 2px 0 rgba(255,255,255,0.4);
  position: relative;
}

#dialogBox::before {
  content: '★';
  position: absolute;
  top: -12px;
  left: 16px;
  background: var(--cream);
  padding: 0 6px;
  color: var(--gold);
  font-size: 1rem;
}

#dialogText {
  font-size: 1.2rem;
  line-height: 1.5;
  margin-bottom: 12px;
}

#dialogActions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#dialogActions button {
  background: linear-gradient(180deg, var(--wood-medium) 0%, var(--wood-dark) 100%);
  color: var(--cream);
  border-color: var(--menu-border);
  text-align: left;
  padding-left: 20px;
  position: relative;
}

#dialogActions button::before {
  content: '▶';
  position: absolute;
  left: 8px;
  opacity: 0;
  transition: opacity 0.15s;
}

#dialogActions button:hover::before {
  opacity: 1;
}

#dialogActions button:hover {
  background: linear-gradient(180deg, var(--brick-medium) 0%, var(--brick-dark) 100%);
  padding-left: 24px;
}

#dialogClose {
  margin-top: 8px;
  background: linear-gradient(180deg, #666 0%, #444 100%);
  color: var(--cream);
  border-color: #333;
  font-size: 0.95rem;
}

#dialogClose:hover {
  background: linear-gradient(180deg, #777 0%, #555 100%);
}

/* Lower info area */
#btnDivLow {
  display: none;
  gap: 8px;
  margin: 12px 0;
  font-size: 1.1rem;
  color: var(--cream);
  flex-direction: column;
  padding: 12px;
  background: var(--wood-dark);
  border: 3px solid var(--menu-border);
  border-radius: 4px;
  box-shadow: inset 1px 1px 0 rgba(255,255,255,0.05);
}

#btnDivLow div {
  padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

#btnDivLow div:last-child {
  border-bottom: none;
}

#btnDivLow strong {
  color: var(--gold);
}

.material-sets-panel h4 {
  margin: 8px 0 4px;
}

.writing-mode-btn {
  background: linear-gradient(180deg, var(--wood-medium) 0%, var(--wood-dark) 100%) !important;
  color: var(--cream) !important;
  text-align: left !important;
  padding: 12px !important;
  position: relative;
}

.writing-mode-btn::before {
  content: '▶';
  position: absolute;
  left: 8px;
  opacity: 0;
  transition: opacity 0.15s;
}

.writing-mode-btn:hover {
  background: linear-gradient(180deg, var(--brick-medium) 0%, var(--brick-dark) 100%) !important;
  padding-left: 24px !important;
}

.writing-mode-btn:hover::before {
  opacity: 1;
}

.writing-mode-btn small {
  color: var(--cream-dark);
  font-size: 0.9rem;
  display: block;
  margin-top: 4px;
}

.cost-badge {
  background: var(--gold);
  color: var(--text-dark);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.8rem;
  margin-left: 6px;
  font-weight: bold;
}

/* Continue/Present Button - Big action button */
#btnContinuar {
  display: none;
  margin: 16px auto;
  background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold) 100%);
  color: var(--text-dark);
  font-family: 'Press Start 2P', monospace;
  font-size: 0.75rem;
  padding: 14px 28px;
  border: 4px solid var(--highlight);
  border-radius: 6px;
  box-shadow: 
    0 4px 0 var(--wood-dark),
    inset 1px 1px 0 rgba(255,255,255,0.4);
  animation: bounce-small 2s ease-in-out infinite;
}

#btnContinuar:hover {
  background: linear-gradient(180deg, #ffe88a 0%, var(--gold-bright) 100%);
  transform: translateY(-2px);
  box-shadow: 
    0 6px 0 var(--wood-dark),
    inset 1px 1px 0 rgba(255,255,255,0.4);
}

#btnContinuar:active {
  transform: translateY(2px);
  box-shadow: 
    0 2px 0 var(--wood-dark),
    inset 1px 1px 0 rgba(255,255,255,0.4);
}

/* Confetti container */
.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
  overflow: hidden;
}

.confetti {
  position: absolute;
  width: 8px;
  height: 8px;
  animation: confetti-fall 1.5s ease-out forwards;
}

@keyframes confetti-fall {
  0% { 
    transform: translateY(0) rotate(0deg) scale(1);
    opacity: 1;
  }
  100% { 
    transform: translateY(-150px) rotate(720deg) scale(0);
    opacity: 0;
  }
}

/* Mobile Responsiveness */
@media (max-width: 500px) {
  body {
    padding: 10px;
  }
  
  #game {
    border-radius: 6px;
  }
  
  #player {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  
  #stats {
    width: 100%;
  }

  .profile-title {
    flex-direction: column;
    align-items: flex-start;
  }

  .profile-title strong {
    text-align: left;
  }
  
  #btnDivUp {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }
  
  #btnDivUp button {
    flex: 1 1 45%;
    font-size: 0.85rem;
    padding: 6px 6px;
  }
  
  h1 {
    font-size: 0.9rem;
  }
  
  #locationImg {
    max-width: 280px;
  }
}

/* Custom scrollbar for whole page */
::-webkit-scrollbar {
  width: 14px;
}

::-webkit-scrollbar-track {
  background: var(--wood-dark);
  border: 2px solid var(--menu-border);
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--menu-border) 0%, var(--wood-medium) 100%);
  border: 2px solid var(--wood-dark);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--gold) 0%, var(--menu-border) 100%);
}

/* ========== DAY CONTROLS ========== */
#dayControls {
  display: flex;
  gap: 12px;
  justify-content: center;
  padding: 12px 16px;
  background: var(--menu-bg);
  border-top: 2px solid var(--menu-border);
  margin-top: 8px;
}

.day-btn {
  flex: 1;
  max-width: 200px;
  padding: 10px 16px;
  font-size: 1.1rem;
}

.show-btn {
  background: linear-gradient(180deg, var(--success) 0%, #4a7a4a 100%) !important;
  color: var(--cream) !important;
  animation: bounce-small 1.5s ease-in-out infinite;
}

.show-btn:hover {
  background: linear-gradient(180deg, #6aaf6a 0%, var(--success) 100%) !important;
}

/* Show today button in main menu */
#button2.show-today {
  background: linear-gradient(180deg, var(--success) 0%, #4a7a4a 100%) !important;
  color: var(--cream) !important;
  animation: bounce-small 1.5s ease-in-out infinite;
  border-color: #3a5a3a !important;
}

#button2.show-today:hover {
  background: linear-gradient(180deg, #6aaf6a 0%, var(--success) 100%) !important;
}

#scheduledShowInfo {
  text-align: center;
  padding: 10px 12px;
  background: var(--wood-dark);
  border-top: 2px solid var(--menu-border);
  color: var(--gold);
  font-size: 1.1rem;
  margin: 4px 0;
}

/* Day stat styling */
.stat-day, .stat-points {
  background: rgba(212, 168, 75, 0.1);
  border-radius: 3px;
  margin-bottom: 4px;
  padding: 3px 6px;
  font-size: 0.95rem;
}

.stat-points[style*="--neon-pink"] {
  background: rgba(166, 68, 68, 0.2);
}

/* ========== FLOW STATE ========== */
@keyframes flow-pulse {
  0%, 100% { 
    box-shadow: 0 0 10px rgba(255, 100, 0, 0.5);
    border-color: #ff6400;
  }
  50% { 
    box-shadow: 0 0 25px rgba(255, 100, 0, 0.8);
    border-color: #ffa500;
  }
}

@keyframes flow-glow {
  0%, 100% { 
    text-shadow: 0 0 10px rgba(255, 100, 0, 0.8);
    color: #ff6400;
  }
  50% { 
    text-shadow: 0 0 20px rgba(255, 165, 0, 1);
    color: #ffa500;
  }
}

@keyframes flow-bg {
  0%, 100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

.stat-flow {
  background: linear-gradient(90deg, rgba(255, 100, 0, 0.3), rgba(255, 165, 0, 0.3), rgba(255, 100, 0, 0.3));
  background-size: 200% 200%;
  animation: flow-bg 2s ease infinite;
  border-radius: 3px;
}

.stat-flow.flow-active {
  animation: flow-bg 2s ease infinite, bounce-small 1s ease-in-out infinite;
}

.stat-flow strong {
  animation: flow-glow 1.5s ease-in-out infinite;
}

/* Flow state body effect */
body.flow-active {
  animation: none;
}

body.flow-active::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 9998;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(255, 100, 0, 0.15) 100%);
  animation: flow-pulse 2s ease-in-out infinite;
  border: 4px solid transparent;
}

body.flow-active #game {
  animation: flow-pulse 2s ease-in-out infinite;
}

/* ========== JOKE CUSTOMIZATION ========== */
.joke-customization {
  padding: 8px;
}

.joke-customization h4 {
  color: var(--gold);
  margin: 8px 0;
  font-size: 1.1rem;
}

.tone-buttons, .structure-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.tone-btn, .structure-btn {
  font-size: 0.95rem !important;
  padding: 6px 12px !important;
  background: linear-gradient(180deg, var(--wood-medium) 0%, var(--wood-dark) 100%) !important;
  color: var(--cream) !important;
}

.tone-btn:hover, .structure-btn:hover {
  background: linear-gradient(180deg, var(--brick-medium) 0%, var(--brick-dark) 100%) !important;
}

.tone-btn.selected, .structure-btn.selected {
  background: linear-gradient(180deg, var(--gold) 0%, var(--highlight) 100%) !important;
  color: var(--text-dark) !important;
  border-color: var(--gold-bright) !important;
}

.crowd-work-control {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.crowd-work-minute-btn {
  min-width: 3.5rem;
  padding: 0.35rem 0.55rem;
}

.crowd-work-minute-btn.selected {
  color: var(--text-dark);
  background: var(--gold);
  box-shadow: inset 0 0 0 2px var(--wood-dark);
}

.crowd-work-minute-btn:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.tone-btn.suggested {
  border-color: var(--success);
}

.tone-btn.current, .structure-btn.current {
  border-color: var(--gold);
}

.customization-hint {
  color: var(--cream-dark);
  font-size: 0.95rem;
  padding: 8px;
  background: rgba(0,0,0,0.2);
  border-radius: 4px;
  margin-top: 8px;
}

/* Joke title input */
.joke-title-input {
  width: 100%;
  padding: 10px 12px;
  font-family: 'VT323', monospace;
  font-size: 1.2rem;
  border: 3px solid var(--menu-border);
  border-radius: 4px;
  background: var(--cream);
  color: var(--text-dark);
  margin-bottom: 12px;
}

.joke-title-input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--gold);
}

/* Legend details */
.legend-details {
  margin: 8px 0 12px 0;
  background: rgba(0,0,0,0.2);
  border-radius: 4px;
  padding: 6px 10px;
}

.legend-details summary {
  cursor: pointer;
  color: var(--gold);
  font-size: 0.95rem;
  padding: 4px 0;
}

.legend-details summary:hover {
  color: var(--gold-bright);
}

.legend-content {
  padding: 8px 0;
  font-size: 0.9rem;
  color: var(--cream-dark);
}

.legend-item {
  padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.legend-item:last-child {
  border-bottom: none;
}

.legend-item strong {
  color: var(--gold);
}

/* Tooltip for buttons */
.tone-btn[title], .structure-btn[title] {
  position: relative;
}

.tone-btn[title]:hover::after, .structure-btn[title]:hover::after {
  content: attr(title);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--menu-bg);
  color: var(--cream);
  padding: 8px 12px;
  border-radius: 4px;
  border: 2px solid var(--menu-border);
  font-size: 0.85rem;
  white-space: normal;
  width: max-content;
  max-width: 200px;
  z-index: 100;
  margin-bottom: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  text-transform: none;
  letter-spacing: normal;
}

/* ========== SHAKE ANIMATION ========== */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* ========== NEON COLORS FOR STATS ========== */
:root {
  --neon-cyan: #00d4ff;
  --neon-pink: #ff6b9d;
  --accent-gold: #ffd700;
}

/* ========== SHOW BROWSER ========== */
#dialogActions button {
  white-space: pre-line;
  line-height: 1.4;
  min-height: 50px;
}

/* ========== HISTORY STYLES ========== */
.history-stats {
  display: flex;
  justify-content: space-around;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--menu-border);
}

.stat-box {
  text-align: center;
  padding: 8px 12px;
  background: rgba(0,0,0,0.2);
  border-radius: 6px;
  min-width: 60px;
}

.stat-box strong {
  display: block;
  font-size: 1.4rem;
  color: var(--gold);
}

.stat-box span {
  font-size: 0.85rem;
  color: var(--cream-dark);
}

.history-distribution {
  text-align: center;
  padding: 8px;
  background: rgba(0,0,0,0.15);
  border-radius: 4px;
  margin-bottom: 12px;
  font-size: 1.1rem;
  letter-spacing: 2px;
}

.history-list {
  max-height: 250px;
  overflow-y: auto;
  padding-right: 4px;
}

.history-item {
  background: var(--wood-medium);
  border: 2px solid var(--menu-border);
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 8px;
}

.history-item.history-good {
  border-color: var(--success);
  background: linear-gradient(180deg, var(--wood-medium) 0%, rgba(90, 143, 90, 0.2) 100%);
}

.history-item.history-bad {
  border-color: var(--danger);
  background: linear-gradient(180deg, var(--wood-medium) 0%, rgba(166, 68, 68, 0.2) 100%);
}

.history-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

.history-emoji {
  font-size: 1.8rem;
}

.history-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.history-info strong {
  color: var(--cream);
  font-size: 1rem;
}

.history-date {
  font-size: 0.85rem;
  color: var(--cream-dark);
}

.history-nota {
  background: var(--gold);
  color: var(--text-dark);
  padding: 4px 10px;
  border-radius: 12px;
  font-weight: bold;
  font-size: 0.9rem;
}

.history-jokes {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 1.2rem;
  letter-spacing: 3px;
}

/* ========== RESPONSIVE ADJUSTMENTS ========== */
@media (max-width: 500px) {
  #dayControls {
    flex-direction: column;
  }
  
  .day-btn {
    max-width: 100%;
  }
  
  .tone-buttons, .structure-buttons {
    justify-content: center;
  }
  
  .tone-btn, .structure-btn {
    flex: 1 1 40%;
  }
  
  .history-stats {
    flex-wrap: wrap;
  }
  
  .stat-box {
    flex: 1 1 40%;
  }
}

/* ========== DESKTOP LAYOUT ========== */
@media (min-width: 768px) {
  body {
    padding: 24px 40px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
  }

  /* Wider game container */
  #game {
    max-width: 1100px;
    width: 100%;
    border-width: 5px;
    border-radius: 12px;
    box-shadow: 
      inset 2px 2px 0 rgba(255,255,255,0.1),
      inset -2px -2px 0 rgba(0,0,0,0.3),
      0 12px 48px rgba(0,0,0,0.6);
  }

  /* Title bar larger */
  h1 {
    font-size: 1.6rem;
    padding: 20px;
    letter-spacing: 4px;
    border-bottom-width: 5px;
  }

  /* Horizontal layout: player sidebar + main content */
  #screen1 {
    display: flex;
    flex-direction: row;
    min-height: 600px;
  }

  /* Player panel as left sidebar */
  #player {
    flex-direction: column;
    align-items: stretch;
    width: 320px;
    min-width: 320px;
    max-width: 320px;
    padding: 16px;
    gap: 12px;
    border-bottom: none;
    border-right: 4px solid var(--menu-border);
    background: linear-gradient(180deg, var(--wood-medium) 0%, var(--wood-dark) 80%, var(--menu-bg) 100%);
    overflow-y: auto;
    max-height: calc(100vh - 120px);
  }

  /* Avatar centered and larger */
  #avatar {
    display: block;
    margin: 0 auto 8px;
    width: 120px;
    height: auto;
    border-width: 4px;
  }

  /* Stats box bigger text */
  #stats {
    gap: 4px;
    padding: 12px;
    border-width: 3px;
  }

  .stat {
    font-size: 1.15rem;
    padding: 4px 8px;
  }

  .stat strong {
    font-size: 0.7rem;
  }

  .stat-day, .stat-points {
    font-size: 1.1rem;
    padding: 5px 8px;
  }

  /* Action buttons - vertical column in sidebar */
  #btnDivUp {
    flex-direction: column;
    min-width: unset;
    width: 100%;
    gap: 5px;
  }

  #btnDivUp button {
    font-size: 1.1rem;
    padding: 10px 12px;
    width: 100%;
    text-align: left;
  }

  /* Day controls side by side in sidebar */
  #dayControls {
    flex-direction: row;
    padding: 12px 8px;
    gap: 8px;
  }

  .day-btn {
    max-width: 100%;
    font-size: 1.15rem;
    padding: 12px 16px;
  }

  /* Scheduled show info visible and prominent */
  #scheduledShowInfo {
    padding: 12px 14px;
    font-size: 1.2rem;
    border-radius: 6px;
    margin: 4px 0;
  }

  /* Main content area fills remaining space */
  #blackScreen {
    flex: 1;
    padding: 24px 28px;
    min-height: 600px;
    display: flex;
    flex-direction: column;
  }

  /* Larger title */
  #title {
    font-size: 1.1rem;
    margin-bottom: 16px;
  }

  /* Location image larger */
  #locationImg {
    max-width: 480px;
    margin: 0 auto 16px;
    border-width: 5px;
  }

  #locationImg.character-image {
    max-width: 220px;
  }

  /* Narration text bigger */
  #text {
    font-size: 1.4rem;
    line-height: 1.7;
    padding: 18px;
    margin: 16px 0;
    border-width: 4px;
  }

  #subTitle {
    font-size: 1.5rem;
    margin: 16px 0;
  }

  /* Joke list larger */
  #jokeList {
    max-height: 400px;
    padding: 12px;
    border-width: 3px;
  }

  .joke-item {
    padding: 14px 16px;
    gap: 6px;
    margin-bottom: 8px;
  }

  .joke-item strong {
    font-size: 1.25rem;
  }

  .joke-item span {
    font-size: 1.1rem;
  }

  .joke-meta {
    font-size: 1.05rem;
  }

  .joke-history {
    font-size: 1.35rem;
    letter-spacing: 4px;
  }

  /* Dialog box bigger */
  #dialogBox {
    padding: 20px;
    margin: 16px 0;
    border-width: 4px;
  }

  #dialogText {
    font-size: 1.35rem;
    line-height: 1.6;
    margin-bottom: 16px;
  }

  #dialogActions {
    gap: 8px;
  }

  #dialogActions button {
    font-size: 1.15rem;
    padding: 12px 16px;
    padding-left: 24px;
    min-height: 56px;
  }

  #dialogClose {
    font-size: 1.05rem;
    margin-top: 12px;
  }

  /* Lower info area bigger */
  #btnDivLow {
    font-size: 1.25rem;
    padding: 16px;
    border-width: 3px;
  }

  /* Continue button bigger */
  #btnContinuar {
    font-size: 0.9rem;
    padding: 18px 36px;
    border-width: 5px;
    margin: 20px auto;
  }

  /* Bigger general buttons */
  button {
    font-size: 1.2rem;
    padding: 10px 16px;
    border-width: 3px;
  }

  /* Writing mode buttons */
  .writing-mode-btn {
    padding: 14px !important;
    font-size: 1.2rem !important;
  }

  .writing-mode-btn small {
    font-size: 1rem;
  }

  .cost-badge {
    font-size: 0.9rem;
    padding: 3px 10px;
  }

  /* Joke customization */
  .joke-customization h4 {
    font-size: 1.25rem;
  }

  .tone-btn, .structure-btn {
    font-size: 1.05rem !important;
    padding: 8px 16px !important;
  }

  .customization-hint {
    font-size: 1.05rem;
  }

  .joke-title-input {
    font-size: 1.3rem;
    padding: 12px 14px;
  }

  /* Legend */
  #legend {
    font-size: 1.1rem;
    padding: 10px;
  }

  .legend-details summary {
    font-size: 1.05rem;
  }

  .legend-content {
    font-size: 1rem;
  }

  /* History styles bigger */
  .history-stats {
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 16px;
  }

  .stat-box {
    padding: 12px 16px;
    min-width: 80px;
  }

  .stat-box strong {
    font-size: 1.7rem;
  }

  .stat-box span {
    font-size: 1rem;
  }

  .history-distribution {
    font-size: 1.25rem;
    letter-spacing: 3px;
  }

  .history-list {
    max-height: 350px;
  }

  .history-item {
    padding: 14px;
    margin-bottom: 10px;
  }

  .history-emoji {
    font-size: 2.2rem;
  }

  .history-info strong {
    font-size: 1.15rem;
  }

  .history-date {
    font-size: 1rem;
  }

  .history-nota {
    font-size: 1rem;
    padding: 5px 14px;
  }

  .history-jokes {
    font-size: 1.35rem;
    letter-spacing: 4px;
  }

  /* Intro screen - bigger on desktop */
  #introScreen {
    padding: 36px 40px;
    gap: 20px;
    max-width: 680px;
    margin: 0 auto;
  }

  #mentorImg {
    max-width: 140px;
  }

  #introText {
    font-size: 1.5rem;
    line-height: 1.6;
    padding: 20px;
    min-height: 120px;
  }

  #nameInput h3 {
    font-size: 1.6rem;
  }

  #playerNameInput {
    font-size: 1.5rem;
    max-width: 320px;
    padding: 14px 20px;
  }

  #avatarSelection {
    gap: 24px;
  }

  .avatar-option {
    padding: 16px;
    gap: 10px;
  }

  .avatar-option img {
    width: 100px;
  }

  .avatar-option span {
    font-size: 1.1rem;
  }

  /* Scrollbar for sidebar */
  #player::-webkit-scrollbar {
    width: 10px;
  }

  #player::-webkit-scrollbar-track {
    background: var(--wood-dark);
  }

  #player::-webkit-scrollbar-thumb {
    background: var(--menu-border);
    border-radius: 4px;
  }

  /* Flow indicator more visible */
  .stat-flow {
    padding: 6px 8px;
  }

  .stat-flow strong {
    font-size: 0.75rem;
  }

  /* Confetti bigger */
  .confetti {
    width: 12px;
    height: 12px;
  }

  /* Rewrite/delete buttons */
  .rewrite-btn, .delete-btn {
    font-size: 1rem;
    padding: 6px 14px;
  }

  /* Tooltip on desktop is better */
  .tone-btn[title]:hover::after, .structure-btn[title]:hover::after {
    font-size: 0.95rem;
    max-width: 260px;
    padding: 10px 14px;
  }
}

/* Extra-wide screens */
@media (min-width: 1200px) {
  #game {
    max-width: 1280px;
  }

  #player {
    width: 360px;
    min-width: 360px;
    max-width: 360px;
    padding: 20px;
  }

  #avatar {
    width: 140px;
  }

  .stat {
    font-size: 1.25rem;
  }

  .stat strong {
    font-size: 0.75rem;
  }

  #btnDivUp button {
    font-size: 1.15rem;
    padding: 12px 14px;
  }

  #blackScreen {
    padding: 28px 36px;
  }

  #text {
    font-size: 1.5rem;
  }

  #locationImg {
    max-width: 560px;
  }

  #dialogText {
    font-size: 1.4rem;
  }
}

/* ─── Ending View (main game panel, never an overlay) ─── */
.ending-screen {
  width: 100%;
  color: var(--text-light);
  padding: 0;
}

#blackScreen.ending-active > :not(#endingScreen) {
  display: none !important;
}

.ending-screen.hidden {
  display: none !important;
}

.ending-screen__inner {
  width: 100%;
  display: grid;
  gap: 16px;
}

.ending-screen__art,
.ending-screen__copy {
  border: 5px solid var(--gold);
  border-radius: 8px;
  background: rgba(26, 20, 16, 0.72);
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.55),
    inset 0 0 0 2px rgba(245, 230, 200, 0.18);
}

.ending-screen__art {
  min-height: 210px;
  overflow: hidden;
  position: relative;
}

.ending-screen__art::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.32) 1px, transparent 1px),
    linear-gradient(0deg, rgba(0, 0, 0, 0.28) 1px, transparent 1px);
  background-size: 34px 34px;
  opacity: 0.35;
}

.ending-screen__art-image {
  width: 100%;
  height: 100%;
  min-height: 210px;
  display: block;
  object-fit: cover;
  position: relative;
  z-index: 1;
}

.ending-screen__copy {
  padding: clamp(18px, 3vw, 32px);
}

.ending-screen__eyebrow {
  margin: 0 0 8px;
  color: var(--gold-bright);
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  font-size: 0.78rem;
}

.ending-screen__copy h2 {
  margin: 0 0 18px;
  color: var(--cream);
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(2.6rem, 7vw, 4.6rem);
  line-height: 0.95;
}

.ending-screen__prose {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.ending-screen__prose p {
  margin: 0;
  color: var(--cream);
  font-size: 1rem;
  line-height: 1.55;
}

.ending-screen__summary {
  margin: 0 0 16px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.ending-screen__summary div {
  min-width: 0;
  border: 2px solid var(--menu-border);
  border-radius: 6px;
  padding: 9px 10px;
  background: rgba(245, 230, 200, 0.09);
}

.ending-screen__summary dt {
  color: var(--gold-bright);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  margin-bottom: 4px;
}

.ending-screen__summary dd {
  margin: 0;
  color: var(--cream);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.ending-screen__unlock {
  border-left: 4px solid var(--success);
  padding: 10px 12px;
  margin-bottom: 18px;
  background: rgba(90, 143, 90, 0.16);
  color: var(--cream);
}

.ending-screen__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.ending-screen__actions button {
  flex: 1 1 180px;
  min-height: 48px;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: var(--text-dark);
  border: 3px solid var(--menu-border);
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.35);
}

.ending-screen__actions button:hover,
.ending-screen__actions button:focus-visible {
  transform: translateY(-2px);
  outline: 2px solid var(--spotlight);
  outline-offset: 2px;
}

.ending-archive-new-run {
  align-self: stretch;
  min-height: 44px;
  margin-top: 6px;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: var(--text-dark);
  border: 3px solid var(--menu-border);
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  cursor: pointer;
}

@media (max-width: 820px) {
  .ending-screen__art {
    min-height: auto;
  }

  .ending-screen__art-image {
    min-height: 180px;
  }

  .ending-screen__summary {
    grid-template-columns: minmax(0, 1fr);
  }
}

.critical-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.3s ease;
}

.critical-overlay.hidden {
  display: none !important;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.critical-dialog {
  background: var(--cream, #f5e6c8);
  border: 5px solid var(--gold, #d4a84b);
  border-radius: 8px;
  padding: 24px;
  max-width: 560px;
  width: 100%;
  color: var(--text-dark, #1a1a2e);
  box-shadow: 0 12px 40px rgba(0,0,0,0.6), 0 0 20px rgba(212, 168, 75, 0.3);
  animation: criticalPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

.critical-dialog::before {
  content: '⚡';
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--cream, #f5e6c8);
  padding: 0 10px;
  font-size: 1.2rem;
}

@keyframes criticalPop {
  from { opacity: 0; transform: scale(0.8) translateY(30px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

#criticalDialogText {
  font-size: 1.2rem;
  line-height: 1.6;
  margin-bottom: 16px;
  white-space: pre-line;
}

.critical-dialog-content {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  margin-bottom: 14px;
}

.critical-dialog-content.no-image {
  grid-template-columns: minmax(0, 1fr);
}

.critical-dialog-image {
  width: 170px;
  height: 170px;
  object-fit: contain;
  object-position: center center;
  padding: 6px;
  box-sizing: border-box;
  border: 3px solid var(--menu-border, #3d2e1f);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.18);
}

.critical-dialog-image.character-image {
  width: 150px;
  height: 200px;
  object-position: center top;
  border-radius: 12px;
}

.critical-dialog-content #criticalDialogText {
  margin-bottom: 0;
}

#criticalDialogActions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#criticalDialogActions button {
  background: linear-gradient(180deg, var(--wood-medium, #8b7355) 0%, var(--wood-dark, #5c4a32) 100%);
  color: var(--cream, #f5e6c8);
  border: 3px solid var(--menu-border, #3d2e1f);
  border-radius: 4px;
  padding: 10px 20px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1rem;
  cursor: pointer;
  text-align: left;
  position: relative;
  padding-left: 24px;
  transition: all 0.2s ease;
}

#criticalDialogActions button::before {
  content: '▶';
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  color: var(--gold, #d4a84b);
}

#criticalDialogActions button:hover {
  background: linear-gradient(180deg, var(--wood-dark, #5c4a32) 0%, var(--wood-medium, #8b7355) 100%);
  transform: translateX(3px);
}

@media (max-width: 680px) {
  .critical-dialog-content {
    grid-template-columns: minmax(0, 1fr);
  }

  .critical-dialog-image {
    width: min(240px, 100%);
    height: auto;
    aspect-ratio: 1 / 1;
    justify-self: center;
  }

  .critical-dialog-image.character-image {
    width: min(180px, 70vw);
    aspect-ratio: 3 / 4;
  }
}
