/* ============================================
   ChatVisionZ - Base Stylesheet
   Modern design system with CSS custom properties
   ============================================ */

/* --- Design Tokens / CSS Custom Properties --- */
:root {
  /* Colors */
  --color-bg-primary: #0f0f0f;
  --color-bg-secondary: #1a1a1a;
  --color-bg-tertiary: #242424;
  --color-bg-elevated: #2a2a2a;
  --color-bg-input: #1e1e1e;
  --color-border: #333;
  --color-border-light: #444;

  /* Text */
  --color-text-primary: #f0f0f0;
  --color-text-secondary: #b0b0b0;
  --color-text-muted: #888;
  --color-text-accent: #4e9bff;

  /* Brand */
  --color-brand-primary: #f48936;
  --color-brand-primary-hover: #ff9f4e;
  --color-brand-primary-active: #e07828;
  --color-brand-blue: #4e9bff;
  --color-brand-green: #6dce77;
  --color-brand-cyan: #00aaff;

  /* Premium */
  --color-premium: #ffc107;
  --color-premium-hover: #ffca28;

  /* Status */
  --color-success: #4CAF50;
  --color-error: #ff5555;
  --color-error-light: #ff6b6b;
  --color-danger: #d9534f;
  --color-warning: #ffc107;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Typography */
  --font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 2rem;

  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 12px 36px rgba(0, 0, 0, 0.5);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;

  /* Layout */
  --header-height: 56px;
  --input-area-height: 64px;
  --max-content-width: 1200px;
  --min-tap-target: 44px;
}

/* --- Global Reset --- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  background-color: var(--color-bg-primary);
  color: var(--color-text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--color-brand-blue);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-brand-cyan);
}

/* Focus styles for accessibility */
:focus-visible {
  outline: 2px solid var(--color-brand-cyan);
  outline-offset: 2px;
}

/* Remove default focus outline for mouse users */
:focus:not(:focus-visible) {
  outline: none;
}

/* --- Shared Button Styles --- */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-brand-primary);
  border: none;
  color: white;
  text-align: center;
  text-decoration: none;
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: 500;
  padding: var(--space-sm) var(--space-md);
  min-height: var(--min-tap-target);
  cursor: pointer;
  transition: background-color var(--transition-base),
              transform var(--transition-base),
              box-shadow var(--transition-base);
  border-radius: var(--radius-md);
  user-select: none;
  -webkit-appearance: none;
  appearance: none;
  line-height: 1.2;
}

.button:hover {
  background-color: var(--color-brand-primary-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.button:active {
  background-color: var(--color-brand-primary-active);
  transform: translateY(0);
  box-shadow: none;
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.mirror {
  transform: scaleX(-1);
}

/* --- Logo --- */
.logo-img {
  max-width: 180px;
  height: auto;
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.logo-img:hover {
  opacity: 0.85;
}

@media (max-width: 768px) {
  .logo-img {
    max-width: 140px;
  }
}

@media (max-width: 480px) {
  .logo-img {
    max-width: 110px;
  }
}

/* --- Top Bar / Header --- */
#top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  background-color: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  min-height: var(--header-height);
  position: relative;
  z-index: 50;
}

#logo {
  display: flex;
  align-items: center;
  height: 100%;
}

#logo img {
  height: auto;
  max-height: 36px;
  width: auto;
}

#logo h1 {
  cursor: pointer;
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  font-weight: 600;
  margin: 0;
}

#top-right {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* Peer label (Stranger + Premium badge) when connected */
.peer-label {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.peer-label .peer-name {
  font-weight: 500;
  color: var(--color-text-primary);
}

.peer-premium-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, rgba(255, 193, 7, 0.25), rgba(255, 193, 7, 0.15));
  color: var(--color-premium);
  text-decoration: none;
  font-size: var(--font-size-xs);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.peer-premium-badge:hover {
  background: linear-gradient(135deg, rgba(255, 193, 7, 0.4), rgba(255, 193, 7, 0.25));
  color: var(--color-premium-hover);
}

#peopleOnline p {
  color: var(--color-brand-blue);
  font-size: var(--font-size-sm);
  font-weight: 500;
  padding: var(--space-xs) var(--space-sm);
  background: rgba(78, 155, 255, 0.1);
  border-radius: var(--radius-full);
  white-space: nowrap;
}

@media (min-width: 769px) {
  #peopleOnline p {
    font-size: var(--font-size-base);
    padding: var(--space-xs) var(--space-md);
  }
}

