/*
 * GOOSE RUNNER (Гусиные Бега) - CSS Design System
 * Warm light mode inspired by the "Cherny Otrog 195" rural festival brandbook.
 * Soft cream backgrounds, sage green and terracotta accents, Comfortaa typography.
 */

@import url('https://fonts.googleapis.com/css2?family=Comfortaa:wght@400;600;700;800&family=Outfit:wght@300;400;600;800&display=swap');

:root {
  --bg-primary: #FAF8F0;           /* Warm cream/off-white background */
  --bg-secondary: #F4EFE6;         /* Slightly darker cream/craft paper */
  --bg-glass: #FFFFFF;             /* Solid white for cards */
  --border-glass: #E5DFD3;         /* Elegant warm beige border */
  
  --color-text: #2D3C33;           /* Deep charcoal/forest green text */
  --color-text-muted: #687D70;     /* Muted sage-green for subtexts */
  
  --accent-neon-green: #5A7D65;    /* Sage green from brandbook */
  --accent-neon-green-glow: rgba(90, 125, 101, 0.1);
  
  --accent-goose-orange: #E05D5D;  /* Terracotta / Coral Red from brandbook */
  --accent-goose-orange-glow: rgba(224, 93, 93, 0.15);
  
  --accent-cyan: #E6C280;          /* Golden Wheat from brandbook */
  --accent-cyan-glow: rgba(230, 194, 128, 0.15);

  --font-sans: 'Comfortaa', 'Outfit', sans-serif;
  --font-retro: 'Comfortaa', sans-serif;
  
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-glow: 0 8px 24px rgba(45, 60, 51, 0.05);
  --shadow-orange-glow: 0 8px 24px rgba(224, 93, 93, 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body, html {
  width: 100%;
  height: 100%;
  background-color: var(--bg-primary);
  color: var(--color-text);
  font-family: var(--font-sans);
  overflow: hidden;
  position: relative;
  touch-action: none; /* Disable pinch zoom and swipe pull-to-refresh at body level */
}

/* Background animated glow gradients */
.bg-glow-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.bg-glow-circle-1 {
  position: absolute;
  top: -10%;
  right: -10%;
  width: 60vw;
  height: 60vw;
  background: radial-gradient(circle, rgba(90, 125, 101, 0.08) 0%, transparent 70%);
  filter: blur(80px);
  animation: float-slow 20s infinite alternate;
}

.bg-glow-circle-2 {
  position: absolute;
  bottom: -10%;
  left: -10%;
  width: 70vw;
  height: 70vw;
  background: radial-gradient(circle, rgba(224, 93, 93, 0.06) 0%, transparent 70%);
  filter: blur(100px);
  animation: float-slow 25s infinite alternate-reverse;
}

/* Main Layout Container */
.app-container {
  position: relative;
  width: 100%;
  height: 100%;
  z-index: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}

.screen {
  position: absolute;
  width: 100%;
  height: 100%;
  max-width: 480px; /* Mobile first lock */
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y; /* Enable vertical swipe scrolling on menu screens */
  opacity: 0;
  transform: scale(0.95);
  pointer-events: none;
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 2;
}

.screen.active {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

/* Card layout wrapper (Light Glassmorphism / Craft paper look) */
.glass-card {
  width: 100%;
  background: var(--bg-glass);
  border: 2px solid var(--border-glass);
  border-radius: 24px;
  padding: 24px 16px;
  box-shadow: 0 12px 40px rgba(45, 60, 51, 0.06);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  overflow: hidden;
  margin: auto 0; /* Align card in the center if height allows, else scroll from top */
  flex-shrink: 0; /* Prevent the card from shrinking and cutting off content on small viewports */
}

.glass-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(to right, transparent, rgba(90, 125, 101, 0.02), transparent);
  transform: skewX(-25deg);
  pointer-events: none;
}

.glass-card:hover::before {
  animation: shine 1.5s ease;
}

/* Typography */
h1 {
  font-family: var(--font-retro);
  font-size: 2.1rem;
  font-weight: 800;
  color: var(--accent-neon-green);
  margin-bottom: 8px;
  letter-spacing: -0.5px;
  text-transform: uppercase;
}

h2 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--accent-neon-green);
}

