/***********************************************/
/** 1. VARIABLES **/
/***********************************************/
:root {
  --primary-color: #29d7b8;
  --secondary-color: #1e1e52;
  --dark-bg: #0f0f23;
  --overlay-bg: rgba(44, 62, 80, 0.95);
  --text-light: #ecf0f1;
  --hover-color: #2e2e72;
  --danger-color: #c0392b;
  --accent-color: #03A9F4;
}

/***********************************************/
/** 2. RESET & BASE STYLES **/
/***********************************************/
html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Arial', sans-serif;
  /* overflow: hidden; */
  overflow-y: auto;

  /* Force on iOS to fill available space */
  min-height: -webkit-fill-available;
}

h1 {
  font-size: 2rem;
  color: var(--primary-color);
}

/***********************************************/
/** 3. LAYOUT & CONTAINERS **/
/***********************************************/

/* App container */
#app {
  height: 100vh;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: var(--dark-bg);
}

/* Page container */
.page-container {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  background: var(--overlay-bg);
  backdrop-filter: blur(10px);
  color: var(--text-light);
  display: flex;
  flex-direction: column;
  align-items: center;
  box-sizing: border-box;
  justify-content: center;
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  min-height: -webkit-fill-available;

  /* Reserve space at the bottom for iPhone’s safe area */
  padding-bottom: env(safe-area-inset-bottom);
}


/* Image Container */
#imageContainer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center; /* Centers vertically */
  align-items: center;     /* Centers horizontally */
  z-index: 1;
}

#imageContainer p {
  margin: 5px 0;
  color: #fff;
  font-size: 1.2rem;
  text-align: center;
}

#imageContainer img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  animation: fadeInOut 15s linear infinite;
  z-index: 0; /* Ensure images stay in the background */
}

/* Welcome content layout */
.welcome-content {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 10;
  /* text-align: right; */
  text-align: center;
  padding: 20px;
}

/* Common container for game selection */
.game-selection-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 20px;
}

/* Chat UI containers */
.game-chat-ui-a,
.game-chat-ui-b {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  overflow: hidden;
}

.game-chat-ui-a::before,
.game-chat-ui-b::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1;
}

.chat-container {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100vh;
  z-index: 2;
  padding-top: 60px;
  box-sizing: border-box;
}

/***********************************************/
/** 4. COMPONENTS (Buttons, Boxes, Etc.) **/
/***********************************************/

