/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --parchment: #FDF5E6;
  --parchment-dark: #F5E6CC;
  --brown: #8B4513;
  --brown-light: #A0522D;
  --brown-dark: #5C2E0A;
  --ink: #2C1810;
  --ink-light: #4A3728;
  --gold: #DAA520;
  --gold-light: #FFD700;
  --accent: #C0392B;
  --accent-light: #E74C3C;
  --green: #27AE60;
  --green-light: #2ECC71;
  --ai-bg: #EDE7F6;
  --ai-border: #9575CD;
  --shadow: rgba(44, 24, 16, 0.15);
  --radius: 12px;
  --radius-sm: 8px;
  --font-story: 'Merriweather', Georgia, 'Times New Roman', serif;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --max-width: 600px;
}

html { font-size: 16px; }
body {
  font-family: var(--font-ui);
  background: var(--parchment);
  color: var(--ink);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* ===== SCREENS ===== */
.screen {
  display: none;
  min-height: 100dvh;
  padding: 1rem;
}
.screen.active { display: flex; }

.screen-container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
}

/* ===== HOME ===== */
#screen-home {
  align-items: center;
  justify-content: center;
  position: relative;
}

.home-container {
  width: 100%;
  max-width: var(--max-width);
  text-align: center;
}

.logo { margin-bottom: 2.5rem; }
.logo-icon { font-size: 4rem; margin-bottom: 0.5rem; }
.logo h1 {
  font-family: var(--font-story);
  font-size: 2.5rem;
  color: var(--brown);
  letter-spacing: -0.02em;
}
.subtitle {
  font-size: 1rem;
  color: var(--ink-light);
  margin-top: 0.25rem;
}

.home-actions { display: flex; flex-direction: column; gap: 0.75rem; }

.divider {
  display: flex; align-items: center; gap: 1rem;
  color: var(--ink-light); font-size: 0.85rem;
  margin: 0.5rem 0;
}
.divider::before, .divider::after {
  content: ''; flex: 1; height: 1px;
  background: var(--brown-light); opacity: 0.3;
}

.join-form { display: flex; flex-direction: column; gap: 0.75rem; }

.settings-btn {
  position: absolute;
  top: 1rem; right: 1rem;
  font-size: 1.5rem;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-ui);
  font-size: 1rem; font-weight: 600;
  border: none; border-radius: var(--radius);
  cursor: pointer;
  padding: 0.75rem 1.5rem;
  transition: all 0.15s ease;
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--brown);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--brown-light); }

.btn-secondary {
  background: var(--parchment-dark);
  color: var(--brown-dark);
  border: 1.5px solid var(--brown);
}
.btn-secondary:hover:not(:disabled) { background: #EDE0CC; }

.btn-accent {
  background: var(--accent);
  color: #fff;
}
.btn-accent:hover:not(:disabled) { background: var(--accent-light); }

.btn-ghost {
  background: transparent;
  color: var(--ink-light);
}
.btn-ghost:hover { background: var(--parchment-dark); }

.btn-large { padding: 1rem 2rem; font-size: 1.1rem; }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.8rem; }

.btn-icon {
  background: none; border: none;
  cursor: pointer; font-size: 1.25rem;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  color: var(--ink-light);
  transition: background 0.15s;
}
.btn-icon:hover { background: var(--parchment-dark); }

.btn-back {
  background: none; border: none;
  font-size: 1rem; color: var(--brown);
  cursor: pointer; padding: 0.5rem 0;
  font-weight: 500; margin-bottom: 1rem;
  font-family: var(--font-ui);
}
.btn-back:hover { color: var(--brown-light); }

