/* Lingo2 - Global Styles (Mobile-First) */

@font-face {
  font-family: 'Gotham';
  src: url('../fonts/Gotham Medium.ttf');
}

/* CSS Variables */
:root {
  --lingo_red: #A52A2E;
  --lingo_blue: #8cc9ff;
  --lingo_yellow: #ffe84e;
  --lingo_dark: #2d2d2d;
  --transition: cubic-bezier(0.46, 0.03, 0.52, 0.96) 0.25s;
}

/* Reset & Base */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Gotham', Helvetica, Arial, sans-serif;
  background: linear-gradient(to bottom, var(--lingo_blue), #50abfb);
  min-height: 100vh;
  color: white;
  overflow-x: hidden;
}

/* Typography */
h1 {
  font-size: 1.75em;
  margin-bottom: 0.5em;
}

h2 {
  font-size: 1.5em;
  margin-bottom: 0.5em;
}

h3 {
  font-size: 1.25em;
}

p, label {
  font-size: 1.125em;
  margin-bottom: 0.5em;
}

/* Header/Topbar */
.topbar {
  background-color: #0000001a;
  height: 7.55vh;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2vw;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.topbar-left, .topbar-center, .topbar-right {
  flex: 1;
}

.topbar-center {
  text-align: center;
}

.topbar-right {
  text-align: right;
}

.logo {
  height: 5vh;
}

.title {
  font-size: 1.5em;
  margin: 0;
}

.user-info {
  font-size: 0.9em;
}

.username {
  margin-right: 1em;
}

.btn-logout {
  color: white;
  text-decoration: none;
  padding: 0.5em 1em;
  background-color: #00000020;
  border-radius: 4px;
  transition: var(--transition);
}

.btn-logout:hover {
  background-color: #00000040;
}

/* Main Page */
.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2vh 4vw;
  min-height: calc(100vh - 7.55vh - 60px);
}

/* Footer */
.footer {
  background-color: #00000020;
  text-align: center;
  padding: 1em;
  font-size: 0.9em;
}

.footer a {
  color: white;
  text-decoration: none;
  margin: 0 0.5em;
}

.footer a:hover {
  text-decoration: underline;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 1em 2em;
  font-size: 1.125em;
  font-family: 'Gotham', sans-serif;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: var(--transition);
  background-color: #00000020;
  color: white;
}

.btn:hover {
  background-color: #00000040;
  transform: translateY(-2px);
}

.btn-primary {
  background-color: var(--lingo_red);
}

.btn-primary:hover {
  background-color: #8a2327;
}

.btn-secondary {
  background-color: #1681C7;
}

.btn-secondary:hover {
  background-color: #125f93;
}

.btn-disabled, .btn:disabled {
  opacity: 0.33;
  cursor: not-allowed;
}

.btn-disabled:hover, .btn:disabled:hover {
  transform: none;
}

.btn-large {
  font-size: 1.5em;
  padding: 1.2em 2.5em;
  min-width: 60vw;
}

.btn-block {
  display: block;
  width: 100%;
}

/* Forms */
.form-group {
  margin-bottom: 1.5em;
}

.form-group label {
  display: block;
  margin-bottom: 0.5em;
  font-weight: bold;
}

.form-control {
  width: 100%;
  padding: 1em;
  font-size: 1.125em;
  font-family: 'Gotham', sans-serif;
  border: none;
  border-radius: 4px;
  background-color: #00000020;
  color: white;
  transition: var(--transition);
}

.form-control:focus {
  outline: none;
  background-color: #00000040;
}

.form-control::placeholder {
  color: #ffffff80;
}

.form-group small {
  display: block;
  margin-top: 0.3em;
  font-size: 0.9em;
  opacity: 0.8;
}

/* Flash Messages */
.flash-messages {
  position: fixed;
  top: 2vh;
  right: 2vw;
  z-index: 1000;
  max-width: 90vw;
}

