* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  background: #000;
  overflow: hidden;
  font-family: 'Trebuchet MS', 'Segoe UI', sans-serif;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

#game-container {
  position: relative;
  width: 1280px;
  height: 720px;
  background: #000;
  overflow: hidden;
  transform-origin: center center;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#ui-root {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hidden {
  display: none !important;
}

/* ---------- Generic screens (title / chapter select) ---------- */

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  background: #1c130c;
  color: #fdf6ec;
  text-align: center;
  overflow: hidden;
}

.screen-backdrop {
  position: absolute;
  inset: -20px;
  background-image: url("images/backgroundPI2.png");
  background-size: cover;
  background-position: center;
  filter: blur(14px) brightness(0.35) saturate(1.1);
  transform: scale(1.1);
  z-index: 0;
}

.screen::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(74, 51, 32, 0.35) 0%, rgba(20, 14, 9, 0.9) 100%);
  z-index: 1;
}

/* Lucioles flottantes décoratives */
.fireflies {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.fireflies span {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ffd98e;
  box-shadow: 0 0 8px 2px rgba(255, 217, 142, 0.8);
  opacity: 0;
  animation: firefly-float 9s ease-in-out infinite;
}

.fireflies span:nth-child(1) { left: 12%; top: 70%; animation-delay: 0s; animation-duration: 8s; }
.fireflies span:nth-child(2) { left: 22%; top: 30%; animation-delay: 1.2s; animation-duration: 10s; }
.fireflies span:nth-child(3) { left: 35%; top: 80%; animation-delay: 2.4s; animation-duration: 9s; }
.fireflies span:nth-child(4) { left: 50%; top: 20%; animation-delay: 3.6s; animation-duration: 11s; }
.fireflies span:nth-child(5) { left: 65%; top: 75%; animation-delay: 0.8s; animation-duration: 9.5s; }
.fireflies span:nth-child(6) { left: 78%; top: 35%; animation-delay: 2s; animation-duration: 8.5s; }
.fireflies span:nth-child(7) { left: 88%; top: 65%; animation-delay: 4s; animation-duration: 10.5s; }
.fireflies span:nth-child(8) { left: 45%; top: 50%; animation-delay: 5s; animation-duration: 9s; }

@keyframes firefly-float {
  0% { opacity: 0; transform: translate(0, 0) scale(0.8); }
  10% { opacity: 1; }
  50% { transform: translate(24px, -36px) scale(1.2); }
  90% { opacity: 1; }
  100% { opacity: 0; transform: translate(-18px, -70px) scale(0.8); }
}

.title-content,
.chapter-select-title,
#chapter-list {
  position: relative;
  z-index: 2;
}

.title-content {
  display: flex;
  flex-direction: column;
  align-items: center;
}

#title-logo {
  max-width: 420px;
  width: 60%;
  margin-bottom: 18px;
  filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.6));
  opacity: 0;
  animation: logo-in 0.9s ease forwards, logo-float 4s ease-in-out 0.9s infinite;
}

@keyframes logo-in {
  from { opacity: 0; transform: translateY(-30px) scale(0.92); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes logo-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

#title-tagline {
  margin: 0 0 32px;
  font-size: 1.05rem;
  font-style: italic;
  letter-spacing: 1px;
  color: #d8c9b8;
  opacity: 0;
  animation: fade-in 0.8s ease 0.5s forwards;
}

#play-button {
  opacity: 0;
  animation: fade-in 0.8s ease 0.8s forwards;
}

@keyframes fade-in {
  to { opacity: 1; }
}

.primary-button {
  font-family: inherit;
  font-size: 1.3rem;
  font-weight: bold;
  color: #2b1d12;
  background: linear-gradient(180deg, #ffd98e 0%, #e8a857 100%);
  border: none;
  border-radius: 999px;
  padding: 14px 48px;
  cursor: pointer;
  box-shadow: 0 6px 0 #a9742f, 0 10px 20px rgba(0, 0, 0, 0.4);
  transition: transform 0.1s ease;
}

.primary-button:hover {
  transform: translateY(-2px);
}

.primary-button:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 #a9742f, 0 6px 14px rgba(0, 0, 0, 0.4);
}

.primary-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.chapter-select-title {
  margin: 0 0 24px;
  font-size: 1.8rem;
  letter-spacing: 2px;
  color: #ffd98e;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

#chapter-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 460px;
}