/* --- Video Chat Layout (Main Grid) --- */
#main {
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height for mobile browsers */
  display: grid;
  grid-template-rows: var(--header-height) 1fr var(--input-area-height);
  grid-template-columns: minmax(240px, 30%) 1fr;
  grid-template-areas:
    'top top'
    'vid msg'
    'vid inp';
  overflow: hidden;
}

/* --- Video Container --- */
#videos {
  grid-area: vid;
  padding: var(--space-sm);
  padding-right: 0;
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: var(--space-xs);
  overflow: hidden;
}

#self {
  overflow: hidden;
  border-radius: var(--radius-sm);
  position: relative;
}

#peer {
  overflow: hidden;
  border-radius: var(--radius-sm);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

#peer img#watermark {
  position: absolute;
  width: 20%;
  max-width: 120px;
  left: var(--space-sm);
  bottom: var(--space-sm);
  z-index: 10;
  opacity: 0.6;
  pointer-events: none;
}

.video-player {
  width: 100%;
  height: 100%;
  background-color: var(--color-bg-tertiary);
  object-fit: cover;
  display: block;
}

#peer-video-loader {
  position: absolute;
  aspect-ratio: 1;
  width: 20%;
  max-width: 60px;
  border-radius: 50%;
  display: inline-block;
  border-top: 4px solid var(--color-text-primary);
  border-right: 4px solid transparent;
  animation: rotation 1s linear infinite;
}

/* --- Message Area --- */
#message-area {
  grid-area: msg;
  background: var(--color-bg-secondary);
  margin: var(--space-sm);
  padding: var(--space-md);
  overflow-y: auto;
  font-size: var(--font-size-base);
  border-radius: var(--radius-sm);
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

#message-area::-webkit-scrollbar {
  width: 6px;
}

#message-area::-webkit-scrollbar-track {
  background: transparent;
}

#message-area::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

.message-status {
  margin: var(--space-sm);
  margin-bottom: var(--space-md);
  font-weight: 600;
  color: var(--color-text-secondary);
}

.message {
  margin: var(--space-sm);
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.message .you {
  color: var(--color-brand-blue);
  font-weight: 500;
}

.message .strange {
  color: var(--color-brand-green);
  font-weight: 500;
}

/* --- Input Area --- */
#input-area {
  grid-area: inp;
  display: flex;
  align-items: center;
  padding: var(--space-sm);
  gap: var(--space-sm);
  background: var(--color-bg-secondary);
  border-top: 1px solid var(--color-border);
  min-width: 0;
}

#skip-btn {
  padding: var(--space-sm) clamp(12px, 3vw, 32px);
  font-size: clamp(0.875rem, 2vw, 1rem);
  min-height: var(--min-tap-target);
  flex-shrink: 0;
}

#skip-btn span,
#send-btn span {
  display: block;
  font-size: var(--font-size-xs);
  opacity: 0.7;
  margin-top: 2px;
}

#message-input {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  min-width: 0;
  min-height: var(--min-tap-target);
  background-color: var(--color-bg-input);
  color: var(--color-text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

#message-input:focus {
  border-color: var(--color-brand-cyan);
  box-shadow: 0 0 0 3px rgba(0, 170, 255, 0.15);
  outline: none;
}

#message-input::placeholder {
  color: var(--color-text-muted);
}

#send-btn {
  padding: var(--space-sm) clamp(12px, 3vw, 32px);
  font-size: clamp(0.875rem, 2vw, 1rem);
  min-height: var(--min-tap-target);
  flex-shrink: 0;
}

/* --- Emoji Button --- */
#emoji-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  width: var(--min-tap-target);
  height: var(--min-tap-target);
  min-width: var(--min-tap-target);
  flex-shrink: 0;
  cursor: pointer;
  font-size: 1.35rem;
  padding: 0;
  color: var(--color-text-muted);
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
  -webkit-appearance: none;
  appearance: none;
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', 'Twemoji Mozilla', sans-serif;
  line-height: 1;
}

#emoji-btn:hover {
  background-color: var(--color-bg-elevated);
  border-color: var(--color-brand-cyan);
  color: var(--color-text-primary);
}

#emoji-btn:active {
  background-color: var(--color-bg-tertiary);
}

/* --- Emoji Picker Panel --- */
.emoji-picker {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: min(340px, calc(100vw - 24px));
  max-height: 320px;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: 100;
  margin-bottom: var(--space-sm);
  flex-direction: column;
  overflow: hidden;
  animation: emojiSlideUp 0.2s ease;
}

.emoji-picker.open {
  display: flex;
}

@keyframes emojiSlideUp {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* Category tabs */
.emoji-tabs {
  display: flex;
  gap: 2px;
  padding: var(--space-xs);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-tertiary);
  flex-shrink: 0;
}