/* Base button */
button {
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  background-color: var(--secondary-color);
  color: var(--primary-color);
  font-size: 1rem;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

button:hover {
  background-color: var(--hover-color);
}

/* Nudge button */
.nudge-button {
  position: fixed;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background-color: var(--accent-color);
  color: #fff;
  border: none;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Select game button */
.select-game-button {
  left: 20px;
  width: 130px;
  height: 40px;
  border: none;
  border-radius: 5px;
  background-color: var(--secondary-color);
  color: var(--primary-color);
  font-size: 1rem;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.select-game-button:hover {
  background-color: var(--hover-color);
}

/* Finish game button */
.finish-game-button {
  position: absolute;
  left: 20px;
  bottom: 0;
  width: 130px;
  height: 40px;
  background-color: #d89b94;
  color: #fff;
  padding: 0;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.finish-game-button:hover {
  background-color: var(--danger-color); /* Darker shade on hover */
}

/* Game box */
.game-box {
  z-index: 10;
  width: 250px;
  padding: 20px;
  border: 3px solid #ccc;
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.3s ease;
  text-shadow:
    2px 2px 4px rgba(0, 0, 0, 0.5),
    0 0 20px rgba(41, 215, 184, 0.3),
    -1px -1px 0 rgba(0, 0, 0, 0.3);
}

.game-box:hover {
  transform: scale(1.05);
}

/***********************************************/
/** 5. MODALS, OVERLAYS, AND SPECIAL BOXES **/
/***********************************************/

/* Game intro modal */
.game-intro-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.modal-content {
  background: #000;
  padding: 20px;
  border-radius: 10px;
  text-align: center;
  max-width: 500px;
}

/* Game intro container & boxes */
.game-intro-container {
  text-align: center;
  padding: 20px;
  color: #fff;
}

.game-intro-box {
  background: rgba(28, 40, 51, 0.8);
  margin: 10px 0;
  padding: 15px;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.3s ease;
}

.game-intro-box:hover {
  transform: scale(1.05);
}

.game-intro-box h2 {
  color: var(--primary-color);
  margin-bottom: 10px;
}

.game-intro-box p {
  color: var(--text-light);
  font-size: 1rem;
}

/* Overlay content (variation 2) */
.overlay-content-2 {
  margin: 20px;
  max-width: 800px;
  position: relative;
  background: #fff;
  color: #000;
  padding: 20px;
  border-radius: 10px;
  text-align: left;
  padding-top: 40px;
}

.overlay-content-2 button {
  position: absolute;
  top: 10px;
  right: 10px;
  border-color: rgba(255, 255, 255, 0.1);
}

/* Evaluation overlay */
.evaluation-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 20;
  padding: 20px;
}

.overlay-content {
  position: relative;
  background: linear-gradient(to bottom,
      rgba(50, 50, 50, 0.9),
      rgba(30, 30, 30, 0.9));
  color: #fff;
  padding: 40px 20px 20px;
  border-radius: 10px;
  text-align: left;
  max-height: 85vh;
  max-width: 800px;
  overflow-y: auto;
}

.overlay-content button {
  position: absolute;
  top: 10px;
  right: 10px;
}

/***********************************************/
/** 6. CHAT & MESSAGING **/
/***********************************************/

/* Scores and evaluation bar (top of the chat) */
.player-scores-and-evaluation {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 12px 20px;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.95), rgba(30, 30, 82, 0.95));
  color: #fff;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  align-items: center;
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(41, 215, 184, 0.2);
  box-shadow: 0 2px 15px rgba(0, 0, 0, 0.3);
}

.score-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(41, 215, 184, 0.1);
  transition: all 0.3s ease;
}

.score-item:hover {
  background: rgba(41, 215, 184, 0.15);
  transform: translateY(-1px);
}

.score-label {
  font-size: 14px;
  opacity: 0.8;
  font-weight: 500;
}

.score-value {
  font-size: 16px;
  font-weight: bold;
  color: var(--primary-color);
}

/* Risk indicator */
.risk-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 8px;
  transition: all 0.3s ease;
}

.risk-indicator.low {
  background: rgba(39, 174, 96, 0.2);
  color: #2ecc71;
}

.risk-indicator.medium {
  background: rgba(241, 196, 15, 0.2);
  color: #f1c40f;
}

.risk-indicator.high {
  background: rgba(231, 76, 60, 0.2);
  color: #e74c3c;
}

/* Conversation history */
.conversation-history {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  padding-bottom: 120px;
  scrollbar-width: thin;
  scrollbar-color: rgba(155, 155, 155, 0.5) transparent;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
}

.message {
  display: flex;
  align-items: flex-start;
  margin-bottom: 15px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 12px;
}

.avatar-icon {
  width: 75px;
  height: 75px;
  border-radius: 50%;
  margin-right: 12px;
  object-fit: cover;
}

.message-content {
  color: #fff;
  font-size: 22px;
  line-height: 1.4;
  text-shadow: 
    2px 2px 4px rgba(0, 0, 0, 0.5), 
    -1px -1px 2px rgba(255, 255, 255, 0.3);
  padding-bottom: 8px;
}

/* Message input container */
.message-input-container {
  position: fixed;
  left: 0;
  right: 0;
  bottom: env(safe-area-inset-bottom);
  padding: 15px;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 60px;
  z-index: 3;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.message-input-container input[type="text"] {
  flex: 1;
  height: 44px;
  padding: 8px 15px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 16px;
}

.message-input-container button {
  padding: 10px 24px;
  height: 44px;
  border-radius: 22px;
  background: linear-gradient(45deg, var(--secondary-color), var(--primary-color));
  color: #fff;
  border: none;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 0 15px rgba(41, 215, 184, 0.3);
  transition: all 0.3s ease;
}

.message-input-container button:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 25px rgba(41, 215, 184, 0.5);
  background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
}

