/* ========================================
   Rock Paper Scissors - game4.fun
   Dark glassmorphism theme
======================================== */

:root {
  --bg-dark: #0a0a1a;
  --bg-card: rgba(255, 255, 255, 0.04);
  --primary-neon: #6366f1;
  --secondary-neon: #ec4899;
  --accent-cyan: #06b6d4;
  --win-green: #22c55e;
  --lose-red: #ef4444;
  --draw-yellow: #eab308;
  --text-main: #f0f0f5;
  --text-dim: rgba(240, 240, 245, 0.5);
  --border-glass: rgba(255, 255, 255, 0.08);
  --radius-xl: 24px;
  --radius-lg: 16px;
  --radius-md: 10px;
}

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

body {
  background: var(--bg-dark);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

/* ---- Header ---- */
.g4f-header {
  width: 100%;
  max-width: 600px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-main);
  font-size: 1.1rem;
  font-weight: 700;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary-neon), var(--secondary-neon));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.2rem;
  color: #fff;
}

.highlight-4 {
  color: var(--primary-neon);
  font-weight: 800;
}

.lang-switch {
  display: flex;
  gap: 6px;
}

.lang-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.25s ease;
}

.lang-btn.active {
  color: var(--text-main);
  border-color: var(--primary-neon);
  background: rgba(99, 102, 241, 0.15);
}

/* ---- Game Container ---- */
.game-container {
  width: 100%;
  max-width: 500px;
  padding: 0 20px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  flex: 1;
  position: relative;
}

.game-header {
  text-align: center;
}

.game-header h1 {
  font-size: 1.6rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary-neon), var(--secondary-neon));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-top: 4px;
}

/* ---- Glass Panel ---- */
.glass-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 12px 16px;
  width: 100%;
}

/* ---- Mode Selector ---- */
.mode-selector {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mode-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.mode-label {
  font-size: 0.8rem;
  color: var(--text-dim);
  min-width: 60px;
}

.mode-buttons {
  display: flex;
  gap: 6px;
  flex: 1;
  flex-wrap: wrap;
}

.mode-btn {
  flex: 1;
  min-width: 60px;
  padding: 8px 4px;
  background: transparent;
  border: 1px solid var(--border-glass);
  color: var(--text-dim);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  transition: all 0.25s ease;
  white-space: nowrap;
}

.mode-btn.active {
  color: var(--text-main);
  border-color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.12);
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.15);
}

/* Extended toggle */
.extended-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.toggle-label input {
  display: none;
}

.toggle-track {
  width: 40px;
  height: 22px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 11px;
  position: relative;
  transition: background 0.3s;
}

.toggle-thumb {
  width: 18px;
  height: 18px;
  background: var(--text-dim);
  border-radius: 50%;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: all 0.3s;
}

.toggle-label input:checked ~ .toggle-track {
  background: rgba(99, 102, 241, 0.3);
}

.toggle-label input:checked ~ .toggle-track .toggle-thumb {
  left: 20px;
  background: var(--primary-neon);
}

.toggle-text {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
}

.toggle-label input:checked ~ .toggle-text {
  color: var(--text-main);
}

.extended-desc {
  font-size: 0.72rem;
  color: var(--text-dim);
  opacity: 0.6;
}

/* ---- Arena ---- */
.arena {
  padding: 20px 16px;
  text-align: center;
}

.arena-players {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.arena-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.arena-label {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
}

.arena-choice {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.03);
  border: 2px solid var(--border-glass);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.arena-choice .choice-emoji {
  font-size: 2.2rem;
  line-height: 1;
}

.arena-vs {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-dim);
  padding: 0 4px;
}

/* Arena result states */
.arena-choice.win {
  border-color: var(--win-green);
  box-shadow: 0 0 24px rgba(34, 197, 94, 0.3);
  animation: resultPulse 0.6s ease;
}

.arena-choice.lose {
  border-color: var(--lose-red);
  box-shadow: 0 0 24px rgba(239, 68, 68, 0.3);
  animation: resultPulse 0.6s ease;
}

.arena-choice.draw {
  border-color: var(--draw-yellow);
  box-shadow: 0 0 24px rgba(234, 179, 8, 0.3);
  animation: resultPulse 0.6s ease;
}

@keyframes resultPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* Computer cycling animation */
.arena-choice.cycling .choice-emoji {
  animation: cycleShake 0.1s ease infinite;
}

@keyframes cycleShake {
  0%, 100% { transform: translateY(0); }
  25% { transform: translateY(-3px) rotate(-5deg); }
  75% { transform: translateY(3px) rotate(5deg); }
}

/* Result display */
.result-display {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 48px;
}

.result-text {
  font-size: 1.1rem;
  font-weight: 700;
  transition: color 0.3s;
}

.result-text.win { color: var(--win-green); text-shadow: 0 0 16px rgba(34, 197, 94, 0.4); }
.result-text.lose { color: var(--lose-red); text-shadow: 0 0 16px rgba(239, 68, 68, 0.4); }
.result-text.draw { color: var(--draw-yellow); text-shadow: 0 0 16px rgba(234, 179, 8, 0.4); }

.result-detail {
  font-size: 0.82rem;
  color: var(--text-dim);
  font-weight: 500;
  min-height: 1.2em;
}

/* Round indicator */
.round-indicator {
  margin-top: 10px;
  display: flex;
  justify-content: center;
  gap: 6px;
  min-height: 20px;
}