.emoji-tab {
  flex: 1;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  padding: var(--space-xs);
  font-size: 1.15rem;
  cursor: pointer;
  min-height: 36px;
  transition: background-color var(--transition-fast);
  color: var(--color-text-primary);
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', 'Twemoji Mozilla', sans-serif;
  line-height: 1;
}

.emoji-tab:hover {
  background-color: var(--color-bg-elevated);
}

.emoji-tab.active {
  background-color: var(--color-brand-cyan);
  color: white;
  border-radius: var(--radius-sm);
}

/* Emoji grid */
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 2px;
  padding: var(--space-sm);
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.emoji-grid::-webkit-scrollbar {
  width: 5px;
}

.emoji-grid::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

.emoji-item {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1.4rem;
  padding: var(--space-xs);
  cursor: pointer;
  min-height: 40px;
  min-width: 40px;
  transition: background-color var(--transition-fast), transform var(--transition-fast);
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', 'Twemoji Mozilla', sans-serif;
  line-height: 1;
}

.emoji-item:hover {
  background-color: var(--color-bg-elevated);
  transform: scale(1.2);
}

.emoji-item:active {
  transform: scale(0.95);
}

/* Mobile adjustments for emoji picker */
@media (max-width: 550px) {
  .emoji-picker {
    width: calc(100vw - 16px);
    left: 50%;
    max-height: 280px;
    border-radius: var(--radius-md);
  }

  .emoji-grid {
    grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
  }

  .emoji-item {
    font-size: 1.25rem;
    min-height: 36px;
    min-width: 36px;
  }
}

/* --- Game Button (input bar) --- */
#game-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  width: var(--min-tap-target);
  height: var(--min-tap-target);
  min-width: var(--min-tap-target);
  flex-shrink: 0;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0;
  color: var(--color-text-muted);
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
  -webkit-appearance: none;
  appearance: none;
  line-height: 1;
}

#game-btn:hover {
  background-color: var(--color-bg-elevated);
  border-color: var(--color-brand-cyan);
  color: var(--color-text-primary);
}

#game-btn:active {
  background-color: var(--color-bg-tertiary);
}

/* --- Game Menu (popup from game button) --- */
.game-menu {
  display: none;
  position: absolute;
  bottom: 100%;
  right: 0;
  width: 220px;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: 100;
  margin-bottom: var(--space-sm);
  overflow: hidden;
  animation: emojiSlideUp 0.2s ease;
}

.game-menu.open {
  display: block;
}

.game-menu-title {
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.game-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-md);
  background: none;
  border: none;
  color: var(--color-text-primary);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  cursor: pointer;
  transition: background-color var(--transition-fast);
  text-align: left;
}

.game-menu-item:hover {
  background-color: var(--color-bg-elevated);
}

.game-menu-item:active {
  background-color: var(--color-bg-tertiary);
}

.game-menu-item .game-icon {
  font-size: 1.4rem;
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}

.game-menu-item .game-label {
  font-weight: 500;
}

/* --- Game Overlay (replaces message area content) --- */
.game-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  gap: var(--space-md);
  padding: var(--space-md);
  text-align: center;
}

.game-overlay .game-back-btn {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-full);
  font-family: var(--font-family);
  font-size: var(--font-size-xs);
  cursor: pointer;
  z-index: 5;
  transition: all var(--transition-fast);
}

.game-overlay .game-back-btn:hover {
  background: var(--color-bg-tertiary);
  color: var(--color-text-primary);
}

.game-overlay .game-title {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--color-text-primary);
}

.game-overlay .game-status {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  min-height: 1.4em;
}

.game-overlay .game-status.win { color: var(--color-success); font-weight: 600; }
.game-overlay .game-status.lose { color: var(--color-error); font-weight: 600; }
.game-overlay .game-status.draw { color: var(--color-premium); font-weight: 600; }

/* --- Game Invitation Banner --- */
.game-invite-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  margin: var(--space-sm);
  background: rgba(0, 170, 255, 0.08);
  border: 1px solid rgba(0, 170, 255, 0.25);
  border-radius: var(--radius-md);
  animation: emojiSlideUp 0.3s ease;
}

.game-invite-banner p {
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
}

.game-invite-banner .invite-actions {
  display: flex;
  gap: var(--space-sm);
}

.game-invite-banner .invite-accept {
  padding: var(--space-sm) var(--space-lg);
  background: var(--color-success);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-weight: 600;
  font-size: var(--font-size-sm);
  cursor: pointer;
  min-height: 38px;
  transition: background-color var(--transition-fast);
}

