/* trivial css */
@media (min-width: 768px) {
  #trivialMenu {
    transform: scale(1.2);
    transform-origin: top center;
  }

  #trivialMainMenuBtn {
    width: 288px;
    max-width: 100%;
    margin: 5px auto 0;
  }
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f4f4f4;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.game-container {
  margin-top: 40px;
  background: #ffffff;
  padding: 24px 28px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  max-width: 520px;
  width: 100%;
}

h1 {
  text-align: center;
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 1.9rem;
}

.subtitle {
  text-align: center;
  font-size: 0.9rem;
  color: #555;
  margin-bottom: 16px;
}

/* Shared buttons */
button {
  cursor: pointer;
  border-radius: 6px;
  border: none;
  padding: 8px 14px;
  font-size: 1rem;
  font-weight: 500;
  background: #0077ff;
  color: white;
  transition: background 0.15s ease, transform 0.05s ease;
}

button:hover {
  background: #005fcb;
}

button:active {
  transform: scale(0.97);
}

button:disabled {
  background: #aaa;
  cursor: not-allowed;
}

.secondary-btn {
  background: #ffffff;
  color: #0077ff;
  border: 1px solid #0077ff;
}

.secondary-btn:hover {
  background: #e9f1ff;
}

/* Main menu buttons (vertical, centered) */
.main-menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-top: 16px;
  align-items: center;
}

.main-menu-buttons button {
  width: 100%;
  height: 40px;
  max-width: 280px;
}

/* How to play */

.how-to-play {
  margin-top: 20px;
  margin-bottom: 12px;
  padding-top: 10px;
  border-top: 1px solid #ddd;
}

.how-to-play h2 {
  font-size: 1.1rem;
  margin: 0 0 6px;
  text-align: center;
}

.how-to-text {
  font-size: 0.75rem;
  color: #555;
  text-align: center;
  margin: 0 0 8px;
}

.how-to-steps li {
  margin-bottom: 6px;
  line-height: 1.35;
}

/* Status + clues */
.status-text {
  font-size: 0.95rem;
  color: #555;
  margin-bottom: 10px;
  text-align: center;
}

.clue-list {
  margin-bottom: 14px;
}

.clue-list ol {
  margin: 0;
  padding-left: 22px;
}

.clue-list li {
  margin-bottom: 4px;
  font-size: 0.95rem;
}

/* Input row */
.visible-input-row {
  display: flex;
  margin-top: 8px;
  margin-bottom: 10px;
  gap: 8px;
}

.visible-input-row input {
  flex: 1;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #ccc;
  font-size: 1rem;
}

/* Message */
#trivialMessage {
  min-height: 20px;
  font-size: 0.95rem;
  margin-top: 4px;
  margin-bottom: 14px;
  color: #d12c2c;
}

#trivialMessage.ok {
  color: #1a7d26;
}

/* Controls row */
.controls-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 0;
}

.buttons-left {
  display: flex;
  gap: 8px;
}

/* Modal styles */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

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

.modal-content {
  background: #ffffff;
  border-radius: 12px;
  padding: 20px 22px;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}

.modal-content h2 {
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 1.2rem;
  text-align: center;
}

.modal-body {
  font-size: 1.05rem;
  color: #333;
  margin-bottom: 16px;
  line-height: 1.4;
  text-align: center;
}

.modal-buttons-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
  margin-bottom: 10px;
}

.modal-main-menu-row {
  display: flex;
  justify-content: center;
  margin-top: 5px;
}

#trivialMainMenuBtn {
  display: block;
  margin: 0 auto;
}

.trivial-history {
  margin-top: 18px;
  border-top: 1px solid #ddd;
  padding-top: 10px;
}

.trivial-history h2 {
  font-size: 1rem;
  margin: 0 0 6px;
  text-align: center;
}

#trivialGuessList {
  margin: 0;
  padding-left: 20px;
  max-height: 240px;
  overflow-y: auto;
  text-transform: uppercase;
  font-size: 0.95rem;
}

#trivialGuessList li {
  padding: 4px 0;
}