.flash {
  padding: 1em 2em;
  margin-bottom: 0.5em;
  border-radius: 8px;
  background-color: #ffffff20;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  position: relative;
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.flash-success {
  border-left: 4px solid #28a745;
}

.flash-error {
  border-left: 4px solid #dc3545;
}

.flash-warning {
  border-left: 4px solid var(--lingo_yellow);
}

.flash-info {
  border-left: 4px solid #17a2b8;
}

.flash-close {
  position: absolute;
  top: 0.5em;
  right: 0.5em;
  background: none;
  border: none;
  color: white;
  font-size: 1.5em;
  cursor: pointer;
  padding: 0;
  width: auto;
  height: auto;
}

/* Containers */
.home-container,
.auth-container,
.menu-container,
.game-container,
.result-container,
.leaderboard-container,
.scores-container,
.cooldown-container {
  text-align: center;
}

.auth-box {
  max-width: 400px;
  margin: 5vh auto;
  padding: 2em;
  background-color: #ffffff10;
  border-radius: 12px;
  backdrop-filter: blur(10px);
}

.auth-title {
  margin-bottom: 1em;
}

.auth-link {
  margin-top: 1em;
  font-size: 0.9em;
}

.auth-link a {
  color: var(--lingo_yellow);
  text-decoration: none;
}

.auth-link a:hover {
  text-decoration: underline;
}

/* Home Page */
.home-logo img {
  max-width: 80vw;
  height: auto;
  margin-bottom: 2em;
}

.home-title {
  font-size: 2.5em;
  margin-bottom: 0.3em;
}

.home-subtitle {
  font-size: 1.3em;
  margin-bottom: 2em;
  opacity: 0.9;
}

.home-buttons {
  display: flex;
  flex-direction: column;
  gap: 1em;
  align-items: center;
  margin-bottom: 3em;
}

.home-info {
  margin-top: 1em;
  padding: 1em;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  color: white;
  font-size: 0.95em;
  max-width: 500px;
  text-align: center;
  backdrop-filter: blur(5px);
}

.home-info strong {
  color: var(--lingo_yellow);
}

.home-features {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5em;
  margin-top: 3em;
}

.feature {
  background-color: #ffffff10;
  padding: 1.5em;
  border-radius: 12px;
}

/* Responsive - Tablet and up (including iPad) */
@media (min-width: 768px) {
  .btn-large {
    min-width: 400px;
  }

  .home-features {
    grid-template-columns: repeat(3, 1fr);
  }

  .home-buttons {
    flex-direction: row;
    justify-content: center;
  }
}

/* Utility Classes */
.text-center {
  text-align: center;
}

.mt-1 { margin-top: 1em; }
.mt-2 { margin-top: 2em; }
.mb-1 { margin-bottom: 1em; }
.mb-2 { margin-bottom: 2em; }

.hidden {
  display: none;
}

.color-demo {
  display: inline-block;
  padding: 0.3em 0.8em;
  border-radius: 4px;
  font-weight: bold;
}

.color-R {
  background: linear-gradient(to bottom, #f78972, #95351e);
  color: white;
}

.color-B {
  background: linear-gradient(to bottom, #f9f97f, #ffd400);
  color: #2d2d2d;
}

.color-N {
  background: linear-gradient(to bottom, #11A7FF, #0065CF);
  color: white;
}

/* Menu Page Styles */
.menu-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 2em 1em;
}

.menu-title {
  font-size: 2.5em;
  margin-bottom: 1em;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* User Card */
.user-card {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  padding: 1.5em;
  border-radius: 16px;
  margin-bottom: 2em;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.user-card h2 {
  font-size: 1.8em;
  margin-bottom: 0.5em;
}

.user-level {
  font-size: 1.2em;
  margin-bottom: 1em;
  opacity: 0.9;
}

/* Lives Status */
.lives-status {
  margin-top: 1em;
  padding-top: 1em;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.lives-count {
  font-size: 1.3em;
}

.cooldown-warning {
  font-size: 1.2em;
  color: var(--lingo_yellow);
  margin-bottom: 0.5em;
}

.cooldown-time {
  font-size: 1.1em;
  opacity: 0.9;
}

/* Menu Actions */
.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 1em;
  margin-bottom: 3em;
  align-items: center;
}

.btn-play {
  background: linear-gradient(135deg, var(--lingo_red) 0%, #d63c3f 100%);
  box-shadow: 0 4px 15px rgba(165, 42, 46, 0.4);
  font-size: 1.4em;
  padding: 1em 2em;
}

.btn-play:hover {
  box-shadow: 0 6px 20px rgba(165, 42, 46, 0.6);
  transform: translateY(-3px);
}

/* Level Selection */
.level-selection {
  margin-top: 3em;
}

.level-selection h3 {
  font-size: 1.8em;
  margin-bottom: 1.5em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.levels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 1em;
  margin: 0 auto;
  max-width: 800px;
}

/* Level Card */
.level-card {
  aspect-ratio: 1;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.3s ease;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.1);
}

.level-card:not(.locked) {
  cursor: pointer;
}

.level-card:not(.locked):hover {
  transform: translateY(-5px) scale(1.05);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
  background: rgba(255, 255, 255, 0.2);
  border-color: var(--lingo_yellow);
}

.level-card.locked {
  opacity: 0.5;
  background: rgba(0, 0, 0, 0.3);
  cursor: not-allowed;
}

.level-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  text-decoration: none;
  color: white;
  position: relative;
}

.level-link::before {
  content: '🔓';
  position: absolute;
  top: 0.5em;
  right: 0.5em;
  font-size: 1.2em;
  opacity: 0.7;
}

.level-card.locked::before {
  content: '🔒';
  position: absolute;
  top: 0.5em;
  right: 0.5em;
  font-size: 1.2em;
  opacity: 0.8;
}

.level-number {
  font-size: 2em;
  font-weight: bold;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.level-badge {
  font-size: 0.7em;
  padding: 0.3em 0.8em;
  background: var(--lingo_yellow);
  color: var(--lingo_dark);
  border-radius: 12px;
  margin-top: 0.5em;
  font-weight: bold;
  text-transform: uppercase;
  position: absolute;
  bottom: 0.5em;
}

.level-badge.locked {
  background: rgba(0, 0, 0, 0.5);
  color: white;
  font-size: 1.2em;
  padding: 0;
  border-radius: 0;
  position: static;
  margin-top: 0.3em;
}

/* Responsive adjustments for levels grid */
@media (max-width: 480px) {
  .levels-grid {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.8em;
  }

  .level-number {
    font-size: 1.6em;
  }

  .level-badge {
    font-size: 0.6em;
    padding: 0.2em 0.6em;
  }
}

@media (min-width: 768px) {
  .menu-actions {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }

  .levels-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 1.2em;
  }
}

/* ========================================
   SCORES & LEADERBOARD STYLES
   ======================================== */

/* Leaderboard Container */
.leaderboard-container,
.scores-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2em 1em;
}

.leaderboard-subtitle,
.scores-subtitle {
  font-size: 1.2em;
  opacity: 0.8;
  margin-bottom: 2em;
}

/* Total Score Box (Mes Scores) */
.total-score-box {
  background: linear-gradient(135deg, rgba(255, 228, 78, 0.2) 0%, rgba(255, 212, 0, 0.1) 100%);
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 228, 78, 0.3);
  border-radius: 20px;
  padding: 2em;
  margin: 2em 0;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
  position: relative;
  overflow: hidden;
}

.total-score-box::before {
  content: '🏆';
  position: absolute;
  top: -20px;
  right: -20px;
  font-size: 10em;
  opacity: 0.1;
  transform: rotate(-15deg);
}

.total-score-box h2 {
  font-size: 1.5em;
  margin-bottom: 0.5em;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.total-score-box .score-total {
  font-size: 4em;
  font-weight: bold;
  color: var(--lingo_yellow);
  text-shadow: 0 0 30px rgba(255, 228, 78, 0.8),
               0 4px 10px rgba(0, 0, 0, 0.5);
  margin: 0.2em 0;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.total-score-box small {
  font-size: 0.9em;
  opacity: 0.7;
}

/* High Scores Section */
.high-scores-section {
  margin: 3em 0;
}

.high-scores-section h2 {
  font-size: 1.8em;
  margin-bottom: 1.5em;
  text-align: center;
}

.high-scores-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.2em;
  margin: 0 auto;
}

/* Score Card */
.score-card {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 1.5em;
  text-align: center;
  transition: all 0.3s ease;
  border: 2px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: hidden;
}

.score-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--lingo_yellow), var(--lingo_red));
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.score-card:hover {
  transform: translateY(-5px);
  border-color: var(--lingo_yellow);
  box-shadow: 0 8px 25px rgba(255, 228, 78, 0.3);
}

.score-card:hover::before {
  transform: scaleX(1);
}

.score-card.no-score {
  opacity: 0.5;
  background: rgba(0, 0, 0, 0.3);
}

.score-card .level-number {
  font-size: 1.2em;
  margin-bottom: 0.5em;
  color: var(--lingo_blue);
}

.score-card .score-value {
  font-size: 2.5em;
  font-weight: bold;
  color: var(--lingo_yellow);
  margin: 0.3em 0;
  text-shadow: 0 2px 10px rgba(255, 228, 78, 0.5);
}

.score-card .score-details {
  font-size: 0.75em;
  opacity: 0.7;
  margin-top: 0.5em;
}

.score-card .no-score-text {
  font-size: 1em;
  opacity: 0.6;
  font-style: italic;
}

/* Recent Scores Section */
.recent-scores-section {
  margin: 3em 0;
}

.recent-scores-section h2 {
  font-size: 1.8em;
  margin-bottom: 1.5em;
  text-align: center;
}

/* Leaderboard Table */
.leaderboard-table-container {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 1.5em;
  margin: 2em 0;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
  overflow-x: auto;
}

.leaderboard-table,
.scores-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: transparent;
}