.message-input-container p {
  color: rgba(255, 255, 255, 0.7);
  text-align: center;
  width: 100%;
  font-size: 16px;
}

/***********************************************/
/** 7. AVATAR SELECTION **/
/***********************************************/
.avatar-selection-content {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #1a2433;
  overflow: hidden;
  padding: 0;
  position: relative;
}

/* Header section */
.avatar-selection-title {
  padding: 24px 16px;
  text-align: center;
  background: rgba(26, 36, 51, 0.95);
  position: sticky;
  /* top: 0; */
  z-index: 10;
  font-size: 2rem;
}

.avatar-selection-title h1 {
  color: var(--primary-color);
  font-size: 1.5rem;
  margin: 0;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
  font-weight: bold;
}

/* Grid container */
.avatar-grid {
  flex: 1;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  max-width: 1200px;

  gap: 16px;
  overflow-y: auto;
  overflow-x: hidden;
  /* align-content: start; */
  align-content: center;
}

/* Avatar items */
.avatar-item {
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 2px solid rgba(41, 215, 184, 0.2);
  position: relative;
}


.avatar-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar-item:hover {
  transform: translateY(-2px);
  border-color: rgba(41, 215, 184, 0.8);
  box-shadow: 0 4px 12px rgba(41, 215, 184, 0.2);
}

.avatar-item.selected {
  border-color: var(--primary-color);
  box-shadow: 0 0 20px rgba(41, 215, 184, 0.4);
}

/* Custom scrollbar (avatar grid) */
.avatar-grid::-webkit-scrollbar {
  width: 6px;
}

.avatar-grid::-webkit-scrollbar-track {
  background: rgba(26, 36, 51, 0.5);
}

.avatar-grid::-webkit-scrollbar-thumb {
  background: rgba(41, 215, 184, 0.5);
  border-radius: 3px;
}

.avatar-grid::-webkit-scrollbar-thumb:hover {
  background: rgba(41, 215, 184, 0.7);
}

/***********************************************/
/** 8. REVIEW & LEADERBOARD **/
/***********************************************/

/* Review container */
.review-container {
  width: 100%;
  max-width: 800px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px;
  background-size: cover;
  background-position: center;
  color: var(--text-light);
  box-sizing: border-box;
  position: relative;
  overflow-y: auto;
  max-height: 100vh;
}

.review-container::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: -1;
  background-size: cover;
  background-position: center;
}

/* Review sections */
.user-details,
.winning-message,
.ai-evaluation,
.review-all-conv {
  background: rgba(52, 73, 94, 0.7);
  padding: 20px;
  border-radius: 12px;
  margin-bottom: 20px;
}

.review-all-conv {
  overflow-y: auto;
  margin-bottom: 100px; /* Space for submit section */
}

/* Score submission (Review page) */
.score-submission {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(
    to top,
    rgba(44, 62, 80, 0.98),
    rgba(44, 62, 80, 0.95)
  );
  border-top: 1px solid rgba(41, 215, 184, 0.2);
  backdrop-filter: blur(8px);
  z-index: 10;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 5px;
}

.submit-name-input {
  width: 300px;
  padding: 12px 20px;
  border: 2px solid rgba(41, 215, 184, 0.5);
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  border-radius: 25px;
  font-size: 16px;
  transition: all 0.3s ease;
  margin-top: 10px;
  margin-bottom: 10px;
}

.submit-name-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 15px rgba(41, 215, 184, 0.3);
}

.score-submission button {
  padding: 12px 30px;
  background: linear-gradient(45deg, var(--secondary-color), var(--primary-color));
  color: #fff;
  border: none;
  border-radius: 25px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: 10px;
  margin-bottom: 10px;
}

.score-submission button:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 20px rgba(41, 215, 184, 0.4);
  background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
}

.score-submission button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

/* Leaderboard container */
.leaderboard-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px;
  color: var(--text-light);
  box-sizing: border-box;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f0f23 100%);
  overflow-y: auto;
  z-index: 1000;
}

/* Leaderboard Header */
.leaderboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding: 0 10px;
}