.btn-leave {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn-leave:hover:not(:disabled) { background: var(--accent-light); }

.mode-screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.mode-screen-header .btn-back { margin-bottom: 0; }

.btn-info {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--parchment-dark);
  font-weight: 700; font-size: 1rem;
  color: var(--brown);
  display: flex; align-items: center; justify-content: center;
}
.btn-info:hover { background: #EDE0CC; }

.mode-info-body { font-size: 0.95rem; line-height: 1.7; color: var(--ink); }
.mode-info-body p { margin-bottom: 0.75rem; }
.mode-info-body ul { margin: 0.5rem 0 0.75rem 1.25rem; }
.mode-info-body li { margin-bottom: 0.3rem; }

/* ===== INPUTS ===== */
.input {
  width: 100%;
  font-family: var(--font-ui);
  font-size: 1rem;
  padding: 0.75rem 1rem;
  border: 1.5px solid rgba(139, 69, 19, 0.3);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  transition: border-color 0.15s;
}
.input:focus {
  outline: none;
  border-color: var(--brown);
  box-shadow: 0 0 0 3px rgba(139, 69, 19, 0.1);
}
.input::placeholder { color: #A99080; }

#input-room-code {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

.hint {
  font-size: 0.8rem;
  color: var(--ink-light);
  margin-top: 0.35rem;
}

.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
}

/* ===== MODAL ===== */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 1rem;
}
.modal[hidden] { display: none; }
.modal-content {
  background: var(--parchment);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%; max-width: 400px;
  box-shadow: 0 8px 32px var(--shadow);
}
.modal-content h2 { margin-bottom: 1rem; }
.modal-wide { max-width: 700px; }
.opening-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 600px) {
  .opening-compare { grid-template-columns: 1fr; }
}
.opening-option {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: var(--radius-sm);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.opening-option h3 {
  font-size: 0.9rem;
  color: var(--ink-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.opening-text {
  font-family: 'Merriweather', serif;
  font-size: 0.9rem;
  line-height: 1.7;
  flex: 1;
}
.opening-option .btn { align-self: center; }
.modal-actions {
  display: flex; gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
}

/* ===== GENRE GRID ===== */
.genre-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-bottom: 2rem;
}

.genre-card {
  background: #fff;
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 1rem;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
  box-shadow: 0 2px 8px var(--shadow);
}
.genre-card:hover {
  border-color: var(--gold);
  box-shadow: 0 4px 16px var(--shadow);
}
.genre-card:active { transform: scale(0.98); }

.genre-card .genre-icon { font-size: 1.75rem; margin-bottom: 0.35rem; }
.genre-card .genre-name {
  font-weight: 700; font-size: 1rem;
  color: var(--brown-dark);
}
.genre-card .genre-desc {
  font-size: 0.8rem; color: var(--ink-light);
  margin-top: 0.2rem; line-height: 1.4;
}

.genre-section-title {
  font-family: var(--font-story);
  font-size: 0.85rem;
  color: var(--brown);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 0.75rem;
  margin-bottom: -0.25rem;
  padding-left: 0.25rem;
}

/* ===== LOBBY ===== */
.lobby-header { text-align: center; margin-bottom: 1.5rem; padding-top: 1rem; }

.room-code-display {
  display: flex; align-items: center; justify-content: center;
  gap: 0.5rem; margin: 0.75rem 0;
}
.room-code {
  font-size: 2.5rem; font-weight: 700;
  letter-spacing: 0.3em;
  color: var(--brown);
  font-family: var(--font-ui);
}
.lobby-genre {
  font-family: var(--font-story);
  font-style: italic;
  color: var(--ink-light);
}

.player-list-section { margin-bottom: 1.5rem; }
.player-list-section h3 { margin-bottom: 0.5rem; }

.player-list {
  list-style: none;
  display: flex; flex-direction: column; gap: 0.5rem;
}
.player-item {
  background: #fff;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; gap: 0.75rem;
  box-shadow: 0 1px 4px var(--shadow);
}
.player-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  color: #fff; font-weight: 700;
}
.player-name { font-weight: 500; flex: 1; }
.player-host-badge {
  font-size: 0.7rem; font-weight: 600;
  background: var(--gold);
  color: #fff;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

.lobby-actions { text-align: center; }

.toggle-option {
  display: flex; align-items: center; gap: 0.5rem;
  justify-content: center;
  font-size: 0.9rem; color: var(--ink-light);
  margin-bottom: 1rem; cursor: pointer;
  user-select: none;
}
.toggle-option input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--brown);
  cursor: pointer;
}
.waiting-text {
  font-style: italic;
  color: var(--ink-light);
}

/* ===== GAME ===== */
.game-layout {
  display: flex; flex-direction: column;
  min-height: 100dvh;
  padding-top: 0.5rem;
}

.game-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
}
.game-header-right {
  display: flex; align-items: center; gap: 0.5rem;
}
.lobby-title-row {
  display: flex; align-items: center; justify-content: space-between;
}
.game-header h2 { font-family: var(--font-story); }
.room-badge {
  font-size: 0.75rem; font-weight: 700;
  background: var(--parchment-dark);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  color: var(--brown);
  letter-spacing: 0.15em;
}