.leaderboard-table thead,
.scores-table thead {
  background: rgba(255, 255, 255, 0.1);
}

.leaderboard-table th,
.scores-table th {
  padding: 1em;
  text-align: left;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.9em;
  border-bottom: 2px solid rgba(255, 255, 255, 0.2);
}

.leaderboard-table td,
.scores-table td {
  padding: 1em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.leaderboard-table tbody tr,
.scores-table tbody tr {
  transition: all 0.3s ease;
}

.leaderboard-table tbody tr:hover,
.scores-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateX(5px);
}

/* Rank Cell */
.rank-cell {
  font-size: 1.5em;
  font-weight: bold;
  text-align: center;
  width: 80px;
}

/* Username Cell */
.username-cell {
  font-size: 1.2em;
  font-weight: 500;
}

/* Score Cell */
.score-cell {
  font-size: 1.3em;
  font-weight: bold;
  color: var(--lingo_yellow);
  text-align: right;
  text-shadow: 0 2px 8px rgba(255, 228, 78, 0.4);
}

/* Highlight Row (current user) */
.highlight-row {
  background: linear-gradient(90deg, rgba(255, 228, 78, 0.2), rgba(255, 228, 78, 0.05)) !important;
  border-left: 4px solid var(--lingo_yellow);
  font-weight: bold;
}

