/* Box sizing + font smoothing */
* { box-sizing: border-box; }
html, body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  font-family: 'Kanit', sans-serif;
  background: #f6f4ef;
  margin: 0;
  color: #000;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Dark mode styles - BLACK THEME */
body.dark-mode {
  background: #13141c;
  color: #e0e0e0;
}

.page-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 3rem;
  /* padding: 1rem; */
  /* min-height: calc(100vh - 80px); */
}

.signin-container {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  padding: 2rem;
  border-radius: 10px;
  box-shadow: 0 6px 15px rgba(0,0,0,0.08);
  width: 350px;
  transition: all 0.3s ease;
}

body.dark-mode .signin-container {
  background: #2f3247;
  border-color: #333;
  box-shadow: 0 6px 15px rgba(0,0,0,0.4);
}

.title {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: #000;
  transition: color 0.3s ease;
}

body.dark-mode .title {
  color: #e0e0e0;
}

.form-group {
  margin-bottom: 1.2rem;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: #000;
  transition: color 0.3s ease;
}

body.dark-mode label {
  color: #e0e0e0;
}

input {
  width: 100%;
  padding: 0.7rem 1rem;
  border: 1px solid #000;
  border-radius: 7px;
  font-size: 0.9rem;
  outline: none;
  transition: all 0.3s ease;
  background: #fff;
  color: #333;
}

body.dark-mode input {
  background: #1a1a2e;
  border-color: #333;
  color: #e0e0e0;
}

input:focus {
  border-color: #000;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.2);
}

body.dark-mode input:focus {
  border-color: #1a1a2e;
  box-shadow: 0 0 0 3px rgba(224,224,224,0.1);
}

.btn-submit {
  width: 100%;
  padding: 0.5rem;
  background: #e5bb22;
  color: #000;
  font-size: 1rem;
  font-family: 'Kanit', sans-serif;
  font-weight: 600;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.3s ease;
}

body.dark-mode .btn-submit {
  background: #fffbf5;
  color: #1a1a2e;
}

.btn-submit:hover {
  background: #b98d25;
}

body.dark-mode .btn-submit:hover {
  background: #8f8f8f;
}

.error {
  margin-top: 1rem;
  color: #dc2626;
  font-weight: 600;
  text-align: center;
  transition: color 0.3s ease;
}

body.dark-mode .error {
  color: #f87171;
}

.extra-links {
  margin-top: 1.5rem;
  text-align: center;
}

.extra-links p {
  margin: 0.5rem 0;
  font-size: 0.9rem;
  color: #000;
  transition: color 0.3s ease;
}

body.dark-mode .extra-links p {
  color: #e0e0e0;
}

.extra-links a {
  color: #000;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.3s ease;
}

body.dark-mode .extra-links a {
  color: #e0e0e0;
}

body.dark-mode .extra-links a:hover {
  color: #60a5fa;
}

/* Responsive design */
@media (max-width: 700px) {
  .page-wrapper {
    margin-top: 3rem;
    padding: 1rem;
  }
  
  .signin-container {
    width: 100%;
    max-width: 350px;
    padding: 1.5rem;
  }
  
  .title {
    font-size: 1.4rem;
  }
}

/* Header with icon */
.how-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.8rem;
}

.how-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
  color: inherit;
}

/* Question mark icon */
.help-icon {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  font-weight: 700;
  color: #000;
  font-size: 1.3rem;
  flex-shrink: 0;
}

body.dark-mode .help-icon {
  border-color: #e0e0e0;
  color: #e0e0e0;
}

/* List styling */
.how-list {
  margin: 0;
  padding-left: 1.25rem;
  list-style: disc;
  color: inherit;
  font-size: 0.95rem;
  line-height: 1.5rem;
}
.how-list li { margin-bottom: 0.5rem; }

/* Points System Styling in How to Play */
.points-system {
  margin-top: 1rem;
  padding: 1rem;
  background: rgba(100, 182, 171, 0.1);
  border-radius: 8px;
  border: 1px solid rgba(100, 182, 171, 0.3);
}

body.dark-mode .points-system {
  background: rgba(100, 182, 171, 0.15);
  border-color: rgba(100, 182, 171, 0.4);
}