/* Story container */
.story-container {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 1rem;
}

.story-entry {
  margin-bottom: 1.25rem;
  animation: fadeIn 0.3s ease;
}

.story-entry-header {
  display: flex; align-items: center; gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.story-author {
  font-size: 0.8rem; font-weight: 600;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  color: #fff;
}
.story-type-badge {
  font-size: 0.7rem;
  color: var(--ink-light);
  font-style: italic;
}

.story-text {
  font-family: var(--font-story);
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--ink);
  white-space: pre-wrap;
}

.copy-scope-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.copy-scope-btn {
  width: 100%;
  text-align: center;
}


.story-entry.atmosphere-entry {
  text-align: center;
  padding: 0.5rem 1rem;
  margin: 0.25rem 0;
}
.story-entry.atmosphere-entry .story-text {
  font-style: italic;
  color: var(--ink-light);
  font-size: 0.9rem;
  background: none;
  border: none;
  padding: 0;
}

.story-entry.ai-entry .story-text {
  background: var(--ai-bg);
  border-left: 3px solid var(--ai-border);
  padding: 0.75rem 1rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Turn panel */
.turn-panel {
  background: #fff;
  border: 2px solid var(--green);
  border-radius: var(--radius);
  padding: 1rem;
  margin-top: auto;
}

.turn-indicator {
  display: flex; flex-direction: column;
  margin-bottom: 0.5rem;
}
.turn-label {
  font-weight: 700; color: var(--green);
  font-size: 1.1rem;
}
.turn-hint {
  font-size: 0.8rem; color: var(--ink-light);
}

.story-input {
  width: 100%;
  font-family: var(--font-story);
  font-size: 1rem;
  line-height: 1.6;
  padding: 0.75rem;
  border: 1.5px solid rgba(139, 69, 19, 0.2);
  border-radius: var(--radius-sm);
  resize: vertical;
  min-height: 100px;
  background: var(--parchment);
  color: var(--ink);
}
.story-input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.1);
}

.hint-panel {
  background: #FFF9E6;
  border: 1px solid #E6D5A0;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--ink);
}
.hint-suggestions { white-space: pre-wrap; }

.turn-actions {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  margin-top: 0.5rem;
}
.char-count { font-size: 0.8rem; color: var(--ink-light); flex: 1; }

.btn-voice {
  font-size: 1.3rem;
  padding: 0.4rem;
  border-radius: 50%;
  transition: all 0.2s;
}
.btn-voice.recording {
  background: var(--accent);
  color: #fff;
  animation: pulse-mic 1.2s ease-in-out infinite;
}
@keyframes pulse-mic {
  0%, 100% { box-shadow: 0 0 0 0 rgba(192, 57, 43, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(192, 57, 43, 0); }
}

/* Waiting panel */
.waiting-panel {
  text-align: center;
  padding: 1.5rem;
  background: var(--parchment-dark);
  border-radius: var(--radius);
  margin-top: auto;
}
.waiting-panel p { font-size: 1rem; color: var(--ink-light); }

.waiting-dots { display: flex; justify-content: center; gap: 0.3rem; margin-top: 0.5rem; }
.waiting-dots span {
  font-size: 1.5rem; color: var(--brown);
  animation: bounce 1.4s infinite;
}
.waiting-dots span:nth-child(2) { animation-delay: 0.2s; }
.waiting-dots span:nth-child(3) { animation-delay: 0.4s; }

/* AI working panel */
.ai-panel {
  text-align: center;
  padding: 1.5rem;
  background: var(--ai-bg);
  border-radius: var(--radius);
  margin-top: auto;
}
.ai-spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--ai-border);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 0.5rem;
}

/* Game bottom actions (illustrate + host controls) */
.game-bottom-actions {
  display: flex; justify-content: center; gap: 0.75rem;
  padding: 0.75rem 0;
  flex-wrap: wrap;
}

.twist-hint {
  width: 100%;
  text-align: center;
  font-size: 0.75rem;
  color: var(--ai-border);
  font-style: italic;
}
.twist-hint[hidden] { display: none; }

.btn-illustrate[hidden] { display: none; }
.btn-illustrate {
  font-size: 0.9rem;
  padding: 0.6rem 1rem;
}
.btn-illustrate:disabled {
  opacity: 0.6;
}
.btn-illustrate .spinner-inline {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--brown-light);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 0.3rem;
}