.half-line-break {
  display: block;
  height: 8px;
}

.gate-buttons-row {
  margin-top: 16px;
}

.modal-clue-list {
  text-align: left;
  margin: 10px auto;
  padding-left: 22px;
  font-size: 0.95rem;
  color: #333;
  max-width: 320px;
}

.modal-footer-note {
  text-align: center;
  margin-top: 12px;
  font-size: 0.9rem;
  color: #555;
}

/* Mobile */
@media (max-width: 480px) {
  .game-container {
    margin-top: 24px;
    padding: 20px 20px;
  }

  #trivialMenu {
    margin-top: 180px;
}

  .modal-content {
    padding: 16px;
    width: 92%;
  }

  .modal-buttons-row {
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 10px;
  }

  .modal-buttons-row button {
    width: 140px;
    flex: 0 0 140px;
  }

  #trivialMainMenuBtn {
    width: 290px;
    max-width: 100%;
    margin: 5px auto 0;
  }

  .visible-input-row {
    flex-direction: column;
  }
}

.modal-overlay.gate-modal .modal-content {
  box-shadow: 0 14px 36px rgba(0,0,0,0.28);
}

.gate-top-buttons {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.gate-top-buttons button,
.modal-buttons-row button {
  width: 140px;
  flex: 0 0 140px;
}


.modal-clue-list li {
  margin-bottom: 8px;
}

.modal-clue-guess {
  margin-top: 2px;
  font-size: 0.8rem;
  color: #666;
  line-height: 1.25;
}

.leaderboard-box {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.leaderboard-card {
  background: #ffffff;
  width: 90%;
  max-width: 420px;
  border-radius: 12px;
  padding: 20px 22px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  text-align: center;
}

.leaderboard-card h2 {
  margin-top: 0;
  margin-bottom: 6px;
}

.leaderboard-subtitle {
  margin-top: 0;
  color: #555;
  font-size: 0.95rem;
}

.leaderboard-name-input {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1rem;
  margin: 10px 0;
}

.leaderboard-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.leaderboard-actions button {
  width: 100%;
}

.leaderboard-message {
  min-height: 20px;
  color: #d12c2c;
  font-size: 0.9rem;
}

.leaderboard-list {
  margin: 12px 0;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #eee;
  align-items: center;
  text-align: left;
}

.leaderboard-rank {
  font-weight: 700;
}

.leaderboard-name {
  font-weight: 600;
}

.leaderboard-score {
  color: #555;
  white-space: nowrap;
}

.leaderboard-empty,
.leaderboard-loading {
  color: #555;
  margin: 16px 0;
}

.leaderboard-win-loss-line {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.leaderboard-card > #leaderboardCloseBtn {
  margin-top: 18px;
}

.leaderboard-actions #leaderboardCloseBtn {
  margin-top: 8px;
}

.clue-list ol {
  list-style: none;
  padding-left: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  perspective: 1000px;
}

.clue-list li {
  margin-bottom: 4px;
  font-size: 0.95rem;
  background: transparent;
  border: none;
  padding: 0;
  box-shadow: none;
  perspective: 1000px;
}

.clue-card-inner {
  position: relative;
  width: 100%;
  min-height: 44px;
  transform-style: preserve-3d;
  transform-origin: center center;
}

.clue-card-face {
  grid-area: 1 / 1;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: #ffffff;
  border: 2px solid #d7e6ff;
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.06);
  color: #333;
}

.clue-card-inner {
  display: grid;
}

.clue-card-back {
  transform: rotateX(180deg);
}

