@import url('https://fonts.googleapis.com/css2?family=Exo+2:wght@400;600;700&display=swap');

/* ============================================
   CSS Variables for Easy Theming
   ============================================ */
:root {
  --color-primary: #f460ff;
  --color-accent: #9e21a1;
  --color-link: #171daf;
  --color-link-hover: #0092ff;
  --color-bg: #000;
  --color-white: #fff;
  --color-border: #fff;
  --color-border-hover: #999;
  --color-border-active: #8c8c8c;
  --font-main: 'Exo 2', sans-serif;
  --transition-speed: 0.3s;
}

/* ============================================
   Base Styles
   ============================================ */
html {
  height: 100%;
  background-color: var(--color-bg);
}

body {
  margin: 0;
  min-height: 100%;
  background-color: var(--color-bg);
  background-image: radial-gradient(ellipse at center, #0a0a1a 0%, #000 70%);
  cursor: pointer !important;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  font-family: var(--font-main);
  font-weight: 400;
}

/* ============================================
   Slider Styles
   ============================================ */
#slider {
  display: none !important;
  /* Hide old slider */
}

#slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-primary);
  cursor: pointer !important;
}

#slider::-moz-range-thumb {
  border: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-primary);
  cursor: pointer !important;
}

/* ============================================
   UI Elements
   ============================================ */
#PressKey {
  font-family: var(--font-main);
  font-weight: 600;
  color: var(--color-accent) !important;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-shadow: 0 0 10px rgba(158, 33, 161, 0.5);
}

#zom {
  display: none !important;
  /* Hide old zoom display */
}

#best {
  font-family: var(--font-main);
  font-weight: 700;
  letter-spacing: 1px;
}

/* ============================================
   Game Buttons (shared styles)
   ============================================ */
.game-btn {
  width: 200px;
  outline: none;
  font-family: var(--font-main);
  font-size: 15px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 8px 12px;
  margin-left: 2px;

  /* Modern Styling */
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border: 2px solid var(--color-accent);
  border-radius: 8px;
  color: #fff;

  transition: all 0.2s ease;
  cursor: pointer;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.game-btn:hover {
  background: linear-gradient(135deg, #2a2a4e 0%, #26315e 100%);
  border-color: var(--color-primary);
  color: #fff;
  box-shadow: 0 0 15px rgba(244, 96, 255, 0.4);
  transform: translateY(-2px);
}

.game-btn:active {
  transform: translateY(1px);
  box-shadow: 0 0 5px rgba(244, 96, 255, 0.4);
  color: #ddd;
}

#switch {
  margin-top: 5px;
}

/* ============================================
   Links
   ============================================ */
#patr {
  color: var(--color-link);
  text-decoration: none;
  font-size: 15px;
}

#patr:hover,
#patrLink:hover {
  color: var(--color-link-hover);
}

/* ============================================
   Settings License Link
   ============================================ */