.highlight-row:hover {
  background: linear-gradient(90deg, rgba(255, 228, 78, 0.3), rgba(255, 228, 78, 0.1)) !important;
}

/* Highscore Row */
.highscore-row {
  background: rgba(255, 228, 78, 0.1);
  font-weight: bold;
}

.highscore-row:hover {
  background: rgba(255, 228, 78, 0.15);
}

/* No Data */
.no-data {
  text-align: center !important;
  padding: 2em !important;
  font-style: italic;
  opacity: 0.6;
}

/* Actions */
.leaderboard-actions,
.scores-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1em;
  justify-content: center;
  margin-top: 3em;
}

/* Victory/Result Page Score Box Enhancement */
.result-container .score-box {
  background: linear-gradient(135deg, rgba(255, 228, 78, 0.2) 0%, rgba(255, 212, 0, 0.1) 100%);
  backdrop-filter: blur(15px);
  border: 2px solid rgba(255, 228, 78, 0.3);
  border-radius: 20px;
  padding: 2em;
  margin: 2em auto;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
  position: relative;
  overflow: hidden;
  max-width: 500px;
}

.result-container .score-box::before {
  content: '✨';
  position: absolute;
  top: -10px;
  right: -10px;
  font-size: 8em;
  opacity: 0.1;
}

.result-container .score-box h2 {
  font-size: 1.5em;
  margin-bottom: 0.5em;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.result-container .score-box .score-total {
  font-size: 4em;
  font-weight: bold;
  color: var(--lingo_yellow);
  text-shadow: 0 0 30px rgba(255, 228, 78, 0.8),
               0 4px 10px rgba(0, 0, 0, 0.5);
  margin: 0.3em 0;
  animation: scoreReveal 0.8s ease-out;
}

@keyframes scoreReveal {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }
  60% {
    transform: scale(1.1);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.result-container .score-box .score-details {
  margin-top: 1em;
  padding-top: 1em;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.result-container .score-box .score-details p {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0.5em 0;
  font-size: 1em;
  padding: 0.3em 0;
}

.result-container .score-box .score-details p::before {
  content: '▸';
  color: var(--lingo_yellow);
  margin-right: 0.5em;
}

/* Responsive - Scores */
@media (max-width: 768px) {
  .high-scores-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1em;
  }

  .score-card .score-value {
    font-size: 2em;
  }

  .total-score-box .score-total {
    font-size: 3em;
  }

  .result-container .score-box .score-total {
    font-size: 3em;
  }

  .leaderboard-table-container {
    padding: 1em;
  }

  .rank-cell {
    font-size: 1.2em;
    width: 60px;
  }

  .username-cell {
    font-size: 1em;
  }

  .score-cell {
    font-size: 1.1em;
  }
}

@media (max-width: 480px) {
  .high-scores-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.8em;
  }

  .score-card {
    padding: 1em;
  }

  .score-card .level-number {
    font-size: 1em;
  }

  .score-card .score-value {
    font-size: 1.8em;
  }

  .total-score-box {
    padding: 1.5em;
  }

  .total-score-box .score-total {
    font-size: 2.5em;
  }
}