.game-invite-banner .invite-accept:hover { background: #3d8b40; }

.game-invite-banner .invite-decline {
  padding: var(--space-sm) var(--space-lg);
  background: var(--color-bg-elevated);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  cursor: pointer;
  min-height: 38px;
  transition: all var(--transition-fast);
}

.game-invite-banner .invite-decline:hover {
  background: var(--color-bg-tertiary);
  color: var(--color-text-primary);
}

/* --- Tic Tac Toe Board --- */
.ttt-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  width: min(260px, 60vw);
  aspect-ratio: 1;
  background: var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.ttt-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg-secondary);
  border: none;
  font-size: clamp(2rem, 8vw, 3.5rem);
  font-weight: 700;
  cursor: pointer;
  color: var(--color-text-primary);
  transition: background-color var(--transition-fast);
  font-family: var(--font-family);
  padding: 0;
}

.ttt-cell:hover:not(.taken) {
  background: var(--color-bg-elevated);
}

.ttt-cell.taken {
  cursor: default;
}

.ttt-cell.x { color: var(--color-brand-cyan); }
.ttt-cell.o { color: var(--color-brand-primary); }

.ttt-cell.win-cell {
  background: rgba(0, 170, 255, 0.15);
}

/* --- Pac-Man Container --- */
.pacman-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
}

.pacman-container canvas {
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  max-width: 100%;
  touch-action: none;
  image-rendering: pixelated;
}

.pacman-hud {
  display: flex;
  justify-content: space-between;
  width: min(300px, 80vw);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.pacman-hud .hud-score { color: var(--color-premium); font-weight: 600; }
.pacman-hud .hud-time { color: var(--color-brand-cyan); font-weight: 600; }
.pacman-hud .hud-lives { color: var(--color-error); }

/* Pac-Man on-screen arrow pad (mobile) */
.pacman-dpad {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: auto auto auto;
  gap: 6px;
  margin-top: var(--space-md);
  width: min(180px, 70vw);
  max-width: 100%;
}
.pacman-dpad .dpad-btn {
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text-primary);
  background: var(--color-bg-tertiary);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: background var(--transition-fast), transform var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}
.pacman-dpad .dpad-btn:active {
  background: var(--color-brand-primary);
  transform: scale(0.95);
}
.pacman-dpad .dpad-up   { grid-column: 2; grid-row: 1; }
.pacman-dpad .dpad-left { grid-column: 1; grid-row: 2; }
.pacman-dpad .dpad-down { grid-column: 2; grid-row: 2; }
.pacman-dpad .dpad-right { grid-column: 3; grid-row: 2; }

/* --- Game Action Buttons --- */
.game-action-btn {
  padding: var(--space-sm) var(--space-xl);
  background: var(--color-brand-cyan);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-weight: 600;
  font-size: var(--font-size-sm);
  cursor: pointer;
  min-height: var(--min-tap-target);
  transition: all var(--transition-base);
}

.game-action-btn:hover {
  background: #0095dd;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.game-action-btn.secondary {
  background: var(--color-bg-elevated);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}

.game-action-btn.secondary:hover {
  background: var(--color-bg-tertiary);
  color: var(--color-text-primary);
}

/* Score display after game */
.game-score-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-md);
  background: var(--color-bg-elevated);
  border-radius: var(--radius-md);
  min-width: 180px;
}

.game-score-display .score-label {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
}

.game-score-display .score-value {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--color-premium);
}

/* Mobile: game button and menu */
@media (max-width: 550px) {
  #game-btn {
    width: 38px;
    height: 38px;
    min-width: 38px;
    font-size: 1.05rem;
  }

  .game-menu {
    width: 200px;
    right: auto;
    left: 50%;
    transform: translateX(-50%);
  }

  .ttt-board {
    width: min(220px, 55vw);
  }
}