.settings-license {
  text-align: center;
  margin-top: 15px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-license a {
  color: #666;
  text-decoration: none;
  font-size: 11px;
  font-family: var(--font-main);
  transition: color 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.settings-license a:hover {
  color: var(--color-primary);
}

/* ============================================
   Top-Right Control Group Container
   ============================================ */
.top-controls {
  position: fixed;
  top: 10px;
  right: 15px;
  z-index: 100;
  display: flex;
  flex-direction: row-reverse;
  /* Reverse order: icons appear on left, login on right */
  gap: 8px;
  align-items: center;
}

/* Reset positioning for buttons inside container */
.top-controls .game-btn {
  position: relative;
  top: auto;
  right: auto;
  left: auto;
}

/* Icon buttons (Settings, Leaderboard) */
.top-controls .icon-btn {
  min-width: 44px !important;
  width: 44px !important;
  height: 40px;
  padding: 0 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

/* Auth/Login button */
.auth-btn {
  min-width: 100px;
  height: 40px;
  padding: 0 16px !important;
  display: flex;
  align-items: center;
  justify-content: center;
}


/* Logged in state inherits standard button style but could be customized here if needed */
.auth-btn.logged-in {
  border-color: var(--color-primary);
  box-shadow: 0 0 10px rgba(244, 96, 255, 0.2);
}

.auth-btn .user-icon {
  margin-right: 4px;
}

/* Rank #1 Gold Glow Effect */
.auth-btn.rank-one {
  border-color: #ffd700 !important;
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.5), 0 0 30px rgba(255, 215, 0, 0.3) !important;
}

.auth-btn.rank-one .username-text {
  color: #ffd700;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.8), 0 0 20px rgba(255, 215, 0, 0.5);
  animation: goldGlow 2s ease-in-out infinite;
}

@keyframes goldGlow {

  0%,
  100% {
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.8), 0 0 20px rgba(255, 215, 0, 0.5);
  }

  50% {
    text-shadow: 0 0 15px rgba(255, 215, 0, 1), 0 0 30px rgba(255, 215, 0, 0.8), 0 0 40px rgba(255, 200, 0, 0.4);
  }
}

/* ============================================
   Auth Modal
   ============================================ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(5px);
}

.modal-content {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border: 2px solid var(--color-primary);
  border-radius: 12px;
  padding: 30px;
  width: 90%;
  max-width: 360px;
  position: relative;
  box-shadow: 0 0 30px rgba(244, 96, 255, 0.3);
  animation: modalSlideIn 0.3s ease-out;
}

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

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 15px;
  background: none;
  border: none;
  color: #888;
  font-size: 28px;
  cursor: pointer;
  transition: color 0.2s;
  line-height: 1;
}

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

.modal-content h2 {
  color: var(--color-primary);
  text-align: center;
  margin: 0 0 25px 0;
  font-family: var(--font-main);
  font-size: 24px;
}

/* ============================================
   Auth Form
   ============================================ */
.form-field {
  margin-bottom: 18px;
}

.form-field.hidden {
  display: none;
}

.form-field label {
  display: block;
  color: #aaa;
  margin-bottom: 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.form-field input {
  width: 100%;
  padding: 12px 15px;
  border: 2px solid #333;
  border-radius: 6px;
  background: #0d0d1a;
  color: white;
  font-size: 16px;
  font-family: var(--font-main);
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

.form-field input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 10px rgba(244, 96, 255, 0.2);
}

.form-field input::placeholder {
  color: #555;
}

.auth-error {
  background: rgba(220, 53, 69, 0.2);
  border: 1px solid #dc3545;
  color: #ff6b7a;
  padding: 10px 15px;
  border-radius: 6px;
  margin-bottom: 15px;
  font-size: 14px;
  text-align: center;
}

.auth-success {
  background: rgba(40, 167, 69, 0.2);
  border: 1px solid #28a745;
  color: #5dd879;
  padding: 10px 15px;
  border-radius: 6px;
  margin-bottom: 15px;
  font-size: 14px;
  text-align: center;
}

.hidden {
  display: none !important;
}

.auth-submit {
  width: 100%;
  padding: 14px !important;
  font-size: 16px !important;
  margin-top: 10px;
}

.auth-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.auth-switch {
  text-align: center;
  margin-top: 20px;
  color: #888;
  font-size: 14px;
}

.switch-btn {
  background: none;
  border: none;
  color: var(--color-primary);
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 14px;
  text-decoration: underline;
  padding: 5px;
}

.switch-btn:hover {
  color: var(--color-link-hover);
}

/* ============================================
   User Menu (dropdown)
   ============================================ */
.user-menu {
  position: fixed;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border: 2px solid var(--color-accent);
  border-radius: 8px;
  padding: 10px 0;
  min-width: 150px;
  z-index: 101;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
  animation: menuFadeIn 0.2s ease-out;
}

@keyframes menuFadeIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.user-menu-header {
  padding: 10px 15px;
  border-bottom: 1px solid #333;
  margin-bottom: 5px;
}

.user-menu-header .username {
  color: var(--color-primary);
  font-weight: bold;
}

.user-menu-item {
  display: block;
  width: 100%;
  padding: 10px 15px;
  background: none;
  border: none;
  color: white;
  text-align: left;
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 14px;
  transition: background 0.2s;
}

.user-menu-item:hover {
  background: rgba(244, 96, 255, 0.1);
}

/* ============================================
   Local Records Button
   ============================================ */
.local-records-btn {
  position: fixed;
  top: 100px;
  right: 10px;
  z-index: 100;
  min-width: 100px;
  padding: 8px 16px !important;
}

/* ============================================
   Local Records Panel
   ============================================ */
.local-records-panel {
  position: fixed;
  top: 145px;
  right: 10px;
  width: 220px;
  max-height: 50vh;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border: 2px solid var(--color-primary);
  border-radius: 12px;
  z-index: 98;
  overflow: hidden;
  box-shadow: 0 0 30px rgba(244, 96, 255, 0.3), 0 5px 20px rgba(0, 0, 0, 0.5);
  animation: panelSlideIn 0.3s ease-out;
}

/* ============================================
   Game Stats Labels
   ============================================ */
.time-label,
.score-label {
  font-size: 12px;
  letter-spacing: 2px;
  opacity: 0.7;
  text-transform: uppercase;
  font-weight: 600;
}

.lr-header {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px 15px;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid #333;
}

.lr-header h3 {
  margin: 0;
  color: #a0aec0;
  font-size: 14px;
  font-family: var(--font-main);
}

.lr-mode-title {
  text-align: center;
  padding: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--color-primary);
  font-size: 12px;
  font-family: var(--font-main);
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 1px solid #333;
}

.lr-content {
  max-height: 280px;
  overflow-y: auto;
  padding: 8px 0;
}

.lr-empty {
  text-align: center;
  color: #666;
  padding: 20px 15px;
  font-size: 13px;
}

.lr-entry {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  transition: background 0.2s;
}

.lr-entry:hover {
  background: rgba(255, 255, 255, 0.05);
}

.lr-entry.best {
  background: rgba(244, 96, 255, 0.1);
  border-left: 3px solid var(--color-primary);
}

.lr-rank {
  width: 30px;
  color: #718096;
  font-weight: bold;
  font-size: 12px;
}

.lr-entry.best .lr-rank {
  color: #ffd700;
}

.lr-score {
  flex: 1;
  color: white;
  font-size: 14px;
  font-weight: bold;
}

.lr-date {
  color: #666;
  font-size: 11px;
}

/* Leaderboard Button - positioned by .top-controls container */

/* ============================================
   Leaderboard Panel (Right Side)
   ============================================ */
.leaderboard-panel {
  position: fixed;
  top: 60px;
  right: 15px;
  box-sizing: border-box;
  /* Width spans from settings button to login button */
  width: 308px;
  max-height: 50vh;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border: 2px solid var(--color-primary);
  border-radius: 12px;
  z-index: 99;
  overflow: hidden;
  box-shadow: 0 0 30px rgba(244, 96, 255, 0.3), 0 5px 20px rgba(0, 0, 0, 0.5);
  animation: panelSlideIn 0.3s ease-out;
}

@keyframes panelSlideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.lb-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 15px;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid #333;
}