.chapter-select-quote {
  position: relative;
  z-index: 2;
  margin: 28px 0 0;
  font-size: 0.65rem;
  font-weight: 400;
  font-style: italic;
  letter-spacing: 0.5px;
  color: rgba(253, 246, 236, 0.25);
  text-align: center;
  max-width: 460px;
}

.chapter-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid rgba(255, 217, 142, 0.35);
  cursor: pointer;
  text-align: left;
  color: #fdf6ec;
  font-family: inherit;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  overflow: hidden;
}

.chapter-item.strikethrough::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    -45deg,
    rgba(255, 217, 142, 0.18) 0px,
    rgba(255, 217, 142, 0.18) 10px,
    transparent 10px,
    transparent 22px
  );
  pointer-events: none;
}

.chapter-item:hover:not(.locked) {
  background: rgba(255, 217, 142, 0.12);
  border-color: #ffd98e;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.chapter-number {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: bold;
  color: #2b1d12;
  background: linear-gradient(180deg, #ffd98e 0%, #e8a857 100%);
}

.chapter-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chapter-item .chapter-title {
  font-size: 1.2rem;
  font-weight: bold;
}

.chapter-item .chapter-subtitle {
  font-size: 0.85rem;
  opacity: 0.75;
}


.chapter-status {
  flex-shrink: 0;
  width: 28px;
  font-size: 1.3rem;
  text-align: center;
}

.chapter-item.locked {
  opacity: 0.6;
  cursor: not-allowed;
}

.chapter-item.locked .chapter-number {
  background: rgba(255, 255, 255, 0.1);
  color: #c9b8a4;
}

/* ---------- HUD notification (phone) ---------- */

#hud-notification {
  position: absolute;
  top: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 14, 9, 0.85);
  border: 1px solid #ffd98e;
  border-radius: 16px;
  font-size: 1.7rem;
  cursor: pointer;
  pointer-events: auto;
  animation: notif-in 0.4s ease;
}

@keyframes notif-in {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.hud-notification-dot {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #e63946;
  border: 2px solid #1c130c;
  animation: notif-pulse 1.2s infinite;
}

@keyframes notif-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.6; }
}

/* ---------- Dialogue box ---------- */

#dialogue-box {
  position: absolute;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  width: 90%;
  max-width: 1100px;
  display: flex;
  gap: 18px;
  align-items: center;
  background: rgba(20, 14, 9, 0.92);
  border: 2px solid #caa46b;
  border-radius: 16px;
  padding: 20px 28px;
  pointer-events: auto;
  cursor: pointer;
}

#dialogue-portrait {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 2px solid #ffd98e;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}

#dialogue-content {
  flex: 1;
  min-height: 64px;
}

#dialogue-name {
  font-weight: bold;
  color: #ffd98e;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 0.85rem;
  margin-bottom: 6px;
}

#dialogue-text {
  color: #fdf6ec;
  font-size: 1.15rem;
  line-height: 1.5;
  white-space: pre-line;
}

#dialogue-box.thought #dialogue-text {
  font-style: italic;
  color: #d8c9b8;
}

#dialogue-box.thought #dialogue-name {
  color: #c9b8a4;
}

#dialogue-continue {
  position: absolute;
  bottom: 8px;
  right: 18px;
  color: #ffd98e;
  animation: bounce 1s infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(4px); }
}

/* ---------- Phone overlay ---------- */

#phone-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  pointer-events: auto;
}

#phone-frame {
  position: relative;
  width: 360px;
  height: 640px;
  background: #111;
  border: 10px solid #1c1c1e;
  border-radius: 40px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

/* ---------- Écrans du téléphone (accueil / Messages / Photos) ---------- */

.phone-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
}

/* ---------- Écran d'accueil ---------- */

#phone-home {
  background: linear-gradient(160deg, #4a3320 0%, #1c130c 100%);
  color: #fdf6ec;
}

.phone-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px 0;
  font-size: 0.85rem;
  font-weight: 600;
}

.phone-status-icons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.phone-icon-signal,
.phone-icon-battery {
  display: inline-block;
  border: 1.5px solid #fdf6ec;
  border-radius: 2px;
}