/* --- Modal Base Styles --- */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-content {
  background-color: var(--color-bg-tertiary);
  margin: 5% auto;
  padding: var(--space-lg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  color: var(--color-text-primary);
  box-shadow: var(--shadow-xl);
  animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.close-modal,
.close {
  color: var(--color-text-muted);
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  transition: color var(--transition-fast);
  line-height: 1;
}

.close-modal:hover,
.close-modal:focus,
.close:hover,
.close:focus {
  color: var(--color-text-primary);
}

/* --- Alert Popup (Banned / Face / NSFW) --- */
.alert-popup {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: rgba(255, 235, 235, 0.97);
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: 1000;
  max-width: 90%;
  width: 420px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(217, 83, 79, 0.2);
  animation: alertPopIn 0.3s ease;
}

@keyframes alertPopIn {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

.alert-popup h3 {
  margin: 0 0 var(--space-sm);
  font-family: var(--font-family);
  font-size: clamp(1rem, 4vw, 1.125rem);
  color: #333;
  font-weight: 700;
  text-align: center;
}

.alert-popup p {
  font-family: var(--font-family);
  font-size: clamp(0.875rem, 3.5vw, 1rem);
  color: #444;
  font-weight: 500;
  text-align: center;
  line-height: 1.5;
  margin: 0;
}

.alert-popup .alert-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.alert-popup .btn-alert-primary {
  display: block;
  width: 100%;
  padding: 12px var(--space-md);
  background-color: #4a90e2;
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: var(--font-family);
  font-size: clamp(0.875rem, 3.5vw, 1rem);
  font-weight: 500;
  text-align: center;
  text-decoration: none;
  transition: background-color var(--transition-fast), transform var(--transition-fast);
  min-height: var(--min-tap-target);
}

.alert-popup .btn-alert-primary:hover {
  background-color: #3a7bd5;
  transform: translateY(-1px);
}

.alert-popup .btn-alert-danger {
  display: block;
  width: 100%;
  padding: 12px var(--space-md);
  background-color: var(--color-danger);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: var(--font-family);
  font-size: clamp(0.875rem, 3.5vw, 1rem);
  font-weight: 500;
  text-align: center;
  transition: background-color var(--transition-fast), transform var(--transition-fast);
  min-height: var(--min-tap-target);
}

.alert-popup .btn-alert-danger:hover {
  background-color: #c9302c;
  transform: translateY(-1px);
}

/* --- Animations --- */
@keyframes rotation {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.pulse {
  animation: pulseAnimation 2s ease-in-out infinite;
}

@keyframes pulseAnimation {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* --- Utility Classes --- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.colored-text {
  color: var(--color-brand-primary);
  font-weight: 600;
}

/* --- Ban Overlay (used by video.js when user is banned) --- */
.ban-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(217, 83, 79, 0.45);
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
  pointer-events: none;
}

.ban-overlay-text {
  color: white;
  font-size: clamp(1rem, 4vw, 1.5rem);
  font-weight: 700;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  text-align: center;
  padding: var(--space-sm);
}

/* --- Responsive: Tablet & Mobile Video Layout --- */
@media screen and (max-width: 768px) {
  #main {
    /* Use minmax for input row so it can grow when buttons wrap */
    grid-template-rows: var(--header-height) 38vh 1fr minmax(var(--input-area-height), auto);
    grid-template-columns: 1fr;
    grid-template-areas:
      'top'
      'vid'
      'msg'
      'inp';
  }

  #videos {
    padding: var(--space-sm);
    grid-template-rows: 1fr;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xs);
  }

  #self {
    margin: 0;
  }

  #peer {
    margin: 0;
  }

  #message-area {
    margin: var(--space-xs);
    padding: var(--space-sm);
  }

  #input-area {
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
  }

  #skip-btn span,
  #send-btn span {
    display: none;
  }
}

/* --- Responsive: Small Mobile --- */
@media screen and (max-width: 550px) {
  #videos {
    grid-template-rows: 1fr;
    grid-template-columns: 1fr;
    position: relative;
  }

  #self {
    position: absolute;
    z-index: 10;
    width: 28%;
    bottom: var(--space-sm);
    right: var(--space-sm);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    border: 2px solid rgba(255, 255, 255, 0.15);
  }

  #self .video-player {
    border-radius: var(--radius-md);
  }

  #peer {
    height: 100%;
  }

  /* Allow input area to grow for wrapped content */
  #input-area {
    flex-wrap: wrap;
    height: auto;
    min-height: var(--input-area-height);
    padding: var(--space-xs) var(--space-sm);
    overflow: visible;
  }

  #message-input {
    order: -1;
    width: 100%;
    flex: 1 1 100%;
    margin-bottom: var(--space-xs);
  }

  #skip-btn,
  #send-btn {
    flex: 1;
    min-width: 80px;
    display: inline-flex;
  }
}

/* --- Responsive: Extra Small --- */
@media screen and (max-width: 375px) {
  :root {
    --header-height: 48px;
    --input-area-height: 56px;
  }

  #top-bar {
    padding: var(--space-xs) var(--space-sm);
  }

  #self {
    width: 32%;
  }

  .modal-content {
    width: 95%;
    padding: var(--space-md);
    margin: 3% auto;
  }
}
