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

body {
  font-family: 'Segoe UI', Tahoma, sans-serif;
  background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
  color: #f0f0f0;
  min-height: 100vh;
  overflow-x: hidden;
}

.screen { display: none; min-height: 100vh; padding: 24px; }
.screen.active { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.hidden { display: none !important; }

/* ===== START ===== */
.hero {
  max-width: 720px;
  text-align: center;
  background: rgba(0, 0, 0, 0.4);
  padding: 40px;
  border-radius: 20px;
  border: 2px solid #6c5ce7;
  box-shadow: 0 0 40px rgba(108, 92, 231, 0.5);
}
.start-image {
  display: block;
  margin: 0 auto 20px;
  max-width: 100%;
  max-height: 320px;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.6);
  border: 2px solid rgba(255, 215, 0, 0.4);
}
.hero h1 { font-size: 3em; margin-bottom: 12px; background: linear-gradient(90deg, #ffd700, #ff6b9d, #6c5ce7); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.tagline { font-size: 1.1em; margin-bottom: 24px; color: #ddd; }
.medal-info { background: rgba(255,255,255,0.05); padding: 20px; border-radius: 12px; margin-bottom: 24px; text-align: left; }
.medal-info h3 { margin-bottom: 12px; color: #ffd700; }
.medal-info ul { list-style: none; padding-left: 0; }
.medal-info li { margin-bottom: 8px; padding-left: 20px; position: relative; }
.medal-info li::before { content: "▸"; position: absolute; left: 0; color: #6c5ce7; }
.medals { display: flex; justify-content: space-around; margin-top: 16px; }
.medal { padding: 8px 16px; border-radius: 20px; font-weight: bold; }
.medal.bronze { background: #cd7f32; color: white; }
.medal.silver { background: #c0c0c0; color: #333; }
.medal.gold { background: #ffd700; color: #333; }

/* ===== PROFILE PAGE ===== */
.profile-page {
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}
.profile-page h1 {
  font-size: 1.6em;
  color: #ffd700;
  text-align: center;
  margin-bottom: 6px;
}
.profile-subtitle {
  text-align: center;
  color: #aaa;
  margin-bottom: 28px;
  font-size: 0.95em;
}
.profile-field {
  margin-bottom: 24px;
}
.profile-field label {
  display: block;
  font-size: 1em;
  color: #00d4ff;
  margin-bottom: 8px;
  font-weight: bold;
}
.profile-field input[type="text"] {
  width: 100%;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 10px;
  padding: 12px 16px;
  color: #fff;
  font-size: 1.1em;
  box-sizing: border-box;
}
.profile-field input[type="text"]:focus { outline: none; border-color: #00d4ff; }
.profile-interests-label {
  font-size: 1em;
  color: #00d4ff;
  font-weight: bold;
  margin-bottom: 10px;
}
.optional { color: #888; font-weight: normal; font-size: 0.85em; }
.interests-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.interest-option {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  font-size: 0.9em;
}
.interest-option:hover { background: rgba(0,212,255,0.1); border-color: #00d4ff; }
.interest-option input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; accent-color: #00d4ff; flex-shrink: 0; }
.interest-option span { line-height: 1.3; }
.profile-continue-btn { display: block; margin: 28px auto 0; }

/* ===== VIDEO PAGE ===== */
.video-page {
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}
.video-page h1 {
  font-size: 1.6em;
  color: #ffd700;
  margin-bottom: 6px;
  text-align: center;
}
.video-subtitle {
  text-align: center;
  color: #aaa;
  margin-bottom: 28px;
  font-size: 0.95em;
}
.video-group {
  margin-bottom: 32px;
}
.video-group-title {
  font-size: 1.1em;
  color: #00d4ff;
  border-bottom: 1px solid rgba(0,212,255,0.3);
  padding-bottom: 6px;
  margin-bottom: 14px;
}
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.video-card {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
.video-card iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border: none;
}
.video-continue-btn {
  display: block;
  margin: 32px auto 0;
  padding: 14px 40px;
  font-size: 1.1em;
}

/* ===== SAVE / CONTINUE ===== */
.save-section {
  margin-top: 20px;
  background: rgba(0, 212, 255, 0.08);
  border: 2px solid rgba(0, 212, 255, 0.35);
  border-radius: 14px;
  padding: 16px 20px;
  text-align: center;
}
.save-section p { color: #00d4ff; font-weight: bold; margin-bottom: 10px; }
.save-summary { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-bottom: 14px; }
.save-badge {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 16px;
  padding: 4px 12px;
  font-size: 0.9em;
}
.save-buttons { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.continue-btn { padding: 12px 28px; font-size: 1em; }
.new-game-btn {
  background: transparent;
  color: #aaa;
  border: 1px solid #555;
  padding: 6px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.8em;
}
.new-game-btn:hover { color: #ff6b6b; border-color: #ff6b6b; }

/* ===== MESSAGE COUNTER ===== */
.msg-counter {
  text-align: right;
  font-size: 0.8em;
  color: #aaa;
  margin-bottom: 8px;
  padding-right: 4px;
  transition: color 0.3s;
}
.msg-counter.low { color: #ffd700; font-weight: bold; }
.msg-counter.limit-reached {
  color: #ff6b6b;
  font-weight: bold;
  text-align: center;
  background: rgba(255, 107, 107, 0.1);
  border-radius: 8px;
  padding: 6px;
}

/* ===== EMAIL OPT-IN ===== */
.email-section {
  margin: 16px 0;
  background: rgba(0, 212, 255, 0.06);
  border: 1px solid rgba(0, 212, 255, 0.25);
  border-radius: 14px;
  padding: 18px 20px;
  text-align: center;
}
.email-prompt { color: #00d4ff; font-weight: bold; margin-bottom: 12px; }
.email-optin-btn {
  background: linear-gradient(135deg, #0090b0, #00d4ff);
  color: #fff;
  border: none;
  border-radius: 24px;
  padding: 10px 28px;
  font-size: 1em;
  cursor: pointer;
  font-weight: bold;
}
.email-optin-btn:hover { opacity: 0.85; }
.email-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
  text-align: left;
}
.email-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.9em;
  color: #ccc;
}
.email-form input {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 8px;
  padding: 8px 12px;
  color: #fff;
  font-size: 1em;
}
.email-form input:focus { outline: none; border-color: #00d4ff; }
.email-send-btn { margin-top: 4px; }
.email-status { margin-top: 6px; font-size: 0.9em; }
.email-status.success { color: #6dff91; }
.email-status.error   { color: #ff6b6b; }

/* ===== LANGUAGE TOGGLE ===== */
.lang-bar {
  width: 100%;
  max-width: 720px;
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}
.lang-btn {
  background: rgba(255,255,255,0.1);
  color: #ddd;
  border: 1px solid rgba(255,255,255,0.25);
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.85em;
  transition: background 0.2s;
}
.lang-btn:hover { background: rgba(255,255,255,0.2); }
.lang-btn.small { padding: 4px 10px; font-size: 0.8em; }

.big-btn {
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  color: white;
  border: none;
  padding: 16px 32px;
  font-size: 1.2em;
  border-radius: 30px;
  cursor: pointer;
  font-weight: bold;
  box-shadow: 0 4px 20px rgba(108, 92, 231, 0.6);
  transition: transform 0.2s;
}
.big-btn:hover { transform: scale(1.05); }

/* ===== MAZE HUB ===== */
.screen#screen-maze { justify-content: flex-start; padding: 12px 16px 20px; }

.maze-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
  max-width: 820px;
  margin-bottom: 10px;
}
.score-board { display: flex; gap: 8px; flex-wrap: wrap; }
.score-badge {
  padding: 5px 12px;
  border-radius: 20px;
  background: rgba(255,255,255,0.1);
  border: 2px solid rgba(255,255,255,0.2);
  font-size: 0.85em;
  font-weight: bold;
}
.score-badge.bronze { background: #cd7f32; color: white; border-color: #cd7f32; }
.score-badge.silver { background: #c0c0c0; color: #333; border-color: #c0c0c0; }
.score-badge.gold   { background: #ffd700; color: #333; border-color: #ffd700; }
.maze-final-btn { margin: 0; padding: 8px 18px; font-size: 0.95em; }

.maze-wrapper {
  position: relative;
  width: 100%;
  max-width: 820px;
}
#maze-canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
  border: 2px solid #3a5a78;
  box-shadow: 0 4px 30px rgba(0,0,0,0.5);
}
.maze-hint {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10,20,35,0.85);
  color: #ffd700;
  padding: 7px 18px;
  border-radius: 20px;
  font-size: 0.88em;
  pointer-events: none;
  white-space: nowrap;
  border: 1px solid #ffd700;
}

.maze-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
  max-width: 820px;
  margin-top: 10px;
}
.maze-legend {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.78em;
  color: #999;
}
.dpad {
  display: grid;
  grid-template-columns: repeat(3, 44px);
  grid-template-rows: repeat(3, 44px);
  gap: 4px;
}
.dpad-btn {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  border-radius: 8px;
  font-size: 1.1em;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  transition: background 0.1s;
}
.dpad-btn:active, .dpad-btn:hover { background: rgba(0,212,255,0.35); }
.dpad-up    { grid-column: 2; grid-row: 1; }
.dpad-left  { grid-column: 1; grid-row: 2; }
.dpad-enter { grid-column: 2; grid-row: 2; background: rgba(255,215,0,0.2); color: #ffd700; font-size: 0.9em; }
.dpad-right { grid-column: 3; grid-row: 2; }
.dpad-down  { grid-column: 2; grid-row: 3; }

/* Quiz overlay */
.maze-quiz-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5,15,28,0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.maze-quiz-box {
  background: #1a2a3d;
  border: 2px solid #ffd700;
  border-radius: 18px;
  padding: 28px 24px;
  max-width: 500px;
  width: 92%;
  box-shadow: 0 0 40px rgba(255,215,0,0.2);
}
.mq-caught  { color: #ffd700; font-weight: bold; text-align: center; font-size: 1.05em; margin-bottom: 14px; }
.mq-question { font-size: 1.05em; margin-bottom: 18px; line-height: 1.55; }
.mq-options { display: flex; flex-direction: column; gap: 10px; }
.mq-option {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.18);
  color: #f0f0f0;
  border-radius: 10px;
  padding: 11px 16px;
  cursor: pointer;
  text-align: left;
  font-size: 0.95em;
  transition: background 0.15s, border-color 0.15s;
}
.mq-option:hover:not(:disabled) { background: rgba(0,212,255,0.2); border-color: #00d4ff; }
.mq-option:disabled { opacity: 0.7; cursor: default; }
.mq-feedback { margin-top: 14px; text-align: center; font-weight: bold; font-size: 0.95em; min-height: 24px; }
.mq-feedback.correct { color: #50ee50; }
.mq-feedback.wrong   { color: #ff6464; }

#btn-final {
  display: block;
  margin: 24px auto 0;
  background: linear-gradient(135deg, #ffd700, #ff6b9d);
}

/* === Portrait wrapper – sizes exactly to the image so %-positions hit the right pixels === */
.portrait { position: relative; display: block; line-height: 0; }

/* === Portrait wrapper – sizes exactly to the image so %-positions hit the right pixels === */
.portrait { position: relative; display: block; line-height: 0; }
.portrait img { display: block; width: 100%; height: auto; }

/* === Blinking eye-lids: white block with green line on bottom (closed eye) === */
.eye-lid {
  position: absolute;
  background: #f5f3ef;
  border-bottom: 2px solid #3a6b2d;
  border-radius: 1px;
  opacity: 0;
  pointer-events: none;
}

/* Stagger the blinks per philosopher and per eye for natural feel */
.portrait[data-phil="platon"]   .eye-lid { animation: blink 5.2s infinite; }
.portrait[data-phil="platon"]   .eye-2   { animation-delay: 0.04s; }
.portrait[data-phil="sartre"]   .eye-lid { animation: blink 6.1s infinite; animation-delay: 1.2s; }
.portrait[data-phil="sartre"]   .eye-2   { animation-delay: 1.24s; }
.portrait[data-phil="beauvoir"] .eye-lid { animation: blink 4.7s infinite; animation-delay: 2.5s; }
.portrait[data-phil="beauvoir"] .eye-2   { animation-delay: 2.55s; }
.portrait[data-phil="kuhn"]     .eye-lid { animation: blink 5.8s infinite; animation-delay: 0.8s; }
.portrait[data-phil="kuhn"]     .eye-2   { animation-delay: 0.85s; }

@keyframes blink {
  0%, 86%, 100% { opacity: 0; }
  89%, 97%      { opacity: 1; }
}

/* Room screen portrait – natural height, no letterboxing */
.portrait-room {
  width: 160px;
  background: #fafafa;
  border-radius: 12px;
  border: 3px solid #ffd700;
  overflow: hidden;
  flex-shrink: 0;
  align-self: flex-start;
}
#btn-final {
  display: block;
  margin: 24px auto 0;
  background: linear-gradient(135deg, #ffd700, #ff6b9d);
}

/* ===== ROOM / CHAT ===== */
.room-frame {
  width: 100%;
  max-width: 1000px;
  background: rgba(0,0,0,0.5);
  border-radius: 20px;
  padding: 20px;
  border: 2px solid #6c5ce7;
}
.room-top { display: flex; flex-direction: column; gap: 16px; margin-bottom: 16px; }

.room-top-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.mode-lang-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}
.back-btn {
  background: transparent;
  color: #00d4ff;
  border: 2px solid #00d4ff;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
}
.back-btn:hover { background: #00d4ff; color: #000; }

/* Mode toggle button */
.mode-btn {
  padding: 6px 14px;
  border-radius: 20px;
  border: 2px solid;
  cursor: pointer;
  font-size: 0.85em;
  font-weight: bold;
  transition: background 0.2s, color 0.2s;
}
.mode-btn.examination {
  background: rgba(108, 92, 231, 0.25);
  border-color: #a29bfe;
  color: #a29bfe;
}
.mode-btn.examination:hover { background: rgba(108, 92, 231, 0.5); }
.mode-btn.discussion {
  background: rgba(0, 212, 100, 0.2);
  border-color: #00d464;
  color: #00d464;
}
.mode-btn.discussion:hover { background: rgba(0, 212, 100, 0.4); }
.room-philosopher-info { display: flex; gap: 16px; align-items: center; }
.room-philosopher-info h2 { color: #ffd700; }
.room-philosopher-info p { color: #ccc; font-size: 0.9em; }
.room-philosopher-info .topic { color: #fff; margin-top: 4px; }

.task-box {
  background: rgba(255, 215, 0, 0.1);
  border-left: 4px solid #ffd700;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.95em;
  white-space: pre-line;
  line-height: 1.6;
}

.chat-window {
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 16px;
  height: 360px;
  overflow-y: auto;
  margin-bottom: 12px;
}
.msg { margin-bottom: 12px; padding: 10px 14px; border-radius: 12px; max-width: 85%; line-height: 1.4; }
.msg.philosopher { background: rgba(108, 92, 231, 0.3); border-left: 3px solid #a29bfe; }
.msg.user { background: rgba(0, 212, 255, 0.2); border-right: 3px solid #00d4ff; margin-left: auto; text-align: right; }
.msg.system { background: rgba(255, 215, 0, 0.15); text-align: center; font-style: italic; font-size: 0.9em; }
.msg .who { font-size: 0.75em; color: #aaa; margin-bottom: 4px; }
.msg.typing { color: #aaa; font-style: italic; }

.chat-input-row { display: flex; gap: 8px; margin-bottom: 12px; }
#chat-input {
  flex: 1;
  padding: 12px;
  border-radius: 12px;
  border: 2px solid rgba(108, 92, 231, 0.5);
  background: rgba(0,0,0,0.3);
  color: white;
  font-size: 1em;
  font-family: inherit;
  resize: vertical;
}
#chat-input:focus { outline: none; border-color: #00d4ff; }
.send-btn {
  background: #00d4ff;
  color: #000;
  border: none;
  padding: 0 24px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: bold;
}
.send-btn:hover { background: #66e6ff; }
.send-btn:disabled, .eval-btn:disabled { opacity: 0.5; cursor: wait; }

.evaluation-row { display: flex; flex-direction: column; gap: 12px; }
.eval-btn {
  background: linear-gradient(135deg, #ffd700, #ff9500);
  color: #000;
  border: none;
  padding: 12px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: bold;
  font-size: 1em;
}
.eval-btn:hover { transform: scale(1.02); }
.eval-result {
  padding: 12px;
  border-radius: 8px;
  font-size: 0.95em;
}
.eval-result.bronze { background: rgba(205, 127, 50, 0.3); border: 2px solid #cd7f32; }
.eval-result.silver { background: rgba(192, 192, 192, 0.25); border: 2px solid #c0c0c0; }
.eval-result.gold { background: rgba(255, 215, 0, 0.3); border: 2px solid #ffd700; }
.eval-result.fail { background: rgba(255, 100, 100, 0.2); border: 2px solid #ff6464; }

.eval-email-section { margin-top: 14px; border-top: 1px solid rgba(255,255,255,0.15); padding-top: 12px; }
.eval-email-optin-btn { background: rgba(0,212,255,0.15); border: 1px solid #00d4ff; color: #00d4ff; border-radius: 8px; padding: 7px 14px; cursor: pointer; font-size: 0.88em; transition: background 0.2s; }
.eval-email-optin-btn:hover { background: rgba(0,212,255,0.3); }
.eval-email-form { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.eval-email-label { display: flex; flex-direction: column; font-size: 0.82em; color: #aaa; gap: 3px; }
.eval-email-label input { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); border-radius: 7px; padding: 7px 10px; color: #fff; font-size: 1em; }
.eval-email-label input:focus { outline: none; border-color: #00d4ff; }

/* ===== FINAL ===== */
.final-frame {
  max-width: 700px;
  text-align: center;
  background: rgba(0,0,0,0.5);
  padding: 40px;
  border-radius: 24px;
  border: 3px solid #ffd700;
  box-shadow: 0 0 60px rgba(255, 215, 0, 0.5);
}
.final-frame h1 { font-size: 2.5em; margin-bottom: 20px; color: #ffd700; }
.trophy { font-size: 6em; margin: 20px 0; }
#final-medal-text { font-size: 2em; margin-bottom: 12px; }
.final-breakdown { margin: 24px 0; text-align: left; background: rgba(255,255,255,0.05); padding: 16px; border-radius: 12px; }
.final-breakdown div { margin-bottom: 8px; }


/* ===== TIME TRAVEL OVERLAY ===== */
.overlay {
  position: fixed; inset: 0;
  background: #000;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
  z-index: 1000;
  overflow: hidden;
}
.vortex {
  width: 300px; height: 300px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #6c5ce7, #00d4ff, #ffd700, #ff6b9d, #6c5ce7);
  animation: spin 1.5s linear infinite;
  filter: blur(8px);
}
@keyframes spin { to { transform: rotate(360deg); } }
.travel-text {
  position: absolute;
  font-size: 2em;
  color: white;
  letter-spacing: 6px;
  font-weight: bold;
  text-shadow: 0 0 20px #00d4ff;
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 0.6; } 50% { opacity: 1; } }

@media (max-width: 600px) {
  .hero h1 { font-size: 2em; }
  .maze-topbar { gap: 6px; }
  .maze-legend { display: none; }
  .room-philosopher-info { flex-direction: column; text-align: center; }
}