.lb-header h3 {
  margin: 0;
  color: var(--color-primary);
  font-size: 16px;
  font-family: var(--font-main);
}

.lb-close {
  background: none;
  border: none;
  color: #888;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.lb-close:hover {
  color: var(--color-primary);
}

.lb-controls {
  background: rgba(0, 0, 0, 0.1);
  border-bottom: 1px solid #333;
}

.lb-tabs {
  display: flex;
  border-bottom: 1px solid #333;
}

.lb-tab {
  flex: 1;
  padding: 8px;
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 13px;
  transition: all 0.2s;
  text-transform: uppercase;
}

.lb-tab:hover {
  color: white;
  background: rgba(255, 255, 255, 0.05);
}

.lb-tab.active {
  color: var(--color-primary);
  background: rgba(244, 96, 255, 0.1);
  border-bottom: 2px solid var(--color-primary);
}

.lb-source-switch {
  display: flex;
  justify-content: center;
  padding: 5px;
}

.lb-source-btn {
  background: none;
  border: 1px solid #444;
  color: #888;
  padding: 4px 12px;
  font-size: 11px;
  font-family: var(--font-main);
  cursor: pointer;
  margin: 0 2px;
  border-radius: 4px;
  text-transform: uppercase;
}

.lb-source-btn.active {
  background: var(--color-primary);
  color: black;
  border-color: var(--color-primary);
  font-weight: bold;
}

.lb-content {
  max-height: 350px;
  overflow-y: auto;
  padding: 10px 0;
}

.lb-loading,
.lb-message {
  text-align: center;
  color: #888;
  padding: 30px 15px;
  font-size: 14px;
}

.lb-entry {
  display: flex;
  align-items: center;
  padding: 10px 15px;
  transition: background 0.2s;
}

.lb-entry:hover {
  background: rgba(255, 255, 255, 0.05);
}