p {
  color: var(--color-text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 24px;
}

/* Input Fields */
.input-group {
  width: 100%;
  margin-bottom: 20px;
  position: relative;
}

.input-label {
  display: block;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 8px;
  letter-spacing: 1px;
}

input[type="text"] {
  width: 100%;
  padding: 14px 20px;
  background: #FFFFFF;
  border: 2px solid var(--border-glass);
  border-radius: 12px;
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  outline: none;
  transition: var(--transition-smooth);
}

input[type="text"]:focus {
  border-color: var(--accent-neon-green);
  box-shadow: 0 4px 12px rgba(90, 125, 101, 0.08);
  background: #FFFFFF;
}

/* Skin/Goose Selector Grid */
.skin-selector {
  width: 100%;
  margin-bottom: 24px;
}

.skin-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: 100%;
}

.skin-option {
  padding: 8px 4px;
  border-radius: 12px;
  border: 2px solid var(--border-glass);
  background: rgba(90, 125, 101, 0.03);
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.skin-option:hover {
  background: rgba(90, 125, 101, 0.06);
}

.skin-option.active {
  border-color: var(--accent-goose-orange);
  background: rgba(224, 93, 93, 0.08);
  box-shadow: 0 4px 12px rgba(224, 93, 93, 0.12);
}

.skin-preview-svg {
  width: 42px;
  height: 34px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.skin-name {
  font-size: 0.65rem;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  max-width: 100%;
  color: var(--color-text);
}

.skin-option.active .skin-name {
  color: var(--accent-goose-orange);
}

/* Custom Buttons */
.btn {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 16px;
  font-family: var(--font-sans);
  font-size: 1.1rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  transition: var(--transition-smooth);
  position: relative;
  overflow: hidden;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: var(--accent-neon-green);
  color: #FAF8F0;
  box-shadow: 0 4px 12px rgba(90, 125, 101, 0.2);
}

.btn-primary:hover {
  transform: translateY(-2px);
  background: #4a6753;
  box-shadow: 0 6px 20px rgba(90, 125, 101, 0.3);
}

.btn-primary:active {
  transform: translateY(1px);
}

.btn-secondary {
  background: #FFFFFF;
  border: 2px solid var(--border-glass);
  color: var(--color-text);
  box-shadow: 0 4px 12px rgba(45, 60, 51, 0.03);
}

.btn-secondary:hover {
  background: var(--bg-secondary);
  border-color: var(--color-text-muted);
}

.btn-orange {
  background: var(--accent-goose-orange);
  color: #FAF8F0;
  box-shadow: 0 6px 20px rgba(224, 93, 93, 0.2);
}

.btn-orange:hover {
  transform: translateY(-2px);
  background: #c94f4f;
  box-shadow: 0 8px 24px rgba(224, 93, 93, 0.35);
}

.btn-orange:active {
  transform: translateY(1px);
}

/* Sound Button (floating) */
.sound-toggle {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--border-glass);
  background: var(--bg-glass);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  z-index: 10;
  color: var(--color-text);
  box-shadow: 0 4px 12px rgba(45, 60, 51, 0.05);
  transition: var(--transition-smooth);
}

.sound-toggle:hover {
  background: var(--bg-secondary);
  transform: scale(1.05);
}

/* Game Interface Layout */
#game-screen {
  padding: 0;
  max-width: 100% !important;
  overflow: hidden !important;
  touch-action: none !important;
}

.game-header {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 5;
  background: linear-gradient(to bottom, rgba(250, 248, 240, 0.8), transparent);
  pointer-events: none;
}

.score-hud {
  display: flex;
  flex-direction: column;
}

.hud-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
}

.hud-val {
  font-family: var(--font-retro);
  font-size: 1.3rem;
  color: var(--color-text);
  font-weight: 800;
}

.high-score-hud .hud-val {
  color: var(--accent-goose-orange);
}