.leaderboard-title h2 {
  font-size: 2.5rem;
  color: var(--primary-color);
  margin: 0;
  text-shadow: 0 0 20px rgba(41, 215, 184, 0.5);
  background: linear-gradient(45deg, var(--primary-color), #00d4ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.game-mode-badge {
  background: linear-gradient(45deg, var(--secondary-color), var(--primary-color));
  color: #fff;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: bold;
  margin-top: 8px;
  box-shadow: 0 0 15px rgba(41, 215, 184, 0.3);
}

.play-again-button-header {
  padding: 12px 24px;
  background: linear-gradient(45deg, var(--secondary-color), var(--primary-color));
  color: #fff;
  border: none;
  border-radius: 25px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 0 15px rgba(41, 215, 184, 0.3);
  transition: all 0.3s ease;
}

.play-again-button-header:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 25px rgba(41, 215, 184, 0.5);
  background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
}

/* Podium Section */
.podium-section {
  margin-bottom: 40px;
}

.podium-container {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 20px;
  perspective: 1000px;
  min-height: 280px;
}

.podium-place {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}

.podium-place:hover {
  transform: translateY(-5px) scale(1.05);
}

.podium-avatar {
  position: relative;
  margin-bottom: 15px;
  z-index: 2;
}

.rank-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 14px;
  z-index: 3;
}