/* Secret objective banner (in-game) */
.objective-banner {
  background: linear-gradient(135deg, #FFF8E1, #FFF3C4);
  border: 2px solid var(--gold);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 0.75rem;
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--ink);
  animation: fadeIn 0.3s ease;
}
.objective-banner[hidden] { display: none; }
.objective-banner .objective-icon {
  margin-right: 0.2rem;
}
.objective-done-btn {
  margin-left: 0.5rem;
  font-size: 0.8rem;
  vertical-align: middle;
}

/* End-game vote panel */
.end-vote-panel {
  background: #fff;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  animation: fadeIn 0.3s ease;
}
.end-vote-panel[hidden] { display: none; }
.end-vote-title {
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  text-align: center;
}
.end-vote-player {
  display: inline-block;
  font-size: 0.8rem;
  padding: 0.15rem 0.5rem;
  margin: 0.15rem;
  border-radius: 999px;
  background: var(--parchment-dark);
  color: var(--ink-light);
}
.end-vote-player.voted {
  background: #e8f5e9;
  color: var(--green);
  font-weight: 500;
}
.end-vote-actions {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.end-vote-waiting {
  font-size: 0.85rem;
  color: var(--ink-light);
  font-weight: 500;
}

/* Final round banner */
.final-round-banner {
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: var(--brown-dark);
  text-align: center;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  margin-bottom: 1rem;
  animation: fadeIn 0.3s ease;
}

/* ===== REACTIONS ===== */
.story-reactions {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.4rem;
  flex-wrap: wrap;
}

.reaction-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  background: var(--parchment-dark);
  border: 1.5px solid transparent;
  border-radius: 999px;
  padding: 0.2rem 0.5rem;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--font-ui);
  line-height: 1;
}
.reaction-btn:hover:not(:disabled) {
  background: #EDE0CC;
  border-color: var(--brown-light);
}
.reaction-btn:active:not(:disabled) { transform: scale(0.93); }
.reaction-btn:disabled { opacity: 0.6; cursor: wait; }

.reaction-btn.reacted {
  background: #E8D5B7;
  border-color: var(--gold);
}

.reaction-count {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink-light);
  min-width: 0.75rem;
  text-align: center;
}

/* ===== REACTION LEADERBOARD ===== */
.reaction-leaderboard {
  background: #fff;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: 0 2px 8px var(--shadow);
  margin-bottom: 1.5rem;
}
.reaction-leaderboard h3 {
  font-family: var(--font-story);
  font-size: 1rem;
  color: var(--brown);
  margin-bottom: 0.75rem;
  text-align: center;
}
.reaction-leaderboard table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.reaction-leaderboard th {
  border-bottom: 1.5px solid var(--parchment-dark);
  padding: 0.3rem 0.25rem;
  font-weight: 600;
  color: var(--ink-light);
}
.reaction-leaderboard td {
  padding: 0.35rem 0.25rem;
  border-bottom: 1px solid var(--parchment-dark);
}
.reaction-leaderboard .lb-name {
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}
.reaction-leaderboard .lb-emoji { text-align: center; }
.reaction-leaderboard .lb-total {
  text-align: center;
  font-weight: 700;
  color: var(--brown);
}

/* ===== FINISHED ===== */
.finished-header {
  text-align: center;
  padding: 2rem 0 1rem;
}
.finished-icon { font-size: 3rem; margin-bottom: 0.5rem; }
.finished-header h2 { font-family: var(--font-story); }

.final-story {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: 0 4px 16px var(--shadow);
  margin-bottom: 1.5rem;
  max-height: none;
  overflow: visible;
}

.finished-actions {
  display: flex; flex-direction: column; gap: 0.75rem;
  padding-bottom: 2rem;
}

/* ===== OBJECTIVES REVEAL ===== */
.objectives-reveal {
  background: #fff;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: 0 2px 8px var(--shadow);
  margin-bottom: 1.5rem;
  border: 2px solid var(--gold);
}
.objectives-reveal h3 {
  font-family: var(--font-story);
  font-size: 1rem;
  color: var(--brown);
  margin-bottom: 0.25rem;
  text-align: center;
}
.objectives-subtitle {
  font-size: 0.8rem;
  color: var(--ink-light);
  text-align: center;
  margin-bottom: 0.75rem;
}
.objectives-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.objective-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--parchment);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
}
.objective-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.objective-player {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink);
}
.objective-text {
  font-family: var(--font-story);
  font-size: 0.9rem;
  font-style: italic;
  color: var(--brown);
  line-height: 1.4;
}

