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

:root {
  --bg: #1a1a2e;
  --bg2: #16213e;
  --bg3: #0f3460;
  --accent: #e94560;
  --green: #4ecca3;
  --blue: #7ec8e3;
  --pink: #ff6b9d;
  --yellow: #f7d354;
  --text: #eee;
  --text2: #aaa;
  --bubble-self: #0a84ff;
  --bubble-other: #3a3a4a;
  --radius: 16px;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #0d0d1a;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(233,69,96,0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 50%, rgba(126,200,227,0.06) 0%, transparent 50%);
  color: var(--text);
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* PHONE FRAME */
.phone-frame {
  width: 100%;
  max-width: 480px;
  height: 100%;
  max-height: 100dvh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 60px rgba(0,0,0,0.5), 0 0 120px rgba(233,69,96,0.08);
}

@media (min-width: 540px) {
  .phone-frame {
    max-height: 98dvh;
    border-radius: 20px;
    border: 2px solid rgba(255,255,255,0.08);
  }
}

@media (max-width: 539px) {
  body {
    background: var(--bg);
  }
}

/* HEADER */
header {
  background: var(--bg2);
  padding: 16px 20px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
  z-index: 100;
}

@media (min-width: 540px) {
  header { border-radius: 28px 28px 0 0; }
}

.header-top {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  position: relative;
}


.game-title {
  font-size: 1.3em;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.day-counter {
  position: absolute;
  right: 0;
  font-size: 0.7em;
  color: #ffd740;
  font-weight: 600;
}

.gauges {
  display: flex;
  gap: 10px;
}

.gauge {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.gauge-label {
  font-size: 0.7em;
  display: flex;
  justify-content: space-between;
}

.gauge.gauge-ful .gauge-label { color: #d89eff; }
.gauge.gauge-trust .gauge-label { color: #5ec4ff; }

.gauge-bar {
  height: 14px;
  background: rgba(255,255,255,0.06);
  clip-path: polygon(0 80%, 100% 0, 100% 100%);
  position: relative;
}

.gauge-fill {
  height: 100%;
  transition: width 0.6s ease;
  position: relative;
}

.gauge-fill.green {
  background: linear-gradient(90deg, #b44dff, #e040fb 40%, #ff2a6d 70%, #ff1744);
}
.gauge-fill.blue {
  background: linear-gradient(90deg, #2979ff, #00b0ff 40%, #00e5ff 70%, #1de9b6);
}

.gauge-fill.low { animation: pulse-low 1s ease-in-out infinite; }
@keyframes pulse-low { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* MAIN CONTENT */
main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tab-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: none;
  scroll-behavior: smooth;
}

.tab-content.active { display: flex; flex-direction: column; }

/* PHONE TAB */
#tab-phone .conversation-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.convo-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg2);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s;
}

.convo-item:hover { background: var(--bg3); }
.convo-item.active { background: var(--bg3); border: 1px solid var(--accent); }
.convo-item.unread { border-left: 3px solid var(--accent); }
.convo-item.ended { opacity: 0.6; }
.convo-item.ended:hover { opacity: 0.8; }

.convo-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5em;
  flex-shrink: 0;
}

.convo-info { flex: 1; min-width: 0; }
.convo-name { font-weight: 600; font-size: 0.95em; }
.convo-preview { font-size: 0.8em; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convo-badge { background: var(--accent); color: white; border-radius: 10px; padding: 2px 8px; font-size: 0.75em; font-weight: 600; }

#tab-phone.chat-open {
  overflow: hidden;
  padding: 0;
  min-height: 0;
}

.chat-view {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}

.chat-view.active { display: flex; }

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
  background: var(--bg2);
}

.chat-back {
  background: none;
  border: none;
  color: var(--blue);
  font-size: 1.2em;
  cursor: pointer;
  padding: 4px 8px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  min-height: 0;
}

.message {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 0.9em;
  line-height: 1.4;
  animation: msg-in 0.3s ease;
}

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

.message.self {
  align-self: flex-end;
  background: var(--bubble-self);
  border-bottom-right-radius: 4px;
}

.message.other {
  align-self: flex-start;
  background: var(--bubble-other);
  border-bottom-left-radius: 4px;
}

.message.system {
  align-self: center;
  background: rgba(255,255,255,0.05);
  color: var(--text2);
  font-size: 0.8em;
  font-style: italic;
  border-radius: 12px;
}

.chat-day-separator {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
}

.chat-day-separator::before,
.chat-day-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,0.1);
}

.chat-day-separator span {
  font-size: 0.65em;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 1px;
  white-space: nowrap;
}

.chat-footer {
  flex-shrink: 0;
  background: var(--bg2);
  border-top: 1px solid rgba(255,255,255,0.1);
}

.chat-responses {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 16px 0;
}

.chat-responses:empty { display: none; }

.chat-night-bar {
  padding: 12px 16px;
  display: flex;
  gap: 8px;
}

.chat-night-bar .night-btn { flex: 1; font-size: 0.9em; padding: 10px 8px; }
.chat-night-bar .night-btn.alone { background: var(--bg3); }
.chat-night-bar .night-btn.alone:hover { background: var(--bg3); box-shadow: 0 2px 10px rgba(255,255,255,0.1); }

.response-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 20px;
  font-size: 0.85em;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.response-btn:hover { background: var(--bubble-self); border-color: var(--bubble-self); }

/* Response type colors */
.response-btn.reassuring { border-color: rgba(78,204,163,0.5); background: rgba(78,204,163,0.1); }
.response-btn.reassuring:hover { background: rgba(78,204,163,0.3); }
.response-btn.honest { border-color: rgba(126,200,227,0.5); background: rgba(126,200,227,0.1); }
.response-btn.honest:hover { background: rgba(126,200,227,0.3); }
.response-btn.evasive { border-color: rgba(247,211,84,0.5); background: rgba(247,211,84,0.1); }
.response-btn.evasive:hover { background: rgba(247,211,84,0.3); }
.response-btn.enthusiastic { border-color: rgba(78,204,163,0.5); background: rgba(78,204,163,0.1); }
.response-btn.enthusiastic:hover { background: rgba(78,204,163,0.3); }
.response-btn.cautious { border-color: rgba(126,200,227,0.5); background: rgba(126,200,227,0.1); }
.response-btn.cautious:hover { background: rgba(126,200,227,0.3); }
.response-btn.flirty { border-color: rgba(255,107,157,0.5); background: rgba(255,107,157,0.1); }
.response-btn.flirty:hover { background: rgba(255,107,157,0.3); }

.response-btn.special {
  background: linear-gradient(135deg, rgba(233,69,96,0.2), rgba(255,107,157,0.2));
  border-color: var(--accent);
  font-weight: 600;
}
.response-btn.special:hover { background: var(--accent); }

.response-btn.dimmed {
  opacity: 0.3;
  pointer-events: none;
}

/* SITE TAB */
.lovers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.lover-card {
  background: var(--bg2);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
  position: relative;
}

.lover-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.lover-card.contacted { border-color: var(--blue); }
.lover-card.active-relation { border-color: var(--green); }
.lover-card.unavailable { opacity: 0.4; pointer-events: none; }

.lover-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.lover-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6em;
}

.lover-name { font-weight: 700; font-size: 1em; }
.lover-age { color: var(--text2); font-size: 0.85em; }
.lover-trait { display: inline-block; background: var(--accent); color: white; padding: 2px 8px; border-radius: 10px; font-size: 0.7em; margin-top: 2px; }
.lover-desc { font-size: 0.82em; color: var(--text2); margin-top: 8px; line-height: 1.4; }

.lover-status {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 0.7em;
  padding: 2px 8px;
  border-radius: 8px;
  font-weight: 600;
}

.lover-status.available { background: rgba(78,204,163,0.2); color: var(--green); }
.lover-status.contacted { background: rgba(126,200,227,0.2); color: var(--blue); }
.lover-status.ongoing { background: rgba(255,107,157,0.2); color: var(--pink); }
.lover-status.ended { background: rgba(255,255,255,0.1); color: var(--text2); }

.lover-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

.lover-btn {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: 12px;
  font-size: 0.8em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.lover-btn.contact { background: var(--accent); color: white; }
.lover-btn.contact:hover { background: #d63050; }
.lover-btn.meet { background: var(--green); color: var(--bg); }
.lover-btn.meet:hover { background: #3db88f; }

/* AGENDA TAB */
.agenda-week {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.agenda-day {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg2);
  border-radius: var(--radius);
  transition: all 0.2s;
}

.agenda-day.today { border: 2px solid var(--yellow); background: rgba(247,211,84,0.08); }
.agenda-day.past { opacity: 0.5; }

.agenda-day-label {
  width: 60px;
  font-weight: 700;
  font-size: 0.9em;
  flex-shrink: 0;
}

.agenda-day-label small { display: block; font-weight: 400; color: var(--text2); font-size: 0.8em; }

.agenda-plan {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.agenda-plan-text { font-size: 0.85em; color: var(--text2); }
.agenda-plan-text.planned { color: var(--text); font-weight: 500; }

.agenda-select {
  background: var(--bg3);
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.8em;
  cursor: pointer;
}

.agenda-select option { background: var(--bg2); }

/* DASHBOARD TAB */
.dashboard {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dash-section {
  background: var(--bg2);
  border-radius: var(--radius);
  padding: 16px;
}

.dash-title {
  font-weight: 700;
  font-size: 0.95em;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.stat-card {
  background: rgba(255,255,255,0.05);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}

.stat-value { font-size: 1.8em; font-weight: 700; }
.stat-label { font-size: 0.75em; color: var(--text2); margin-top: 4px; }

.relation-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.relation-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: rgba(255,255,255,0.03);
  border-radius: 10px;
}

.relation-meetings { font-size: 0.8em; color: var(--text2); margin-left: auto; }

/* BOTTOM TAB BAR */
.tab-bar {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  background: var(--bg2);
  border-top: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
  z-index: 100;
}

@media (min-width: 540px) {
  .tab-bar { border-radius: 0 0 28px 28px; }
}

.tab-btn {
  flex: 1;
  padding: 8px 6px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  color: var(--text2);
  font-size: 0.82em;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s;
}

.tab-btn .tab-icon { display: flex; align-items: center; }
.tab-btn .tab-icon svg { width: 1.3em; height: 1.3em; }
.tab-btn.active { color: var(--accent); background: rgba(233,69,96,0.12); border-color: rgba(233,69,96,0.3); }
.tab-btn:hover { background: rgba(255,255,255,0.1); color: var(--text); }

/* ACTION BAR */
.action-bar {
  padding: 12px 16px;
  background: var(--bg2);
  border-top: 1px solid rgba(255,255,255,0.1);
}

.night-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 14px;
  font-size: 1em;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), #ff6b9d);
  color: white;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.night-btn:hover { transform: scale(1.02); box-shadow: 0 4px 20px rgba(233,69,96,0.4); }
.night-btn:active { transform: scale(0.98); }
.night-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.night-btn .btn-sub {
  display: block;
  font-size: 0.75em;
  font-weight: 400;
  opacity: 0.8;
  margin-top: 3px;
}

/* EVENT POPUP */
.event-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  border-radius: inherit;
}

.event-overlay.show { opacity: 1; pointer-events: all; }

.event-popup {
  background: var(--bg2);
  border-radius: 20px;
  padding: 28px 24px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  transform: scale(0.9);
  transition: transform 0.3s;
  border: 1px solid rgba(255,255,255,0.1);
}

.event-overlay.show .event-popup { transform: scale(1); }

.event-period {
  font-size: 0.65em;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 10px;
  opacity: 0.5;
}

html[lang="fr"] .event-overlay[data-period="night"] .event-period::before {
  content: '🌙 nuit';
}
html[lang="fr"] .event-overlay[data-period="morning"] .event-period::before {
  content: '☀️ matin';
}
html[lang="en"] .event-overlay[data-period="night"] .event-period::before {
  content: '🌙 night';
}
html[lang="en"] .event-overlay[data-period="morning"] .event-period::before {
  content: '☀️ morning';
}

/* LANGUAGE TOGGLE */
.lang-toggle {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  gap: 6px;
  z-index: 10;
}
.lang-toggle button {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  font-size: 1.4em;
  padding: 4px 8px;
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1;
}
.lang-toggle button:hover {
  background: rgba(255,255,255,0.15);
  transform: scale(1.1);
}

.event-emoji { font-size: 3em; margin-bottom: 12px; }
.event-title { font-size: 1.1em; font-weight: 700; margin-bottom: 10px; }
.event-text { font-size: 0.9em; color: var(--text2); line-height: 1.5; margin-bottom: 20px; }

.event-close {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 32px;
  border-radius: 12px;
  font-size: 0.9em;
  font-weight: 600;
  cursor: pointer;
}

/* SPLASH SCREEN */
#splash-screen {
  position: absolute;
  inset: 0;
  background: var(--bg);
  z-index: 2500;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  border-radius: inherit;
}
#splash-sprite {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  width: 160px;
  height: 160px;
}
.splash-bar {
  width: 160px;
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  overflow: hidden;
}
.splash-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--pink));
  border-radius: 2px;
  transition: width 0.12s linear;
}