.rank-badge.gold {
  background: linear-gradient(45deg, #ffd700, #ffed4e);
  color: #333;
  font-size: 16px;
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
}

.rank-badge.silver {
  background: linear-gradient(45deg, #c0c0c0, #e8e8e8);
  color: #333;
  box-shadow: 0 0 10px rgba(192, 192, 192, 0.5);
}

.rank-badge.bronze {
  background: linear-gradient(45deg, #cd7f32, #daa520);
  color: #fff;
  box-shadow: 0 0 10px rgba(205, 127, 50, 0.5);
}

.avatar-placeholder {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(45deg, var(--secondary-color), var(--primary-color));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: bold;
  color: #fff;
  text-transform: uppercase;
  box-shadow: 0 0 20px rgba(41, 215, 184, 0.3);
  border: 3px solid rgba(255, 255, 255, 0.2);
}

.avatar-placeholder.champion {
  width: 100px;
  height: 100px;
  font-size: 36px;
  background: linear-gradient(45deg, #ffd700, var(--primary-color));
  box-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
  border: 4px solid #ffd700;
}

.podium-info {
  text-align: center;
  margin-bottom: 10px;
}

.player-name {
  font-size: 16px;
  font-weight: bold;
  color: #fff;
  margin-bottom: 5px;
}

.first-place .player-name {
  font-size: 20px;
  color: #ffd700;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.player-score {
  font-size: 18px;
  color: var(--primary-color);
  font-weight: bold;
}

.first-place .player-score {
  font-size: 22px;
  color: #ffd700;
}

.podium-step {
  width: 120px;
  border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, rgba(52, 73, 94, 0.9), rgba(44, 62, 80, 0.9));
  border: 2px solid rgba(41, 215, 184, 0.3);
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
}

.podium-step.first {
  height: 100px;
  background: linear-gradient(180deg, rgba(255, 215, 0, 0.3), rgba(255, 215, 0, 0.1));
  border-color: #ffd700;
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

.podium-step.second {
  height: 80px;
  background: linear-gradient(180deg, rgba(192, 192, 192, 0.3), rgba(192, 192, 192, 0.1));
  border-color: #c0c0c0;
}

.podium-step.third {
  height: 60px;
  background: linear-gradient(180deg, rgba(205, 127, 50, 0.3), rgba(205, 127, 50, 0.1));
  border-color: #cd7f32;
}

.podium-step:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(41, 215, 184, 0.4);
}

/* Remaining Players Section */
.remaining-players {
  margin-top: 40px;
}

.remaining-players h3 {
  font-size: 1.5rem;
  color: var(--primary-color);
  margin-bottom: 20px;
  text-align: center;
  text-shadow: 0 0 10px rgba(41, 215, 184, 0.3);
}

.player-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.player-card {
  background: rgba(52, 73, 94, 0.7);
  border: 1px solid rgba(41, 215, 184, 0.2);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(5px);
}

.player-card:hover {
  transform: translateY(-2px);
  background: rgba(52, 73, 94, 0.9);
  border-color: rgba(41, 215, 184, 0.4);
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

.card-rank {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(45deg, var(--secondary-color), var(--primary-color));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: #fff;
  font-size: 16px;
}

.card-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(45deg, rgba(41, 215, 184, 0.3), rgba(30, 30, 82, 0.8));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: bold;
  color: #fff;
  text-transform: uppercase;
  border: 2px solid rgba(255, 255, 255, 0.1);
}

.card-info {
  flex: 1;
}

.card-name {
  font-size: 16px;
  font-weight: bold;
  color: #fff;
  margin-bottom: 4px;
}

.card-score {
  font-size: 14px;
  color: var(--primary-color);
  font-weight: 600;
}

.card-progress {
  width: 100px;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* Leaderboard list */
.leaderboard-list {
  width: 100%;
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.leaderboard-list li {
  background: rgba(52, 73, 94, 0.7);
  padding: 15px 20px;
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.3s ease;
  cursor: pointer;
  border: 1px solid rgba(41, 215, 184, 0.1);
}

.leaderboard-list li:hover {
  transform: translateY(-2px);
  background: rgba(52, 73, 94, 0.9);
  border-color: rgba(41, 215, 184, 0.3);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.leaderboard-list li strong {
  font-size: 1.1em;
  color: #fff;
}

.leaderboard-list .score {
  color: var(--primary-color);
  font-weight: bold;
  font-size: 1.1em;
}

/* Play again button */
.play-again-button {
  margin-top: 30px;
  padding: 15px 30px;
  background: linear-gradient(45deg, var(--secondary-color), var(--primary-color));
  color: #fff;
  border: none;
  border-radius: 25px;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 0 15px rgba(41, 215, 184, 0.3);
  transition: all 0.3s ease;
  display: block; /* ensures margin: auto works */
  margin: 10px auto;
}

.play-again-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 25px rgba(41, 215, 184, 0.5);
  background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
}

/***********************************************/
/** 9. REPOSITIONED / SAFE-AREA UTILS **/
/***********************************************/

/* Updated welcome-content to use safe-area variables */
.welcome-content {
  position: fixed;
  top: var(--sat, 0);
  right: var(--sar, 0);
  bottom: var(--sab, 0);
  left: var(--sal, 0);
  z-index: 10;
  text-align: right;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  pointer-events: none;
}

.welcome-content h1,
.welcome-content .nudge-button {
  pointer-events: auto;
}

/* Updated nudge-button to use safe-area variables */
.nudge-button {
  position: fixed;
  right: max(20px, var(--sar, 20px));
  bottom: max(20px, var(--sab, 20px));
  z-index: 100;
}

/* Updated game-chat-ui to use safe-area variables */
.game-chat-ui-a,
.game-chat-ui-b {
  position: fixed;
  top: var(--sat, 0);
  right: var(--sar, 0);
  bottom: var(--sab, 0);
  left: var(--sal, 0);
  display: flex;
  flex-direction: column;
}

/* Updated message-input-container for safe-area */
.message-input-container {
  position: fixed;
  left: var(--sal, 0);
  right: var(--sar, 0);
  bottom: var(--sab, 0);
  padding: 15px;
  z-index: 100;
  background: rgba(0, 0, 0, 0.9);
}

.conversation-history {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  padding-bottom: calc(120px + var(--sab, 0px));
  margin-bottom: 0;
  box-sizing: border-box;
}

/***********************************************/
/** 10. KEYFRAMES & ANIMATIONS **/
/***********************************************/
@keyframes fadeInOut {
  0%,
  100% {
    opacity: 0;
  }
  5%,
  95% {
    opacity: 1;
  }
}

/***********************************************/
/** 11. SCROLLBAR STYLING (global) **/
/***********************************************/
.conversation-history::-webkit-scrollbar {
  width: 6px;
}
.conversation-history::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}
.conversation-history::-webkit-scrollbar-thumb {
  background: rgba(41, 215, 184, 0.5);
  border-radius: 3px;
}
.conversation-history::-webkit-scrollbar-thumb:hover {
  background: rgba(41, 215, 184, 0.7);
}

/***********************************************/
/** 12. NEW REVIEW PAGE STYLES **/
/***********************************************/

/* Review Container (New Design) */
.review-container-new {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px;
  background-size: cover;
  background-position: center;
  color: var(--text-light);
  box-sizing: border-box;
  overflow-y: auto;
  z-index: 1000;
}

.review-container-new::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1;
}

.review-container-new > * {
  position: relative;
  z-index: 2;
}

/* Score Showcase Section */
.score-showcase {
  text-align: center;
  margin-bottom: 30px;
  background: linear-gradient(135deg, rgba(30, 30, 82, 0.9), rgba(52, 73, 94, 0.9));
  border-radius: 20px;
  padding: 30px;
  border: 2px solid rgba(41, 215, 184, 0.3);
  box-shadow: 0 0 30px rgba(41, 215, 184, 0.2);
}

.game-mode-indicator {
  margin-bottom: 20px;
}

.mode-badge {
  background: linear-gradient(45deg, var(--secondary-color), var(--primary-color));
  color: #fff;
  padding: 8px 20px;
  border-radius: 25px;
  font-size: 18px;
  font-weight: bold;
  display: inline-block;
  margin-bottom: 8px;
  box-shadow: 0 0 15px rgba(41, 215, 184, 0.3);
}

.mode-badge.orange {
  background: linear-gradient(45deg, #ff6b35, #f7931e);
  box-shadow: 0 0 15px rgba(255, 107, 53, 0.3);
}

.mode-subtitle {
  display: block;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  font-style: italic;
}

.score-display {
  margin: 25px 0;
}

.score-number {
  font-size: 4rem;
  font-weight: bold;
  background: linear-gradient(45deg, var(--primary-color), #00d4ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 0 30px rgba(41, 215, 184, 0.5);
  margin-bottom: 10px;
}

.score-label {
  font-size: 18px;
  color: rgba(255, 255, 255, 0.8);
  text-transform: uppercase;
  letter-spacing: 2px;
}

/* Performance Badges */
.performance-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  border-radius: 25px;
  font-weight: bold;
  margin: 20px 0;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
}

.performance-badge.champion {
  background: linear-gradient(45deg, #ffd700, #ffed4e);
  color: #333;
  box-shadow: 0 0 25px rgba(255, 215, 0, 0.5);
}

.performance-badge.master {
  background: linear-gradient(45deg, #e74c3c, #c0392b);
  color: #fff;
}

.performance-badge.expert {
  background: linear-gradient(45deg, #3498db, #2980b9);
  color: #fff;
}

.performance-badge.intermediate {
  background: linear-gradient(45deg, #f39c12, #e67e22);
  color: #fff;
}

.performance-badge.novice {
  background: linear-gradient(45deg, #95a5a6, #7f8c8d);
  color: #fff;
}

.badge-icon {
  font-size: 24px;
}

.badge-text {
  font-size: 16px;
}

/* Victory Banner */
.victory-banner {
  background: linear-gradient(45deg, rgba(46, 204, 113, 0.9), rgba(39, 174, 96, 0.9));
  border: 2px solid #2ecc71;
  border-radius: 15px;
  padding: 20px;
  margin-top: 20px;
  box-shadow: 0 0 25px rgba(46, 204, 113, 0.3);
  animation: victoryPulse 2s ease-in-out infinite alternate;
}

.victory-text {
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 8px;
}

.victory-subtitle {
  font-size: 16px;
  margin-bottom: 8px;
  opacity: 0.9;
}

.bonus-points {
  font-size: 18px;
  font-weight: bold;
  color: #f1c40f;
}

/* AI Analysis Dashboard */
.ai-analysis-dashboard {
  margin-bottom: 30px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  color: var(--primary-color);
  margin-bottom: 20px;
  text-shadow: 0 0 10px rgba(41, 215, 184, 0.3);
}

.title-icon {
  font-size: 24px;
}

.ai-evaluations-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.ai-evaluations-grid.single {
  grid-template-columns: 1fr;
  max-width: 600px;
  margin: 0 auto;
}

.ai-eval-card {
  background: rgba(52, 73, 94, 0.9);
  border-radius: 15px;
  padding: 20px;
  border: 2px solid rgba(41, 215, 184, 0.2);
  transition: all 0.3s ease;
}

.ai-eval-card:hover {
  border-color: rgba(41, 215, 184, 0.5);
  box-shadow: 0 0 20px rgba(41, 215, 184, 0.2);
}

.ai-header {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 20px;
}

.ai-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(45deg, var(--secondary-color), var(--primary-color));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: bold;
  color: #fff;
}

.ai-avatar.judge {
  background: linear-gradient(45deg, #ff6b35, #f7931e);
}

.ai-info {
  flex: 1;
}

.ai-name {
  font-size: 18px;
  font-weight: bold;
  color: #fff;
  margin-bottom: 4px;
}

.ai-role {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  font-style: italic;
}

.eval-content {
  space-y: 15px;
}

.suspicion-target {
  margin-bottom: 15px;
}

.suspicion-target .label {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  margin-right: 8px;
}

.suspicion-target .target {
  font-size: 16px;
  font-weight: bold;
  color: var(--primary-color);
}

.confidence-meter {
  margin-bottom: 15px;
}

.confidence-label {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 8px;
}

.confidence-bar {
  position: relative;
  width: 100%;
  height: 12px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  overflow: hidden;
}

.confidence-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
  border-radius: 6px;
  transition: width 0.5s ease;
}

.confidence-value {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  font-weight: bold;
  color: #fff;
}

.rationale {
  margin-top: 15px;
}

.rationale-label {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 8px;
  font-weight: bold;
}

.rationale-text {
  font-size: 14px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(0, 0, 0, 0.2);
  padding: 12px;
  border-radius: 8px;
  border-left: 3px solid var(--primary-color);
}

/* Conversation Section */
.conversation-section {
  margin-bottom: 30px;
}

.section-header {
  cursor: pointer;
  padding: 15px;
  background: rgba(52, 73, 94, 0.7);
  border-radius: 10px;
  border: 2px solid rgba(41, 215, 184, 0.2);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.3s ease;
}

.section-header:hover {
  border-color: rgba(41, 215, 184, 0.4);
}

.message-count {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.6);
  font-weight: normal;
}

.toggle-icon {
  font-size: 18px;
  color: var(--primary-color);
  transition: transform 0.3s ease;
}

.toggle-icon.expanded {
  transform: rotate(180deg);
}

.conversation-timeline {
  margin-top: 15px;
  max-height: 400px;
  overflow-y: auto;
  padding: 10px;
}

.message-bubble {
  background: rgba(52, 73, 94, 0.6);
  border-radius: 12px;
  padding: 15px;
  margin-bottom: 10px;
  border-left: 4px solid var(--primary-color);
}

.message-bubble.ai-a {
  border-left-color: #3498db;
}

.message-bubble.ai-b {
  border-left-color: #e74c3c;
}

.message-bubble.user {
  border-left-color: #f39c12;
}

.message-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.message-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(45deg, var(--secondary-color), var(--primary-color));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  color: #fff;
}

.message-avatar.ai-a {
  background: linear-gradient(45deg, #3498db, #2980b9);
}

.message-avatar.ai-b {
  background: linear-gradient(45deg, #e74c3c, #c0392b);
}

.message-avatar.user {
  background: linear-gradient(45deg, #f39c12, #e67e22);
}

.message-turn {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
}

.message-text {
  font-size: 14px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.9);
}

/* Action Area */
.action-area {
  background: linear-gradient(135deg, rgba(30, 30, 82, 0.9), rgba(52, 73, 94, 0.9));
  border-radius: 15px;
  padding: 25px;
  border: 2px solid rgba(41, 215, 184, 0.3);
}

.submit-section {
  text-align: center;
}

.submit-header h3 {
  font-size: 22px;
  color: var(--primary-color);
  margin-bottom: 8px;
}

.submit-header p {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 20px;
}

.submit-form {
  display: flex;
  gap: 15px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.name-input-new {
  flex: 1;
  min-width: 250px;
  padding: 12px 20px;
  border: 2px solid rgba(41, 215, 184, 0.3);
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  border-radius: 25px;
  font-size: 16px;
  transition: all 0.3s ease;
}

.name-input-new:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 15px rgba(41, 215, 184, 0.3);
}

.submit-button-new {
  padding: 12px 30px;
  background: linear-gradient(45deg, var(--secondary-color), var(--primary-color));
  color: #fff;
  border: none;
  border-radius: 25px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.submit-button-new:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 0 25px rgba(41, 215, 184, 0.5);
  background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
}

.submit-button-new:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.loading-text {
  display: flex;
  align-items: center;
  gap: 8px;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Animations */
@keyframes victoryPulse {
  from { box-shadow: 0 0 25px rgba(46, 204, 113, 0.3); }
  to { box-shadow: 0 0 35px rgba(46, 204, 113, 0.6); }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/***********************************************/
/** 13. MEDIA QUERIES **/
/***********************************************/

/* Tablet & below (max-width: 768px) */
@media (max-width: 768px) {

  .message-content {
    font-size: 18px;
  }

  .message-input-container {
    padding: 10px;
  }

  .message-input-container input[type="text"] {
    font-size: 16px; /* Prevent zoom on iOS */
  }

  .message-input-container button {
    height: 40px;
    padding: 8px 20px;
    font-size: 14px;
  }

  .avatar-icon {
    width: 50px;
    height: 50px;
  }

  .review-container {
    padding: 15px;
    background-size: cover;
    background-position: center;
  }

  .review-all-conv {
    margin-bottom: 160px;
  }

  .score-submission {
    flex-direction: column;
    padding: 15px;
  }

  .submit-name-input {
    width: calc(100% - 40px);
    padding: 10px 16px;
    font-size: 14px;
  }

  .score-submission button {
    width: 100%;
  }

  /* Leaderboard mobile styles */
  .leaderboard-header {
    flex-direction: column;
    gap: 15px;
    text-align: center;
  }

  .leaderboard-title h2 {
    font-size: 2rem;
  }

  .podium-container {
    gap: 10px;
    min-height: 240px;
  }

  .avatar-placeholder {
    width: 60px;
    height: 60px;
    font-size: 20px;
  }

  .avatar-placeholder.champion {
    width: 75px;
    height: 75px;
    font-size: 24px;
  }

  .podium-step {
    width: 80px;
  }

  .podium-step.first {
    height: 80px;
  }

  .podium-step.second {
    height: 60px;
  }

  .podium-step.third {
    height: 40px;
  }

  .player-name {
    font-size: 14px;
  }

  .first-place .player-name {
    font-size: 16px;
  }

  .player-score {
    font-size: 16px;
  }

  .first-place .player-score {
    font-size: 18px;
  }

  .player-card {
    padding: 12px;
    gap: 12px;
  }

  .card-rank {
    width: 35px;
    height: 35px;
    font-size: 14px;
  }

  .card-avatar {
    width: 40px;
    height: 40px;
    font-size: 16px;
  }

  .card-progress {
    width: 60px;
  }

  /* New Review Page Mobile Styles */
  .review-container-new {
    padding: 15px;
  }

  .score-showcase {
    padding: 20px;
  }

  .score-number {
    font-size: 3rem;
  }

  .ai-evaluations-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .ai-evaluations-grid.single {
    max-width: none;
  }

  .ai-eval-card {
    padding: 15px;
  }

  .ai-avatar {
    width: 50px;
    height: 50px;
    font-size: 20px;
  }

  .submit-form {
    flex-direction: column;
    align-items: stretch;
  }

  .name-input-new {
    min-width: auto;
    width: 100%;
  }

  .submit-button-new {
    width: 100%;
    justify-content: center;
  }

  .section-title {
    font-size: 18px;
  }

  .conversation-timeline {
    max-height: 300px;
  }

  .message-bubble {
    padding: 12px;
  }
}

/* Small screens (max-width: 480px) */
@media screen and (max-width: 480px) {

  .leaderboard-container {
    padding: 15px;
    overflow-y: auto;
    flex-shrink: 1;
  }

  .leaderboard-container h2 {
    font-size: 2rem;
  }

  .leaderboard-list li {
    padding: 12px 15px;
    font-size: 0.9em;
  }

  .play-again-button {
    padding: 12px 25px;
    font-size: 16px;
  }
}