.round-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-glass);
  transition: all 0.3s;
}

.round-dot.player-won { background: var(--win-green); border-color: var(--win-green); box-shadow: 0 0 8px rgba(34, 197, 94, 0.4); }
.round-dot.computer-won { background: var(--lose-red); border-color: var(--lose-red); box-shadow: 0 0 8px rgba(239, 68, 68, 0.4); }
.round-dot.drawn { background: var(--draw-yellow); border-color: var(--draw-yellow); box-shadow: 0 0 8px rgba(234, 179, 8, 0.3); }
.round-dot.current { border-color: var(--accent-cyan); box-shadow: 0 0 8px rgba(6, 182, 212, 0.3); }

/* ---- Choice Buttons ---- */
.choices {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
}

.choice-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 12px;
  min-width: 80px;
  flex: 1;
  max-width: 110px;
  background: var(--bg-card);
  border: 2px solid var(--border-glass);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.25s ease;
  color: var(--text-main);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.choice-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.choice-btn:active {
  transform: translateY(0) scale(0.95);
}

.choice-btn.selected {
  border-color: var(--primary-neon);
  background: rgba(99, 102, 241, 0.15);
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.2);
  animation: selectBounce 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.choice-btn.disabled {
  pointer-events: none;
  opacity: 0.4;
}

@keyframes selectBounce {
  0% { transform: scale(1); }
  40% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.choice-icon {
  font-size: 2rem;
  line-height: 1;
}

.choice-name {
  font-size: 0.72rem;
  color: var(--text-dim);
  font-weight: 600;
}

/* Extended-only buttons hidden by default */
.choice-btn.extended-only {
  display: none;
}

.choices.extended .choice-btn.extended-only {
  display: flex;
}

.choices.extended .choice-btn {
  min-width: 65px;
  padding: 12px 8px;
}

/* ---- Scoreboard ---- */
.scoreboard {
  display: flex;
  justify-content: space-around;
  text-align: center;
  gap: 8px;
}

.score-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.score-label {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.score-value {
  font-size: 1.4rem;
  font-weight: 800;
}

.score-player .score-value { color: var(--win-green); }
.score-computer .score-value { color: var(--lose-red); }
.score-draw .score-value { color: var(--text-dim); }
.score-streak .score-value { color: var(--accent-cyan); }

/* ---- Stats Bar ---- */
.stats-bar {
  display: flex;
  justify-content: space-around;
  text-align: center;
  padding: 10px 16px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary-neon);
}

/* ---- Match Result Overlay ---- */
.match-result-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.match-result-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.match-result-content {
  text-align: center;
  padding: 32px 40px;
  max-width: 340px;
  animation: overlayPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.match-result-content h2 {
  font-size: 1.4rem;
  margin-bottom: 20px;
  background: linear-gradient(135deg, var(--primary-neon), var(--secondary-neon));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

@keyframes overlayPop {
  0% { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* ---- History ---- */
.history-section {
  width: 100%;
}

.section-title {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 8px;
  font-weight: 600;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

.history-item .history-choices {
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-item .history-emoji {
  font-size: 1.1rem;
}

.history-item .history-vs {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.history-item .history-result {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
}

.history-result.win { color: var(--win-green); background: rgba(34, 197, 94, 0.12); }
.history-result.lose { color: var(--lose-red); background: rgba(239, 68, 68, 0.12); }
.history-result.draw { color: var(--draw-yellow); background: rgba(234, 179, 8, 0.12); }

/* ---- Buttons ---- */
.actions {
  display: flex;
  gap: 10px;
  width: 100%;
}

.btn {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s ease;
  background: var(--bg-card);
  color: var(--text-main);
}

.btn-primary {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(236, 72, 153, 0.2));
  border-color: rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.35), rgba(236, 72, 153, 0.35));
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.2);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.06);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0) scale(0.97);
}

/* ---- Ad Container ---- */
.g4f-ad-container {
  width: 100%;
  max-width: 500px;
  margin: 8px auto;
  padding: 20px;
  text-align: center;
  background: var(--bg-card);
  border: 1px dashed var(--border-glass);
  border-radius: var(--radius-lg);
}

.ad-placeholder-content {
  color: var(--text-dim);
  font-size: 0.8rem;
}

/* ---- Footer ---- */
.footer {
  width: 100%;
  text-align: center;
  padding: 20px;
  color: var(--text-dim);
  font-size: 0.78rem;
}

/* ---- Responsive ---- */
@media (max-width: 380px) {
  .choice-btn {
    min-width: 65px;
    padding: 12px 8px;
  }

  .choice-icon {
    font-size: 1.6rem;
  }

  .arena-choice {
    width: 64px;
    height: 64px;
  }

  .arena-choice .choice-emoji {
    font-size: 1.8rem;
  }

  .mode-btn {
    font-size: 0.72rem;
    padding: 6px 2px;
  }
}

@media (min-width: 480px) {
  .choice-btn {
    min-width: 90px;
    padding: 20px 16px;
  }

  .choice-icon {
    font-size: 2.4rem;
  }

  .arena-choice {
    width: 96px;
    height: 96px;
  }

  .arena-choice .choice-emoji {
    font-size: 2.6rem;
  }
}

/* Scrollbar */
.history-list::-webkit-scrollbar {
  width: 4px;
}

.history-list::-webkit-scrollbar-track {
  background: transparent;
}

.history-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}