.clue-card-number {
  display: inline;
  font-size: 0.9rem;
  font-weight: 700;
  color: #0077ff;
  margin-right: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.clue-list li.trivial-win-flip .clue-card-inner {
  animation: trivialCardFlip 850ms ease forwards;
}

.clue-list li.trivial-win-flip .clue-card-back {
  background: #dff8e4;
  border-color: #2fa84f;
  color: #1a7d26;
}

.clue-list li.trivial-win-flip .clue-card-back .clue-card-number {
  color: #1a7d26;
}

.clue-list li.trivial-lose-reveal .clue-card-inner {
  animation: trivialCardFlip 900ms ease forwards;
}

.clue-list li.trivial-lose-reveal .clue-card-back {
  background: #ffe8e8;
  border-color: #d12c2c;
  color: #8f1f1f;
}

.clue-list li.trivial-lose-reveal .clue-card-back .clue-card-number {
  color: #d12c2c;
}

@keyframes trivialCardFlip {
  0% {
    transform: rotateX(0deg);
  }

  100% {
    transform: rotateX(180deg);
  }
}

.leaderboard-card {
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.leaderboard-list {
  overflow-y: scroll;
  scrollbar-gutter: stable;
  max-height: 48vh;
  padding-right: 6px;
}

.leaderboard-list::before {
  content: "Scroll for more ↓";
  display: block;
  position: sticky;
  top: 0;
  z-index: 2;
  background: #ffffff;
  color: #555;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
  padding: 4px 0 6px;
  margin-bottom: 4px;
  border-bottom: 1px solid #eee;
}

@media (min-width: 701px) {
  .leaderboard-card {
    max-height: 88vh;
  }

  .leaderboard-list {
    max-height: 60vh;
  }
}

@media (max-width: 700px) {
  .leaderboard-card {
    max-height: 88vh;
    transform: scale(0.94);
    transform-origin: center center;
  }

  .leaderboard-list {
    max-height: 58vh;
  }
}

.streak-celebration {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 220ms ease, transform 220ms ease;
}

.streak-celebration.show {
  opacity: 1;
  transform: scale(1);
}

.streak-emoji {
  font-size: 5rem;
  line-height: 1;
  animation: streakEmojiPop 900ms ease forwards;
}

.streak-title {
  margin-top: 12px;
  background: #ffffff;
  color: #333;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 1.25rem;
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(0,0,0,0.22);
}

@keyframes streakEmojiPop {
  0% {
    transform: scale(0.4) rotate(-18deg);
  }

  40% {
    transform: scale(1.25) rotate(10deg);
  }

  70% {
    transform: scale(0.95) rotate(-4deg);
  }

  100% {
    transform: scale(1) rotate(0deg);
  }
}

.streak-five .streak-emoji {
  text-shadow: 0 0 24px rgba(255, 100, 0, 0.85);
}

.streak-ten .streak-title {
  box-shadow: 0 0 26px rgba(0, 119, 255, 0.45);
}

.streak-thirty .streak-title {
  border: 2px solid #f4c542;
}

.streak-sixty .streak-emoji {
  animation: streakEmojiPop 900ms ease forwards, streakWiggle 500ms ease 2;
}

.streak-ninety .streak-title {
  border: 2px solid #f4c542;
  box-shadow: 0 0 30px rgba(244, 197, 66, 0.55);
}

.streak-six-months .streak-title {
  border: 2px solid #7bdff2;
  box-shadow: 0 0 32px rgba(123, 223, 242, 0.65);
}

.streak-year .streak-emoji {
  font-size: 6rem;
}

.streak-year .streak-title {
  border: 2px solid #f4c542;
  box-shadow: 0 0 40px rgba(244, 197, 66, 0.75);
}

.modal-overlay.gate-modal .modal-footer-note {
  display: none;
}

.home-footer {
  margin-top: 20px;
  font-size: 0.7rem;
  color: #777;
  text-align: center;
}

@keyframes streakWiggle {
  0% {
    transform: rotate(0deg) scale(1);
  }

  25% {
    transform: rotate(-8deg) scale(1.05);
  }

  50% {
    transform: rotate(8deg) scale(1.05);
  }

  75% {
    transform: rotate(-5deg) scale(1.02);
  }

  100% {
    transform: rotate(0deg) scale(1);
  }
}

@media (max-width: 480px) {
  .streak-emoji {
    font-size: 4.2rem;
  }

  .streak-title {
    font-size: 1rem;
    padding: 9px 15px;
  }

  .streak-year .streak-emoji {
    font-size: 5rem;
  }
}