.points-section {
  margin-bottom: 1.2rem;
}

.points-section:last-child {
  margin-bottom: 0;
}

.points-section h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 0.5rem 0;
  color: #000;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

body.dark-mode .points-section h3 {
  color: #e0e0e0;
}

.points-section ul {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.85rem;
}

.points-section li {
  margin-bottom: 0.3rem;
  line-height: 1.4;
  color: #000;
}

body.dark-mode .points-section li {
  color: #e0e0e0;
}

.points-section strong {
  color: #1c9c8b;
  font-weight: 700;
}

body.dark-mode .points-section strong {
  color: #4ecdc4;
}

.points-note {
  margin-top: 1rem;
  padding: 0.8rem;
  background: rgba(233, 194, 87, 0.1);
  border-radius: 6px;
  border-left: 3px solid #e9c257;
  font-size: 0.85rem;
  line-height: 1.4;
}

body.dark-mode .points-note {
  background: rgba(233, 194, 87, 0.15);
  border-left-color: #e9c257;
}

.points-note p {
  margin: 0;
  color: #000;
}

body.dark-mode .points-note p {
  color: #e0e0e0;
}

.points-note strong {
  color: #e9c257;
}

body.dark-mode .points-note strong {
  color: #ffd700;
}

/* Bonus description styling */
.bonus-description {
  font-size: 0.85rem;
  margin: 0.5rem;
  color: #000;
  line-height: 1.3;
}

body.dark-mode .bonus-description {
  color: #e0e0e0;
}

/* Responsive design */
@media (max-width: 600px) {
  .points-section h3 {
    font-size: 0.9rem;
  }
  
  .points-section ul {
    font-size: 0.8rem;
  }
  
  .points-note {
    font-size: 0.8rem;
    padding: 0.6rem;
  }
}

/* hidden class */
.hidden { display: none !important; }

/* Modal Styles */
.modal {
  position: fixed;
  top: 0; left: 0;
  width: 100%; 
  height: 100%;
  background: rgba(0,0,0,0.5);
  font-size: 0.96rem;
  line-height: 1.5rem;
  padding: 1.2rem 1.15rem;
  border-radius: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}
.modal.hidden { 
  display: none; 
}

/* prevents body to scroll when modal is open */
body:has(.modal:not(.hidden)) {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
}

.modal-content {
  background: #f6f4ef;
  color: #000;
  padding: 1.5rem;
  border-radius: 15px;
  max-width: 500px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 6px 18px rgba(0,0,0,0.2);
  position: relative;
}

body.dark-mode .modal-content {
  background: #3a3d52;
  border-color: #e0e0e0;
  color: #e0e0e0;
  box-shadow: 0 6px 18px rgba(0,0,0,0.6);
}

.close-btn, .close-hint-btn {
  position: absolute;
  top: 0.25rem;
  right: 1rem;
  font-size: 2rem;
  font-weight: bold;
  color: #333;
  cursor: pointer;
}

body.dark-mode .close-btn,
body.dark-mode .close-hint-btn {
  color: #e0e0e0;
}

.close-btn:hover { 
  color: #666; 
}

body.dark-mode .close-btn:hover,
body.dark-mode .close-hint-btn:hover {
  color: #ffffff;
}

/* STATS modal - Clean Design */
.stats-modal-title {
  text-align: center;
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: inherit;
}

.stats-grid-modal {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 0.6rem;
  margin: 0 auto;
}

.stat-box {
  border-radius: 8px;
  /* padding: 0.8rem 0.3rem; */
  border: 2px solid #000;
  text-align: center;
  color: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  min-height: 70px;
}

.stat-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
}

.stat-box:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

body.dark-mode .stat-box {
  background: #2d2d44;
  color: #e0e0e0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  border: 1px solid #fff;
}

body.dark-mode .stat-box:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.stat-box h3 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 0.2rem;
}

.stat-box p {
  margin: 0;
  font-size: 0.7rem;
  color: #000;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

body.dark-mode .stat-box p {
  color: #a0a0a0;
}

/* Stats summary section */
.stats-summary {
  margin-top: 1rem;
  padding: 1rem;
  background: #ffffff;
  border-radius: 8px;
  text-align: center;
  border: 2px solid #000;
}

body.dark-mode .stats-summary {
  background: #2d2d44;
  border: 1px solid #fff;
}

.stats-summary h4 {
  margin: 0 0 0.5rem 0;
  font-size: 0.9rem;
  font-weight: 900;
  color: #000;
}

body.dark-mode .stats-summary h4 {
  color: #e0e0e0;
}

.stats-summary p {
  margin: 0.3rem 0;
  font-size: 0.75rem;
  color: #000;
  font-weight: 500;
}

body.dark-mode .stats-summary p {
  color: #a0a0a0;
}

.win-rate {
  font-size: 0.8rem !important;
  font-weight: 700 !important;
  color: #64b6ab !important;
}

.giveup-rate {
  font-size: 0.8rem !important;
  font-weight: 700 !important;
  color: #b67764 !important;
}

body.dark-mode .win-rate {
  color: #4ade80 !important;
}

/* Stats Sign-in Prompt Styles */
.stats-signin-prompt {
  text-align: center;
  max-width: 400px;
  margin: 0 auto;
}

.signin-icon {
  font-size: 3rem;
  color: #6b7280;
  margin-bottom: 1rem;
}

body.dark-mode .signin-icon {
  color: #9ca3af;
}

.stats-signin-prompt h3 {
  font-size: 1.3rem;
  font-weight: 700;
  color: #000;
  margin-bottom: 1rem;
}

body.dark-mode .stats-signin-prompt h3 {
  color: #e0e0e0;
}

.stats-signin-prompt p {
  color: #6b7280;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

body.dark-mode .stats-signin-prompt p {
  color: #9ca3af;
}

.stats-signin-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: #e9c257;
  color: #000;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  transition: all 0.2s ease-in-out;
  margin-bottom: 1.5rem;
}

body.dark-mode .stats-signin-btn {
  background: #e0e0e0;
  color: #1a1a2e;
}

.stats-signin-btn:hover {
  background: #b69949;
}

body.dark-mode .stats-signin-btn:hover {
  background: #a19e9e;
}

.signin-note {
  font-size: 0.875rem;
  color: #6b7280;
  margin-bottom: 0;
}

body.dark-mode .signin-note {
  color: #9ca3af;
}

.signup-link {
  color: #000;
  text-decoration: underline;
  font-weight: 600;
}

body.dark-mode .signup-link {
  color: #e0e0e0;
}

.signup-link:hover {
  color: #333;
}

body.dark-mode .signup-link:hover {
  color: #a19e9e;
}

/* Stats Error Styles */
.stats-error {
  text-align: center;
  padding: 2rem;
  color: #b91c1c;
}

body.dark-mode .stats-error {
  color: #fca5a5;
}

.stats-error i {
  font-size: 2rem;
  margin-bottom: 1rem;
}

.stats-error h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.stats-error p {
  color: #6b7280;
}

body.dark-mode .stats-error p {
  color: #9ca3af;
}

@media (max-width: 600px) {
  .stats-grid-modal { 
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 0.5rem;
  }
  
  .stat-box {
    padding: 0.6rem 0.2rem;
    min-height: 60px;
  }
  
  .stat-box h3 {
    font-size: 1rem;
  }
  
  .stats-modal-title {
    font-size: 1.1rem;
    margin-bottom: 0.8rem;
  }
  
  .stats-summary {
    padding: 0.8rem;
    margin-top: 0.8rem;
  }
  
  .stats-summary h4 {
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
  }
  
  .stats-summary p {
    font-size: 0.7rem;
    margin: 0.2rem 0;
  }

  .modal {
    padding: 0;
  }
}

/* leaderboard modal */
.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.65rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  overflow: hidden;
}

body.dark-mode .leaderboard-table {
  box-shadow: 0 1px 3px rgba(255, 255, 255, 0.1);
}

.leaderboard-table thead {
  background-color: #facb1c;
  border-bottom: 2px solid #e2e8f0;
}

body.dark-mode .leaderboard-table thead {
  background-color: #2f3247;
  border-bottom-color: #333;
}

.leaderboard-table th {
  padding: 1rem 0.75rem;
  text-align: center;
  font-weight: 600;
  color: #374151;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

body.dark-mode .leaderboard-table th {
  color: #e0e0e0;
}

.leaderboard-table td {
  padding: 1rem 0.75rem;
  border-bottom: 1px solid #f1f5f9;
  transition: background-color 0.2s ease;
  font-size: 0.85rem;
  text-align: center;
}

body.dark-mode .leaderboard-table td {
  border-bottom-color: #333;
}

.leaderboard-table tbody tr:hover {
  background-color: #f8fafc;
}

body.dark-mode .leaderboard-table tbody tr:hover {
  background-color: #2f3247;
}

.leaderboard-table tbody tr:last-child td {
  border-bottom: none;
}

/* Loading and error states */
.leaderboard-loading {
  text-align: center;
  padding: 3rem;
  color: #6b7280;
  font-style: italic;
}

body.dark-mode .leaderboard-loading {
  color: #888;
}

.leaderboard-error {
  text-align: center;
  padding: 3rem;
  color: #dc2626;
  background-color: #fef2f2;
  border-radius: 8px;
  margin: 1rem 0;
}

body.dark-mode .leaderboard-error {
  color: #f87171;
  background-color: #3a3a52;
}

.leaderboard-empty {
  text-align: center;
  padding: 3rem;
  color: #6b7280;
  background-color: #f9fafb;
  border-radius: 8px;
  margin: 1rem 0;
}

body.dark-mode .leaderboard-empty {
  color: #888;
  background-color: #2d2d44;
}

/* Responsive design */
@media (max-width: 600px) {
  .leaderboard-table {
    font-size: 0.8rem;
  }
  
  .leaderboard-table th,
  .leaderboard-table td {
    padding: 0.75rem 0.5rem;
    font-size: 0.75rem;
  }
}

/* profile modal logout button */
.logout-btn {
  padding: 0.5rem 0.7rem;
  font-size: 0.95rem;
  margin-top: 0.5rem;
  font-weight: 600;
  font-family: 'Kanit', sans-serif;
  background: #e9c257;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  color: #000;
  transition: background 0.2s ease;
}

.logout-btn:hover {
  background: #b98d25;
}

body.dark-mode .logout-btn {
  background: #e0e0e0;
  color: #2d2d44;
}

body.dark-mode .logout-btn:hover {
  background: #a19e9e;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 3px;
  transition: background 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.5);
}

body.dark-mode ::-webkit-scrollbar-thumb {
  background: rgba(224, 224, 224, 0.3);
}

body.dark-mode ::-webkit-scrollbar-thumb:hover {
  background: rgba(224, 224, 224, 0.5);
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.3) transparent;
}

body.dark-mode * {
  scrollbar-color: rgba(224, 224, 224, 0.3) transparent;
}


/* Migration Overlay Styles */
.migration-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

.migration-loader {
    background: #ffffff;
    border-radius: 16px;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.4s ease;
}

body.dark-mode .migration-loader {
    background: #2f3247;
    color: #e0e0e0;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(229, 187, 34, 0.2);
    border-top: 4px solid #e5bb22;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

body.dark-mode .spinner {
    border: 4px solid rgba(224, 224, 224, 0.2);
    border-top: 4px solid #e0e0e0;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.migration-text h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.2rem;
    font-weight: 600;
}

.migration-text p {
    margin: 0.5rem 0;
    font-size: 0.9rem;
    color: #666;
}

body.dark-mode .migration-text p {
    color: #aaa;
}

.progress-bar-container {
    width: 100%;
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    margin: 1rem 0;
    overflow: hidden;
}

body.dark-mode .progress-bar-container {
    background: #1a1a2e;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background: #e5bb22;
    border-radius: 3px;
    transition: width 0.3s ease;
}

body.dark-mode .progress-bar {
    background: #e0e0e0;
}

.migration-note {
    font-size: 0.8rem;
    color: #999;
    font-style: italic;
}

body.dark-mode .migration-note {
    color: #777;
}

.migration-overlay.hidden {
    display: none;
}