/* ===== ILLUSTRATION ENTRIES ===== */
.story-illustration {
  text-align: center;
  margin-bottom: 1.25rem;
  animation: fadeIn 0.3s ease;
}
.story-illustration img {
  max-width: 100%;
  width: 400px;
  border-radius: var(--radius);
  box-shadow: 0 2px 12px var(--shadow);
}
.story-illustration .illust-credit {
  font-size: 0.75rem;
  color: var(--ink-light);
  margin-top: 0.35rem;
  font-style: italic;
}
.story-illustration .illust-shimmer {
  width: 400px;
  max-width: 100%;
  height: 260px;
  background: linear-gradient(110deg, var(--parchment-dark) 30%, #fff 50%, var(--parchment-dark) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius);
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* Illustration scope modal */
.illustrate-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.illustrate-option {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 0.75rem;
  background: #fff;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}
.illustrate-option:hover { background: var(--parchment-dark); }
.illustrate-option input[type="radio"] {
  accent-color: var(--brown);
  width: 16px; height: 16px;
}
.illustrate-option > span:first-of-type {
  font-weight: 500;
  flex: 1;
}
.illustrate-option > .hint {
  width: 100%;
  margin-top: 0;
  padding-left: 1.6rem;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 2rem; left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  z-index: 200;
  animation: fadeInUp 0.3s ease;
  white-space: nowrap;
}
.toast[hidden] { display: none; }

/* ===== PLAYER COLORS ===== */
.player-color-0 { background: #E74C3C; }
.player-color-1 { background: #3498DB; }
.player-color-2 { background: #27AE60; }
.player-color-3 { background: #F39C12; }
.player-color-4 { background: #9B59B6; }
.player-color-5 { background: #1ABC9C; }
.player-color-6 { background: #E67E22; }

/* ===== AVATAR PICKER ===== */
.avatar-picker {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.avatar-pick-btn {
  width: 44px;
  height: 44px;
  font-size: 1.5rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
  font-family: inherit;
}
.avatar-pick-btn:hover {
  background: var(--parchment-dark);
  border-color: var(--brown-light);
}
.avatar-pick-btn.selected {
  border-color: var(--gold);
  background: rgba(218, 165, 32, 0.15);
  box-shadow: 0 0 0 2px rgba(218, 165, 32, 0.3);
}

.player-avatar.avatar-emoji {
  font-size: 1.35rem;
  color: initial;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translate(-50%, 16px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-8px); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== MODE PICKER ===== */
.mode-picker { display: flex; gap: 1rem; margin: 1.5rem 0; }
.mode-card {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 0.5rem; padding: 1.5rem 1rem;
  background: #fff; border: 2px solid #e0d5c0; border-radius: var(--radius);
  cursor: pointer; transition: border-color 0.2s, transform 0.2s;
  font-family: var(--font-ui);
}
.mode-card:hover { border-color: var(--green); transform: translateY(-2px); }
.mode-card:active { transform: scale(0.97); }
.mode-icon { font-size: 2.5rem; }
.mode-name { font-weight: 600; font-size: 1.1rem; color: var(--ink); }
.mode-desc { font-size: 0.8rem; color: var(--ink-light); text-align: center; }

/* ===== RESUME BANNERS ===== */
.resume-banner {
  display: flex; align-items: center; justify-content: space-between;
  background: #FFF8E1; border: 1px solid #E6D5A0; border-radius: var(--radius-sm);
  padding: 0.75rem 1rem; margin-bottom: 0.5rem; font-size: 0.9rem;
}
.resume-banner[hidden] { display: none; }

/* ===== TURN COUNT PICKER ===== */
.turn-count-picker { margin: 1rem 0; }
.turn-count-picker label { font-weight: 600; font-size: 0.9rem; }
.turn-count-options { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.turn-count-btn {
  flex: 1; padding: 0.75rem; border: 2px solid #ddd; border-radius: var(--radius-sm);
  background: #fff; cursor: pointer; font-size: 1.1rem; font-weight: 600;
  font-family: var(--font-ui); color: var(--ink);
  transition: border-color 0.15s, background 0.15s;
}
.turn-count-btn:hover { border-color: var(--brown-light); }
.turn-count-btn.active { border-color: var(--green); background: #f0faf0; }

/* ===== SECRET ROLE BANNER (solo in-game) ===== */
.secret-role-banner {
  background: linear-gradient(135deg, #E8F5E9, #C8E6C9);
  border: 2px solid #66BB6A;
  border-radius: var(--radius);
  padding: 1rem; margin-bottom: 0.75rem;
  font-size: 1.05rem; line-height: 1.5;
  animation: fadeIn 0.3s ease;
}
.secret-role-banner[hidden] { display: none; }
.secret-role-banner .role-icon { margin-right: 0.2rem; }

/* ===== TURN COUNTER (solo game header) ===== */
.turn-counter {
  font-size: 0.8rem; font-weight: 600;
  background: var(--green); color: #fff;
  padding: 0.2rem 0.6rem; border-radius: 999px;
}
.turn-counter[hidden] { display: none; }

/* ===== SOLO ROLE REVEAL (finished screen) ===== */
.solo-role-reveal {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: 0 2px 8px var(--shadow);
  margin-bottom: 1.5rem;
  border: 2px solid #66BB6A;
}
.solo-role-reveal[hidden] { display: none; }
.solo-role-reveal h3 {
  font-family: var(--font-story);
  font-size: 1rem;
  color: var(--brown);
  margin-bottom: 0.75rem;
  text-align: center;
}
.solo-role-section {
  margin-bottom: 0.75rem;
  padding: 0.75rem;
  background: var(--parchment);
  border-radius: var(--radius-sm);
}
.solo-role-section:last-child { margin-bottom: 0; }
.solo-role-label {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink-light);
  margin-bottom: 0.25rem;
}
.solo-role-text {
  font-family: var(--font-story);
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--ink);
}

/* ===== ADVENTURE MODE ===== */
.adventure-turn-panel {
  border-color: #7E57C2;
}

.adventure-options-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.adventure-option-card {
  width: 100%;
  text-align: left;
  padding: 0.75rem 1rem;
  background: #fff;
  border: 2px solid #D1C4E9;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  color: var(--ink);
  transition: all 0.15s ease;
}
.adventure-option-card:hover {
  border-color: #7E57C2;
  background: #F3E5F5;
}
.adventure-option-card.selected {
  border-color: #7E57C2;
  background: #EDE7F6;
  box-shadow: 0 0 0 2px rgba(126, 87, 194, 0.25);
  font-weight: 600;
}
.adventure-option-card:active { transform: scale(0.98); }

.adventure-option-custom {
  border-style: dashed;
  color: var(--ink-light);
  font-style: italic;
}
.adventure-option-custom.selected {
  font-style: normal;
  color: var(--ink);
}

/* Situation option chips (in story entries) */
.situation-options-display {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.option-chip {
  display: inline-block;
  font-size: 0.8rem;
  padding: 0.2rem 0.6rem;
  background: var(--parchment-dark);
  border: 1px solid #D1C4E9;
  border-radius: 999px;
  color: var(--ink-light);
}
.option-chip.option-chosen {
  background: #EDE7F6;
  border-color: #7E57C2;
  color: #7E57C2;
  font-weight: 600;
}

/* Adventure banner (goal/antagonist/setting) */
.adventure-banner {
  background: linear-gradient(135deg, #F3E5F5, #EDE7F6);
  border: 2px solid #7E57C2;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  animation: fadeIn 0.3s ease;
}
.adventure-banner[hidden] { display: none; }
.adventure-banner-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: #5E35B1;
  margin-bottom: 0.35rem;
}
.adventure-banner-item {
  font-size: 0.85rem;
  color: var(--ink);
  line-height: 1.5;
}

/* Finale badge on climax situations */
.finale-badge {
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--accent);
  color: #fff;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  animation: pulse-finale 2s ease-in-out infinite;
}
@keyframes pulse-finale {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Mode picker: 3 cards layout */
.mode-picker {
  flex-wrap: wrap;
}

/* ===== RESPONSIVE ===== */
@media (min-width: 480px) {
  .genre-grid { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 768px) {
  :root { --max-width: 700px; }
  .logo h1 { font-size: 3rem; }
}
