:root {
  --success: var(--ok);
  --error: #d64545;
  --game-gradient: linear-gradient(135deg, rgba(233, 168, 107, 0.08) 0%, rgba(47, 72, 88, 0.04) 100%);
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--game-gradient);
}

.game-header {
  background: var(--paper);
  border-bottom: 1px solid rgba(40, 50, 70, 0.08);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.game-header .nav {
  padding: 18px 20px;
}

.game-layout {
  flex: 1;
  display: flex;
  justify-content: center;
  padding-top: 32px;
  padding-bottom: 64px;
}

.game-card {
  width: min(720px, 100%);
  background: var(--paper);
  border: 1px solid rgba(40, 50, 70, 0.08);
  border-radius: calc(var(--radius) + 6px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
  padding: 32px clamp(20px, 5vw, 42px);
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: relative;
  overflow: hidden;
}

.game-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
}

.game-card__header .kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, rgba(233, 168, 107, 0.25), rgba(233, 168, 107, 0.15));
  color: #8a5e2f;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
  border: 1px solid rgba(233, 168, 107, 0.3);
}

.game-card__header .kicker::before {
  content: "🎯";
  font-size: 14px;
}

.game-card__header h1 {
  margin: 0;
  font-size: clamp(28px, 3.4vw, 36px);
  line-height: 1.1;
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.scoreboard__item {
  background: linear-gradient(135deg, rgba(40, 50, 70, 0.05), rgba(40, 50, 70, 0.02));
  border: 1px solid rgba(40, 50, 70, 0.06);
  border-radius: 14px;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.scoreboard__item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.scoreboard__item .label {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.scoreboard__item .value {
  font-size: 26px;
  font-weight: 800;
}

.scoreboard__item.ok .value {
  color: var(--success);
}

.scoreboard__item.warn .value {
  color: #d97c2b;
  font-size: 20px;
}

.scoreboard__item.streak .value {
  color: var(--brand-2);
}

/* Hangman Game Area */
.hangman-area {
  background: linear-gradient(135deg, #fdfbf7, #f9f6f1);
  border-radius: calc(var(--radius) + 2px);
  padding: 32px 24px;
  border: 2px solid rgba(233, 168, 107, 0.2);
  box-shadow: 0 2px 8px rgba(233, 168, 107, 0.08);
  display: flex;
  flex-direction: column;
  gap: 24px;
  align-items: center;
  position: relative;
}

/* Mobile Lives Display - hidden on desktop */
.mobile-lives-display {
  display: none;
}

@media (max-width: 720px) {
  .mobile-lives-display {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2px;
    position: absolute;
    top: 0;
    right: 4px;
    background: rgba(255, 255, 255, 0.9);
    padding: 4px;
    border-radius: calc(var(--radius) - 4px);
    border: 1px solid rgba(233, 168, 107, 0.3);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    z-index: 5;
  }

  .mobile-lives-display .heart {
    font-size: 16px;
    line-height: 1;
    text-align: center;
    transition: all 0.3s ease;
  }

  .mobile-lives-display .heart.lost {
    animation: heartBreak 0.6s ease-out;
  }

  @keyframes heartBreak {
    0% {
      transform: scale(1);
      opacity: 1;
    }
    25% {
      transform: scale(1.4) rotate(-10deg);
      opacity: 1;
    }
    50% {
      transform: scale(0.8) rotate(10deg);
      opacity: 0.6;
    }
    75% {
      transform: scale(1.2) rotate(-5deg);
      opacity: 0.8;
    }
    100% {
      transform: scale(1) rotate(0deg);
      opacity: 1;
    }
  }

  /* Hide lives from scoreboard on mobile */
  .scoreboard__item.warn {
    display: none;
  }
}

/* Hint */
.hint-container {
  text-align: center;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  position: relative;
}

.hint-reveal-btn {
  background: linear-gradient(135deg, rgba(233, 168, 107, 0.2), rgba(233, 168, 107, 0.1));
  border: 2px solid rgba(233, 168, 107, 0.4);
  color: var(--brand-2);
  padding: 12px 24px;
  border-radius: calc(var(--radius) - 4px);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hint-reveal-btn:hover {
  background: linear-gradient(135deg, rgba(233, 168, 107, 0.3), rgba(233, 168, 107, 0.15));
  border-color: var(--brand);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(233, 168, 107, 0.25);
}

.hint-reveal-btn:active {
  transform: translateY(0);
}

.hint-reveal-btn.hidden {
  display: none;
}

.hint-content {
  width: 100%;
  opacity: 1;
  transform: scale(1);
  transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.hint-content.hidden {
  opacity: 0;
  transform: scale(0.9);
  max-height: 0;
  overflow: hidden;
}

.hint-content.reveal {
  animation: hintReveal 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes hintReveal {
  0% {
    opacity: 0;
    transform: scale(0.8) translateY(-20px);
    filter: blur(10px);
  }
  50% {
    filter: blur(5px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
    filter: blur(0);
  }
}

.hint-label {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  display: block;
  margin-bottom: 8px;
}

.hint-text {
  font-size: clamp(20px, 3vw, 26px);
  font-weight: 700;
  color: var(--brand-2);
  display: block;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Word and Hangman Container */
.word-hangman-container {
  position: relative;
  width: 100%;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 160px 20px 20px 20px; /* Space for hangman on top */
}

/* Word Display */
.word-display {
  font-size: clamp(32px, 5vw, 48px);
  font-weight: 800;
  color: var(--ink);
  letter-spacing: 8px;
  text-align: center;
  font-family: 'Courier New', monospace;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: 4px;
}

.word-display.shake {
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-8px); }
  20%, 40%, 60%, 80% { transform: translateX(8px); }
}

.word-display .letter {
  display: inline-block;
}

.word-display .letter.reveal {
  animation: letterReveal 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes letterReveal {
  0% {
    transform: scale(0) rotateY(90deg);
    opacity: 0;
    color: var(--brand);
  }
  50% {
    transform: scale(1.3) rotateY(0deg);
    color: var(--brand);
  }
  100% {
    transform: scale(1) rotateY(0deg);
    opacity: 1;
    color: var(--ink);
  }
}

/* Hangman Drawing - Fixed position at top center */
.hangman-drawing {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: var(--radius);
  border: 2px solid rgba(233, 168, 107, 0.15);
}

.hangman-drawing svg {
  display: block;
}

/* Hangman parts - initially hidden */
.hangman-part {
  opacity: 0;
  transform: scale(0);
  transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.hangman-part.visible {
  opacity: 1;
  transform: scale(1);
}

/* Animation for each part appearing */
@keyframes partAppear {
  0% {
    opacity: 0;
    transform: scale(0) rotate(-10deg);
  }
  50% {
    transform: scale(1.1) rotate(5deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

.hangman-part.visible {
  animation: partAppear 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Used Letters */
.used-letters-container {
  text-align: center;
  width: 100%;
}

.used-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--muted);
  display: block;
  margin-bottom: 6px;
}

.used-letters {
  font-size: 16px;
  font-weight: 600;
  color: #d64545;
  letter-spacing: 4px;
}

/* Virtual Keyboard */
.keyboard {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

.keyboard-row {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.keyboard-row:nth-child(2) {
  padding: 0 20px; /* Offset for QWERTY middle row */
}

.keyboard-row:nth-child(3) {
  padding: 0 40px; /* Offset for QWERTY bottom row */
}

.key-btn {
  background: linear-gradient(135deg, #fffaf5, #fff7ee);
  border: 2px solid rgba(233, 168, 107, 0.4);
  color: #703f18;
  border-radius: calc(var(--radius) - 6px);
  padding: 12px 8px;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex: 1;
  min-width: 45px;
  max-width: 55px;
  position: relative;
  overflow: hidden;
  text-transform: uppercase;
  font-family: inherit;
}

.key-btn:hover:not(.disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(233, 168, 107, 0.25);
  border-color: rgba(233, 168, 107, 0.6);
}

.key-btn:active:not(.disabled) {
  transform: translateY(0);
}

.key-btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.key-btn.correct {
  background: linear-gradient(135deg, rgba(26, 157, 87, 0.2), rgba(26, 157, 87, 0.12));
  border-color: var(--success);
  color: var(--success);
}

.key-btn.wrong {
  background: linear-gradient(135deg, rgba(214, 69, 69, 0.15), rgba(214, 69, 69, 0.08));
  border-color: #d64545;
  color: #d64545;
  text-decoration: line-through;
}

.key-btn.disabled {
  pointer-events: none;
  opacity: 0.4;
}

.feedback {
  min-height: 22px;
  font-size: 15px;
  text-align: center;
}

.feedback.positive {
  color: var(--success);
  font-weight: 600;
}

.feedback.negative {
  color: #d64545;
  font-weight: 600;
}

/* Simple CTA Panel Design */
.cta-panel-simple {
  background: linear-gradient(135deg, #fdfbf7, #f9f6f1);
  border: 2px solid rgba(233, 168, 107, 0.3);
  border-radius: calc(var(--radius) + 2px);
  padding: 24px;
  display: flex;
  gap: 20px;
  align-items: center;
  box-shadow: 0 2px 8px rgba(233, 168, 107, 0.08);
}

.cta-panel-simple .cta-icon {
  font-size: 48px;
  flex-shrink: 0;
  line-height: 1;
}

.cta-panel-simple .cta-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cta-panel-simple .cta-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}

.cta-panel-simple .cta-text {
  margin: 0;
  font-size: 15px;
  color: var(--muted);
  line-height: 1.4;
}

.cta-panel-simple .btn {
  align-self: center;
  min-width: 200px;
}

@media (max-width: 540px) {
  .cta-panel-simple {
    flex-direction: column;
    text-align: center;
    padding: 20px;
  }

  .cta-panel-simple .btn {
    align-self: stretch;
    width: 100%;
  }
}

/* Back link container */
.back-link-container {
  margin-top: 24px;
  text-align: center;
}

.back-link {
  display: inline-block;
  font-size: 15px;
  color: var(--brand-2);
  text-decoration: none;
  padding: 10px 16px;
  border-radius: var(--radius);
  transition: all 0.2s ease;
}

.back-link:hover {
  color: var(--brand);
  background: rgba(233, 168, 107, 0.1);
}

/* Overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(22, 24, 29, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.3s ease;
  z-index: 1000;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.overlay.hidden {
  display: none;
}

.overlay__card {
  background: var(--paper);
  border-radius: calc(var(--radius) + 4px);
  padding: 32px clamp(24px, 5vw, 48px);
  max-width: 540px;
  text-align: center;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.25), 0 8px 16px rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(233, 168, 107, 0.2);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.overlay__card h2 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: clamp(26px, 3vw, 34px);
}

.overlay__card p {
  margin-bottom: 20px;
  color: var(--muted);
  line-height: 1.6;
}

.overlay-cta-text {
  margin-top: 16px;
  color: var(--brand-2) !important;
  font-weight: 500;
}

.overlay__actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.overlay .btn {
  min-width: 180px;
}

/* Tertiary button style */
.btn.tertiary {
  background: linear-gradient(135deg, rgba(233, 168, 107, 0.15), rgba(233, 168, 107, 0.08));
  color: var(--brand-2);
  border: 2px solid rgba(233, 168, 107, 0.4);
}

.btn.tertiary:hover {
  background: linear-gradient(135deg, rgba(233, 168, 107, 0.25), rgba(233, 168, 107, 0.15));
  border-color: var(--brand);
  transform: translateY(-1px);
}

/* Smaller overlay card for leaderboard input */
.overlay__card--small {
  max-width: 420px;
}

/* Best Streak Display in Overlay */
.best-streak-display {
  background: linear-gradient(135deg, rgba(233, 168, 107, 0.2), rgba(233, 168, 107, 0.1));
  border: 2px solid rgba(233, 168, 107, 0.4);
  border-radius: var(--radius);
  padding: 20px;
  margin: 20px 0;
  text-align: center;
}

.best-streak-display.hidden {
  display: none;
}

.best-streak-label {
  font-size: 14px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.best-streak-value {
  font-size: 48px;
  font-weight: 800;
  color: var(--brand-2);
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.best-streak-value::before {
  content: "🔥";
  font-size: 40px;
}

/* Leaderboard Styles */
.leaderboard {
  background: linear-gradient(135deg, rgba(233, 168, 107, 0.08), rgba(47, 72, 88, 0.04));
  border: 1px solid rgba(233, 168, 107, 0.2);
  border-radius: calc(var(--radius) + 2px);
  padding: 16px 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.leaderboard-header {
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid rgba(233, 168, 107, 0.15);
}

.leaderboard-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--brand-2);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.leaderboard-columns {
  display: grid;
  grid-template-columns: 32px 1fr 70px 70px 70px;
  gap: 8px;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(40, 50, 70, 0.08);
  margin-bottom: 8px;
}

.leaderboard-columns > div {
  text-align: center;
}

.col-name {
  text-align: left !important;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.leaderboard-empty {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  font-style: italic;
  padding: 12px 0;
}

.leaderboard-item {
  display: grid;
  grid-template-columns: 32px 1fr 70px 70px 70px;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  background: var(--paper);
  border-radius: var(--radius);
  border: 1px solid rgba(40, 50, 70, 0.06);
  transition: all 0.2s ease;
}

.leaderboard-item:hover {
  transform: translateX(4px);
  box-shadow: 0 2px 8px rgba(233, 168, 107, 0.15);
}

.leaderboard-rank {
  font-size: 15px;
  font-weight: 700;
  color: var(--brand);
  text-align: center;
}

.leaderboard-item:nth-child(1) .leaderboard-rank {
  color: #FFD700;
  font-size: 16px;
}

.leaderboard-item:nth-child(2) .leaderboard-rank {
  color: #C0C0C0;
}

.leaderboard-item:nth-child(3) .leaderboard-rank {
  color: #CD7F32;
}

.leaderboard-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.leaderboard-streak {
  font-size: 15px;
  font-weight: 700;
  color: var(--brand-2);
  text-align: center;
}

.leaderboard-words {
  font-size: 15px;
  font-weight: 700;
  color: var(--brand);
  text-align: center;
}

.leaderboard-date {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

/* Leaderboard Form in Modal */
.leaderboard-congrats {
  margin: 0 0 16px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}

.leaderboard-congrats strong {
  color: var(--brand-2);
  font-size: 18px;
  display: block;
  margin-bottom: 4px;
}

.leaderboard-input-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.leaderboard-input {
  flex: 1;
  min-width: 100%;
  padding: 12px 16px;
  font-size: 15px;
  border: 2px solid rgba(233, 168, 107, 0.3);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  font-family: inherit;
  transition: all 0.2s ease;
}

.leaderboard-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(233, 168, 107, 0.15);
}

.leaderboard-input::placeholder {
  color: var(--muted);
}

/* Pulse animation for streak milestones */
@keyframes pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(233, 168, 107, 0.7);
  }
  50% {
    transform: scale(1.1);
    box-shadow: 0 0 0 10px rgba(233, 168, 107, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(233, 168, 107, 0);
  }
}

.scoreboard__item.pulse {
  animation: pulse 0.6s ease;
}

/* Mobile Responsive */
@media (max-width: 720px) {
  .scoreboard {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
  }

  .keyboard {
    gap: 5px;
    max-width: 100%;
  }

  .keyboard-row:nth-child(2),
  .keyboard-row:nth-child(3) {
    padding: 0; /* Remove offset on mobile */
  }

  .key-btn {
    padding: 10px 4px;
    font-size: 15px;
    min-height: 44px; /* Ensure touch-friendly size */
    min-width: 32px;
    max-width: 45px;
  }
}

@media (max-width: 540px) {
  .game-card {
    padding: 24px 14px;
  }

  .hangman-area {
    padding: 20px 14px;
  }

  .word-hangman-container {
    padding: 150px 15px 15px 15px;
    min-height: 200px;
  }

  .word-display {
    letter-spacing: 3px;
    font-size: clamp(26px, 5vw, 38px);
  }

  .hangman-drawing {
    padding: 8px;
  }

  .hangman-drawing svg {
    width: 100px;
    height: 120px;
  }

  .keyboard {
    gap: 4px;
  }

  .key-btn {
    padding: 9px 3px;
    font-size: 14px;
    min-height: 42px;
    min-width: 28px;
    max-width: 40px;
  }

  .best-streak-value {
    font-size: 36px;
  }

  .best-streak-value::before {
    font-size: 32px;
  }

  .leaderboard {
    padding: 14px 16px;
  }

  .leaderboard-columns {
    grid-template-columns: 20px 1fr 44px 44px 52px;
  }

  .leaderboard-item {
    grid-template-columns: 20px 1fr 44px 44px 52px;
    gap: 8px;
    padding: 6px 10px;
  }

  .leaderboard-rank {
    font-size: 14px;
  }

  .leaderboard-name {
    font-size: 13px;
  }

  .leaderboard-streak {
    font-size: 14px;
  }

  .leaderboard-words {
    font-size: 14px;
  }
}