.lb-entry.current-user {
  background: rgba(244, 96, 255, 0.15);
  border-left: 3px solid var(--color-primary);
}

.lb-rank {
  width: 35px;
  color: var(--color-accent);
  font-weight: bold;
  font-size: 14px;
}

.lb-entry:nth-child(1) .lb-rank {
  color: #ffd700;
}

.lb-entry:nth-child(2) .lb-rank {
  color: #c0c0c0;
}

.lb-entry:nth-child(3) .lb-rank {
  color: #cd7f32;
}

.lb-name {
  flex: 1;
  color: white;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-score {
  color: var(--color-primary);
  font-weight: bold;
  font-size: 14px;
  margin-left: 10px;
}

.lb-user-rank {
  border-top: 1px solid #333;
  padding: 12px 15px;
  background: rgba(0, 0, 0, 0.2);
}

.lb-user-entry {
  color: #aaa;
  font-size: 13px;
  text-align: center;
}

.lb-user-entry strong {
  color: var(--color-primary);
}

/* ============================================
   Scrollbar Styling
   ============================================ */
.lb-content::-webkit-scrollbar {
  width: 6px;
}

.lb-content::-webkit-scrollbar-track {
  background: transparent;
}

.lb-content::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 3px;
}

.lb-content::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* ============================================
   Responsive Adjustments
   ============================================ */
@media (max-width: 600px) {

  .auth-btn,
  .leaderboard-btn {
    font-size: 12px !important;
    padding: 6px 12px !important;
    min-width: 80px;
  }

  .leaderboard-panel {
    width: calc(100% - 20px);
    left: 10px;
    right: 10px;
  }

  .modal-content {
    padding: 20px;
  }
}

/* Settings Button - positioned by .top-controls container */

/* ============================================
   Game Container Glow Effect
   ============================================ */
#basis {
  box-shadow:
    0 0 40px rgba(244, 96, 255, 0.15),
    0 0 80px rgba(158, 33, 161, 0.1),
    inset 0 0 0 1px rgba(244, 96, 255, 0.2);
  /* Border effect using inset shadow */
  border-radius: 4px;
}

/* ============================================
   Settings Modal (Centered)
   ============================================ */
.settings-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  /* Highest priority */
  backdrop-filter: blur(5px);
  display: none;
  /* Hidden by default */
}

.settings-panel {
  position: relative;
  /* Relative to overlay */
  top: auto;
  right: auto;
  left: auto;
  width: 300px;
  /* Slightly wider */
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border: 2px solid var(--color-accent);
  border-radius: 12px;
  box-shadow: 0 0 30px rgba(244, 96, 255, 0.3);
  animation: modalSlideIn 0.3s ease-out;
  display: block;
  /* Always block inside the flex overlay */
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 15px;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid #333;
}

.settings-header h3 {
  margin: 0;
  color: var(--color-primary);
  font-size: 16px;
  font-family: var(--font-main);
}

.settings-close {
  background: none;
  border: none;
  color: #888;
  font-size: 20px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.settings-close:hover {
  color: var(--color-primary);
}

.settings-content {
  padding: 15px;
}

.settings-row {
  margin-bottom: 20px;
}

.settings-row:last-child {
  margin-bottom: 5px;
}

.settings-label {
  display: block;
  color: #aaa;
  font-size: 12px;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Custom Range Input for Volume and Zoom */
.volume-slider,
.zoom-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: #333;
  outline: none;
  opacity: 0.9;
  transition: opacity .2s;
}

.volume-slider:hover,
.zoom-slider:hover {
  opacity: 1;
}

.volume-slider::-webkit-slider-thumb,
.zoom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-primary);
  cursor: pointer;
  box-shadow: 0 0 10px rgba(244, 96, 255, 0.5);
}

.volume-slider::-moz-range-thumb,
.zoom-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-primary);
  cursor: pointer;
  border: none;
  box-shadow: 0 0 10px rgba(244, 96, 255, 0.5);
}

/* Custom Select for Sound */
.sound-select {
  width: 100%;
  padding: 8px;
  background: #0d0d1a;
  border: 1px solid #444;
  border-radius: 4px;
  color: white;
  font-family: var(--font-main);
  font-size: 14px;
  outline: none;
}

.sound-select:focus {
  border-color: var(--color-primary);
}

@media (max-width: 600px) {
  .settings-panel {
    width: 90%;
  }

}