/* INTRO SCREEN */
#intro-screen {
  position: absolute;
  inset: 0;
  background: var(--bg);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  border-radius: inherit;
}

.intro-container {
  max-width: 500px;
  width: 100%;
}

.intro-deer {
  font-size: 5em;
  text-align: center;
  line-height: 1;
  margin-bottom: 8px;
  color: transparent;
  text-shadow: 0 0 0 var(--accent);
}

.intro-title {
  font-size: 2em;
  font-weight: 800;
  text-align: center;
  margin-bottom: 24px;
  background: linear-gradient(135deg, var(--accent), var(--pink), var(--yellow));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.intro-chat {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 55vh;
  overflow-y: auto;
  padding: 16px;
  background: var(--bg2);
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.intro-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 0.9em;
  line-height: 1.4;
  display: none;
}

.intro-msg.visible { display: block; animation: introFadeIn 0.4s ease forwards; }
@keyframes introFadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.intro-msg.wife { align-self: flex-end; background: var(--bubble-self); border-bottom-right-radius: 4px; }
.intro-msg.husband { align-self: flex-start; background: var(--bubble-other); border-bottom-left-radius: 4px; }

.intro-buttons {
  display: flex;
  gap: 10px;
}

.intro-next-btn {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: 14px;
  font-size: 1em;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--pink));
  color: white;
  transition: all 0.2s;
}