.phone-icon-signal {
  width: 16px;
  height: 10px;
  background: linear-gradient(to right, #fdf6ec 0 70%, transparent 70% 100%);
}

.phone-icon-battery {
  position: relative;
  width: 22px;
  height: 11px;
  background: linear-gradient(to right, #fdf6ec 0 75%, transparent 75% 100%);
}

.phone-icon-battery::after {
  content: "";
  position: absolute;
  top: 3px;
  right: -4px;
  width: 2px;
  height: 5px;
  background: #fdf6ec;
  border-radius: 0 2px 2px 0;
}

.phone-app-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: min-content;
  gap: 28px 16px;
  padding: 36px 24px;
}

.phone-app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: none;
  background: none;
  font-family: inherit;
  color: #fdf6ec;
  cursor: pointer;
}

.phone-app-icon {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}

.phone-app-icon--messages {
  background: linear-gradient(160deg, #6cdf6c, #2fb344);
}

.phone-app-icon--photos {
  background: linear-gradient(135deg, #ff9500, #ff2d55, #af52de, #5856d6);
}

.phone-app-label {
  font-size: 0.78rem;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.phone-app-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #e63946;
  border: 2px solid #2b1d12;
}

.phone-home-indicator {
  width: 120px;
  height: 5px;
  margin: 0 auto 10px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.4);
}

/* ---------- En-tête commun aux applications (Messages / Photos) ---------- */

.phone-app-header {
  background: #f2f2f7;
  color: #1c1c1e;
  padding: 16px 14px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: 1rem;
  border-bottom: 1px solid #d6d6db;
}

.phone-app-back {
  font-size: 1.4rem;
  font-weight: bold;
  color: #007aff;
  cursor: pointer;
  width: 24px;
}

.phone-app-back--hint {
  animation: back-button-wiggle 1.2s ease-in-out infinite;
  transform-origin: center;
}

@keyframes back-button-wiggle {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(2px); }
  60% { transform: translateX(-2px); }
  80% { transform: translateX(3px); }
}

.phone-app-header-spacer {
  width: 24px;
}

/* ---------- Application Photos ---------- */

#phone-photos-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: #8e8e93;
  font-size: 0.95rem;
  text-align: center;
}

/* ---------- Application Messages ---------- */

#phone-messages {
  flex: 1;
  background: #fff;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 0.92rem;
  line-height: 1.4;
  white-space: pre-line;
}

.message-bubble.received {
  background: #e9e9eb;
  color: #1c1c1e;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.message-bubble.sent {
  background: #0b93f6;
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.message-thought {
  align-self: center;
  max-width: 85%;
  padding: 6px 14px;
  border-radius: 12px;
  background: rgba(60, 60, 67, 0.08);
  color: #8e8e93;
  font-size: 0.8rem;
  font-style: italic;
  text-align: center;
  white-space: pre-line;
}

#phone-actions {
  padding: 14px;
  background: #f2f2f7;
  border-top: 1px solid #d6d6db;
  display: flex;
  justify-content: center;
  gap: 12px;
}

#phone-actions .primary-button {
  font-size: 0.95rem;
  padding: 10px 26px;
}

.phone-choice-button--secondary {
  background: transparent;
  color: #6b6b70;
  border: 1.5px solid #c7c7cc;
  box-shadow: none;
}

.phone-choice-button--secondary:active {
  box-shadow: none;
  transform: translateY(1px);
}

/* ---------- Bulle de dialogue flottante ---------- */

#speech-bubble {
  position: absolute;
  transform: translate(-50%, -100%);
  max-width: 220px;
  padding: 10px 16px;
  background: #fdf6ec;
  color: #2b1d12;
  border: 2px solid #2b1d12;
  border-radius: 16px;
  font-size: 0.95rem;
  text-align: center;
  pointer-events: none;
}

#speech-bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -10px;
  transform: translateX(-50%);
  border-width: 10px 8px 0 8px;
  border-style: solid;
  border-color: #2b1d12 transparent transparent transparent;
}

#speech-bubble::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -7px;
  transform: translateX(-50%);
  border-width: 8px 6px 0 6px;
  border-style: solid;
  border-color: #fdf6ec transparent transparent transparent;
  z-index: 1;
}

/* ---------- Transitions ---------- */

#dim-overlay {
  position: absolute;
  inset: 0;
  background: #0a0806;
  opacity: 0;
  pointer-events: none;
}

#text-card {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 80px;
  color: #fdf6ec;
  font-size: 2rem;
  text-align: center;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
  opacity: 0;
  pointer-events: none;
}

#fade-overlay {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
}