/* The Game Canvas */
#game-canvas {
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
  display: block;
  touch-action: none !important;
}

/* Mobile Controls Overlay */
.mobile-controls {
  position: absolute;
  bottom: 30px;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 0 30px;
  pointer-events: none;
  z-index: 5;
}

.controls-left, .controls-right {
  display: flex;
  gap: 15px;
}

.control-btn {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid var(--border-glass);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: auto;
  cursor: pointer;
  color: var(--color-text);
  box-shadow: 0 6px 20px rgba(45, 60, 51, 0.08);
  transition: var(--transition-smooth);
}

.control-btn:active {
  transform: scale(0.9);
  background: var(--bg-secondary);
  border-color: var(--accent-neon-green);
}

.control-btn svg {
  width: 32px;
  height: 32px;
  fill: currentColor;
}

/* Leaderboard view styling */
.leaderboard-list {
  width: 100%;
  margin: 16px 0;
  max-height: 250px;
  overflow-y: auto;
  padding-right: 4px;
}

.leaderboard-list::-webkit-scrollbar {
  width: 6px;
}

.leaderboard-list::-webkit-scrollbar-track {
  background: rgba(90, 125, 101, 0.02);
  border-radius: 3px;
}

.leaderboard-list::-webkit-scrollbar-thumb {
  background: rgba(90, 125, 101, 0.15);
  border-radius: 3px;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(90, 125, 101, 0.04);
  margin-bottom: 8px;
  border: 1px solid transparent;
  transition: var(--transition-smooth);
}

.leaderboard-item:hover {
  background: rgba(90, 125, 101, 0.08);
}

.leaderboard-item.top-1 {
  border-color: rgba(230, 194, 128, 0.5);
  background: linear-gradient(90deg, rgba(230, 194, 128, 0.12), transparent);
}
.leaderboard-item.top-1 .rank {
  color: #b58d3d;
  font-weight: 800;
}

.leaderboard-item.top-2 {
  border-color: rgba(148, 163, 184, 0.5);
  background: linear-gradient(90deg, rgba(148, 163, 184, 0.12), transparent);
}
.leaderboard-item.top-2 .rank {
  color: #788290;
}

.leaderboard-item.top-3 {
  border-color: rgba(224, 93, 93, 0.3);
  background: linear-gradient(90deg, rgba(224, 93, 93, 0.08), transparent);
}
.leaderboard-item.top-3 .rank {
  color: #b84c4c;
}