.intro-next-btn:hover { transform: scale(1.02); }

.intro-skip-btn {
  padding: 14px 20px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 14px;
  font-size: 0.85em;
  font-weight: 500;
  cursor: pointer;
  background: rgba(255,255,255,0.05);
  color: var(--text2);
  transition: all 0.2s;
}

.intro-skip-btn:hover { background: rgba(255,255,255,0.1); color: var(--text); }

/* END SCREEN */
#end-screen {
  position: absolute;
  inset: 0;
  background: var(--bg);
  z-index: 2000;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
  border-radius: inherit;
}

#end-screen.show { display: flex; }

.end-container {
  max-width: 500px;
  width: 100%;
  text-align: center;
}

.end-title { font-size: 1.8em; font-weight: 800; margin-bottom: 16px; }
.end-text { font-size: 0.95em; line-height: 1.6; color: var(--text2); margin-bottom: 24px; }

.end-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 24px;
}

.end-stat {
  background: var(--bg2);
  padding: 14px;
  border-radius: 14px;
}

.end-stat-val { font-size: 1.5em; font-weight: 700; }
.end-stat-label { font-size: 0.75em; color: var(--text2); margin-top: 4px; }

.replay-btn {
  padding: 14px 40px;
  border: none;
  border-radius: 14px;
  font-size: 1em;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--pink));
  color: white;
}

/* NIGHT SUMMARY */
.night-summary {
  background: var(--bg2);
  border-radius: var(--radius);
  padding: 16px;
  margin: 10px 0;
  border-left: 3px solid var(--accent);
}

.night-summary h3 { font-size: 0.95em; margin-bottom: 8px; }
.night-summary p { font-size: 0.85em; color: var(--text2); line-height: 1.4; }

/* TOAST */
.toast {
  position: absolute;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg3);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 0.85em;
  opacity: 0;
  transition: all 0.3s;
  z-index: 500;
  border: 1px solid rgba(255,255,255,0.15);
  white-space: nowrap;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* SCROLLBAR */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }
