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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #121212;
  color: #e0e0e0;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: #1DB954; text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Header === */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: #181818;
  border-bottom: 1px solid #282828;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-size: 1.25rem;
  font-weight: 800;
  color: #1DB954;
  letter-spacing: -0.5px;
}
.logo:hover { text-decoration: none; }

.header-nav { display: flex; gap: 1.25rem; }
.header-nav a { color: #B3B3B3; font-size: 0.875rem; font-weight: 500; }
.header-nav a:hover { color: #fff; text-decoration: none; }

/* === 3-Column Layout === */
.layout-3col {
  display: grid;
  grid-template-columns: 180px 1fr 320px;
  gap: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.sidebar { display: flex; flex-direction: column; gap: 1.5rem; }

.ad-slot--sidebar { min-height: 600px; width: 160px; background: #181818; border-radius: 8px; border: 1px dashed #404040; }
.ad-slot--sidebar-sm { min-height: 250px; width: 300px; background: #181818; border-radius: 8px; border: 1px dashed #404040; }
.ad-slot--inline { display: none; min-height: 250px; background: #181818; border-radius: 8px; border: 1px dashed #404040; margin: 1.5rem 0; }
.ad-slot--bottom { min-height: 90px; max-width: 1000px; margin: 1.5rem auto; background: #181818; border-radius: 8px; border: 1px dashed #404040; }

/* === Main Content === */
.main-content { min-width: 0; }

h1 {
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 0.5rem;
  letter-spacing: -0.5px;
}

.intro-text {
  color: #B3B3B3;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.75rem;
}

h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 0.4rem;
}

/* === Card === */
.card {
  background: #181818;
  border: 1px solid #282828;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card-desc {
  color: #B3B3B3;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
.btn:active { transform: scale(0.97); }

.btn--primary { background: #1DB954; color: #121212; }
.btn--primary:hover { background: #1ed760; }

.btn--secondary { background: #282828; color: #e0e0e0; border: 1px solid #404040; }
.btn--secondary:hover { background: #333; }

/* === Game Controls === */
.game-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.mode-toggle { display: flex; align-items: center; }

.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: #B3B3B3;
  user-select: none;
}

.toggle-label input { display: none; }

.toggle-slider {
  position: relative;
  width: 44px;
  height: 24px;
  background: #404040;
  border-radius: 12px;
  transition: background 0.2s;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #B3B3B3;
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.toggle-label input:checked + .toggle-slider {
  background: #1DB954;
}

.toggle-label input:checked + .toggle-slider::after {
  transform: translateX(20px);
  background: #fff;
}

.btn--stats { padding: 0.5rem 1rem; font-size: 0.8rem; }

/* === Game Board === */
.board {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 1rem 0;
}

.board-row {
  display: flex;
  gap: 6px;
}

.tile {
  width: 58px;
  height: 58px;
  border: 2px solid #404040;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  transition: border-color 0.1s;
  user-select: none;
}

.tile--filled {
  border-color: #535353;
  animation: pop 0.1s ease;
}

.tile--correct {
  background: #1DB954;
  border-color: #1DB954;
  color: #fff;
}

.tile--present {
  background: #F5C518;
  border-color: #F5C518;
  color: #121212;
}

.tile--absent {
  background: #535353;
  border-color: #535353;
  color: #fff;
}

.tile--reveal {
  animation: flip 0.5s ease forwards;
}

@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

@keyframes flip {
  0% { transform: rotateX(0deg); }
  50% { transform: rotateX(90deg); }
  100% { transform: rotateX(0deg); }
}

@keyframes bounce {
  0%, 20% { transform: translateY(0); }
  40% { transform: translateY(-20px); }
  50% { transform: translateY(5px); }
  60% { transform: translateY(-10px); }
  80% { transform: translateY(2px); }
  100% { transform: translateY(0); }
}

.tile--win {
  animation: bounce 0.6s ease forwards;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
  20%, 40%, 60%, 80% { transform: translateX(4px); }
}

.board-row--shake {
  animation: shake 0.4s ease;
}

/* === On-screen Keyboard === */
.keyboard {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 1.5rem;
}

.keyboard-row {
  display: flex;
  gap: 5px;
}

.key {
  min-width: 36px;
  height: 52px;
  border: none;
  border-radius: 6px;
  background: #282828;
  color: #e0e0e0;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  transition: background 0.2s;
  user-select: none;
  padding: 0 8px;
}

.key:hover { background: #333; }
.key:active { transform: scale(0.95); }

.key--wide {
  min-width: 60px;
  font-size: 0.7rem;
}

.key--correct { background: #1DB954; color: #fff; }
.key--present { background: #F5C518; color: #121212; }
.key--absent { background: #535353; color: #fff; }

/* === Message Area === */
.message-area {
  text-align: center;
  min-height: 2rem;
  margin-bottom: 0.5rem;
}

.message {
  display: inline-block;
  background: #e0e0e0;
  color: #121212;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  animation: fadeIn 0.2s ease;
}

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

/* === Stats Modal === */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: #181818;
  border: 1px solid #282828;
  border-radius: 12px;
  padding: 2rem;
  max-width: 440px;
  width: 100%;
  position: relative;
}

.modal h2 {
  text-align: center;
  margin-bottom: 1.25rem;
}

.modal h3 {
  text-align: center;
  margin-top: 1.25rem;
  margin-bottom: 0.75rem;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: #B3B3B3;
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: #fff; }

.stats-summary {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  text-align: center;
}

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

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
}

.stat-label {
  font-size: 0.7rem;
  color: #B3B3B3;
  text-transform: uppercase;
}

.guess-distribution {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dist-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
}

.dist-label {
  width: 14px;
  text-align: right;
  font-weight: 600;
  color: #B3B3B3;
}

.dist-bar {
  min-width: 20px;
  padding: 2px 8px;
  background: #404040;
  border-radius: 4px;
  text-align: right;
  font-weight: 700;
  font-size: 0.75rem;
  color: #fff;
  transition: width 0.3s ease;
}

.dist-bar--highlight {
  background: #1DB954;
}

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* === Content Below === */
.content-below {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 1.5rem 2rem;
}

.card--wide { width: 100%; }

/* === Tips Grid === */
.tips-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

.tip-item {
  background: #212121;
  border-radius: 8px;
  padding: 1rem;
}

.tip-item p {
  color: #B3B3B3;
  font-size: 0.85rem;
}

/* === FAQ === */
.faq-list { display: flex; flex-direction: column; gap: 0.5rem; }

.faq-item {
  background: #212121;
  border-radius: 8px;
  overflow: hidden;
}

.faq-question {
  padding: 1rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  color: #fff;
  list-style: none;
}
.faq-question::-webkit-details-marker { display: none; }
.faq-question::before {
  content: '+';
  display: inline-block;
  width: 1.5rem;
  color: #1DB954;
  font-weight: 700;
}
details[open] .faq-question::before { content: '-'; }

.faq-answer {
  padding: 0 1rem 1rem 2.5rem;
  color: #B3B3B3;
  font-size: 0.875rem;
  line-height: 1.7;
}

/* === Cross Links === */
.tools-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
  margin-top: 0.75rem;
}

.tool-link {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  background: #212121;
  border-radius: 8px;
  padding: 1.25rem;
  transition: background 0.2s, border-color 0.2s;
  border: 1px solid #282828;
}
.tool-link:hover { background: #282828; text-decoration: none; border-color: #1DB954; }

.tool-icon { font-size: 1.5rem; }
.tool-name { font-weight: 600; color: #fff; font-size: 1rem; }
.tool-desc { color: #B3B3B3; font-size: 0.8rem; }

/* === Footer === */
.footer {
  background: #181818;
  border-top: 1px solid #282828;
  padding: 2rem 1.5rem 1rem;
}

.footer-inner {
  max-width: 1000px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 2rem;
  margin-bottom: 1.5rem;
}

.footer-logo { font-weight: 800; color: #1DB954; font-size: 1.1rem; }
.footer-about-text { color: #535353; font-size: 0.8rem; margin-top: 0.5rem; }

.footer-heading { color: #B3B3B3; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 0.5rem; }
.footer-links-group { display: flex; flex-direction: column; gap: 0.4rem; }
.footer-links-group a { color: #535353; font-size: 0.85rem; }
.footer-links-group a:hover { color: #fff; text-decoration: none; }

.footer-bottom {
  text-align: center;
  border-top: 1px solid #282828;
  padding-top: 1rem;
  max-width: 1000px;
  margin: 0 auto;
}
.footer-bottom p { color: #535353; font-size: 0.75rem; }

/* === Responsive === */
@media (max-width: 1024px) {
  .layout-3col {
    grid-template-columns: 1fr;
    padding: 1.5rem 1rem;
  }
  .sidebar--left { display: none; }
  .sidebar--right { display: none; }
  .ad-slot--inline { display: block; }
}

@media (max-width: 768px) {
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.15rem; }

  .header { padding: 0.75rem 1rem; }

  .tile {
    width: 48px;
    height: 48px;
    font-size: 1.4rem;
  }

  .key {
    min-width: 28px;
    height: 46px;
    font-size: 0.7rem;
    padding: 0 5px;
  }

  .key--wide {
    min-width: 48px;
    font-size: 0.6rem;
  }

  .tips-grid { grid-template-columns: 1fr; }
  .tools-grid { grid-template-columns: 1fr; }

  .footer-inner { grid-template-columns: 1fr; gap: 1.25rem; }

  .stats-summary { gap: 1rem; }
  .stat-value { font-size: 1.5rem; }
}

@media (max-width: 400px) {
  .tile {
    width: 42px;
    height: 42px;
    font-size: 1.2rem;
  }

  .key {
    min-width: 24px;
    height: 42px;
    font-size: 0.65rem;
    padding: 0 3px;
  }

  .key--wide {
    min-width: 42px;
  }
}