.rank {
  width: 30px;
  font-family: var(--font-retro);
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.player-info {
  flex: 1;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.player-score {
  font-family: var(--font-retro);
  font-size: 0.9rem;
  color: var(--accent-neon-green);
  font-weight: 800;
}

/* ========================================================
   PROJECTOR DASHBOARD (Трансляция для большого экрана)
   ======================================================== */
.projector-container {
  width: 100vw;
  height: 100vh;
  padding: 40px;
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 40px;
  max-width: 1600px;
  align-items: center;
}

.projector-main {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: var(--bg-glass);
  border: 2px solid var(--border-glass);
  border-radius: 32px;
  padding: 48px;
  box-shadow: 0 15px 45px rgba(45, 60, 51, 0.06);
}

.projector-sidebar {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 30px;
}

.projector-qr-card {
  background: var(--bg-glass);
  border: 2px solid var(--border-glass);
  border-radius: 32px;
  padding: 40px 30px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 15px 45px rgba(45, 60, 51, 0.06);
}

.qr-code-wrapper {
  background: white;
  padding: 16px;
  border-radius: 20px;
  margin: 20px 0;
  box-shadow: 0 8px 30px rgba(45, 60, 51, 0.08);
  display: inline-block;
  border: 1px solid var(--border-glass);
  transition: var(--transition-smooth);
}

.qr-code-wrapper img, .qr-code-wrapper canvas {
  display: block;
}

.projector-stats-card {
  background: var(--bg-glass);
  border: 2px solid var(--border-glass);
  border-radius: 32px;
  padding: 30px;
  flex: 1;
  box-shadow: 0 15px 45px rgba(45, 60, 51, 0.06);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.stat-item {
  background: rgba(90, 125, 101, 0.03);
  border: 1px solid var(--border-glass);
  padding: 16px;
  border-radius: 16px;
  text-align: center;
}

.stat-val {
  font-family: var(--font-retro);
  font-size: 1.5rem;
  color: var(--accent-neon-green);
  margin-top: 8px;
  font-weight: 800;
}

/* Large Leaderboard for Projector */
.proj-title-bar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 2px solid var(--border-glass);
  padding-bottom: 20px;
  margin-bottom: 30px;
}

.proj-title {
  font-family: var(--font-retro);
  font-size: 2.2rem;
  color: var(--accent-neon-green);
  font-weight: 800;
}

.proj-subtitle {
  color: var(--color-text-muted);
  font-weight: 700;
  font-size: 1.1rem;
}

.proj-leaderboard {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

.proj-item {
  display: flex;
  align-items: center;
  padding: 16px 24px;
  border-radius: 16px;
  background: rgba(90, 125, 101, 0.03);
  border: 1px solid var(--border-glass);
  font-size: 1.3rem;
  animation: list-entry-slide 0.5s ease forwards;
  color: var(--color-text);
}

.proj-item .rank {
  font-size: 1.4rem;
  width: 50px;
  font-weight: 700;
}

.proj-item .player-name {
  font-size: 1.4rem;
}

.proj-item .player-score {
  font-size: 1.4rem;
  font-weight: 800;
}

.proj-item.top-1 {
  background: linear-gradient(90deg, rgba(230, 194, 128, 0.12), transparent);
  border-color: rgba(230, 194, 128, 0.5);
  box-shadow: 0 6px 20px rgba(230, 194, 128, 0.1);
  transform: scale(1.02);
}

/* Admin panel modal overlay */
.admin-trigger {
  position: absolute;
  bottom: 20px;
  right: 20px;
  background: transparent;
  border: none;
  color: rgba(45, 60, 51, 0.2);
  cursor: pointer;
  font-size: 0.8rem;
  z-index: 100;
  transition: var(--transition-smooth);
}

.admin-trigger:hover {
  color: var(--color-text);
}

.admin-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(250, 248, 240, 0.95);
  backdrop-filter: blur(10px);
  z-index: 200;
  display: none;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.admin-card {
  max-width: 500px;
  width: 100%;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  width: 100%;
  margin-top: 20px;
}

/* Animations */
@keyframes float-slow {
  0% { transform: translateY(0px) rotate(0deg); }
  50% { transform: translateY(-20px) rotate(2deg); }
  100% { transform: translateY(0px) rotate(0deg); }
}

@keyframes shine {
  100% { left: 125%; }
}

@keyframes list-entry-slide {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive screen layout switches */
#projector-screen {
  max-width: 100%;
  display: none; /* Only show when triggered */
  justify-content: center;
  align-items: center;
}

#projector-screen.active {
  display: flex;
}

/* Media query for landscape/projector viewports */
@media (min-width: 1024px) and (min-height: 500px) {
  body.mode-projector .screen:not(#projector-screen) {
    display: none !important;
  }
}

/* Orientation Warning Overlay */
.orientation-warning {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
  z-index: 9999;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 30px;
  box-sizing: border-box;
}

.orientation-icon {
  animation: rotate-device 2s infinite ease-in-out;
  color: var(--accent-neon-green);
  margin-bottom: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.orientation-warning p {
  font-size: 1.1rem;
  color: var(--color-text);
  max-width: 320px;
  margin: 0;
  line-height: 1.4;
  font-weight: 700;
}

@keyframes rotate-device {
  0% { transform: rotate(0deg); }
  50% { transform: rotate(-90deg); }
  100% { transform: rotate(-90deg); }
}

/* Show warning ONLY in portrait orientation and when the game is active */
@media (orientation: portrait) {
  body.game-playing .orientation-warning {
    display: flex;
  }
}

/* Center start button overlay on game screen */
.game-start-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  background: rgba(250, 248, 240, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: auto;
}
