/* ============================================
   BUZZWORDS — Styles
   Honeycomb / Bee theme — warm amber on dark
   ============================================ */

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

:root {
  /* Core palette */
  --bg-deep: #13100C;
  --bg-primary: #1A1611;
  --bg-secondary: #221E18;
  --bg-elevated: #2A2520;
  --bg-surface: #332E27;

  /* Amber / Honey */
  --amber: #F5A623;
  --amber-bright: #FFB83D;
  --amber-dim: #C4841C;
  --amber-glow: rgba(245, 166, 35, 0.25);
  --amber-ghost: rgba(245, 166, 35, 0.08);

  /* Semantic */
  --solved: #5CB85C;
  --solved-dim: #4A9A4A;
  --solved-glow: rgba(92, 184, 92, 0.2);
  --error: #D9534F;
  --error-dim: #B5403D;
  --error-glow: rgba(217, 83, 79, 0.2);

  /* Text */
  --text-primary: #F5F0E8;
  --text-secondary: #A09888;
  --text-muted: #6B6055;
  --text-inverse: #1A1611;

  /* Surfaces */
  --tile-bg: #2D2722;
  --tile-border: #3D362F;
  --key-bg: #47403A;
  --key-text: #D4CCBF;
  --key-active: #4D463F;

  /* Sizing */
  --header-h: 44px;
  --info-h: 28px;
  --keyboard-h: 170px;
  --footer-h: 24px;
  --max-width: 520px;
  --tile-gap: 4px;
  --tile-radius: 4px;

  /* Type */
  --font-display: 'Syne', sans-serif;
  --font-body: 'DM Sans', sans-serif;

  /* Motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-deep);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

/* Honeycomb background texture */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='100' viewBox='0 0 56 100'%3E%3Cpath d='M28 66L0 50L0 16L28 0L56 16L56 50L28 66ZM28 100L0 84L0 50L28 34L56 50L56 84L28 100Z' stroke='%23F5A623' stroke-width='0.5' fill='none' opacity='0.04'/%3E%3C/svg%3E");
  background-size: 56px 100px;
  pointer-events: none;
  z-index: 0;
}

/* --- App Layout --- */
#app {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 100%;
  margin: 0 auto;
  z-index: 1;
}

.hidden { display: none !important; }

/* --- Header --- */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  padding: 0 12px;
  border-bottom: 1px solid rgba(51, 46, 39, 0.6);
  flex-shrink: 0;
  overflow: hidden;
}

.header-left, .header-right {
  width: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.header-right { justify-content: flex-end; }

.header-center {
  flex: 1;
  display: flex;
  justify-content: center;
  min-width: 0;
  overflow: hidden;
}

.logo {
  display: flex;
  align-items: center;
  gap: 6px;
}

.logo-bee {
  font-size: 22px;
  line-height: 1;
  filter: drop-shadow(0 0 6px var(--amber-glow));
}

.logo-text {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 2px;
  color: var(--text-primary);
  line-height: 1;
  text-shadow: 0 0 20px var(--amber-ghost);
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1.5px solid var(--bg-surface);
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  border-color: var(--amber-dim);
  color: var(--amber);
}

/* --- Game Info Bar --- */
#gameInfo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  height: var(--info-h);
  flex-shrink: 0;
  padding: 0 16px;
}

.info-tag {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Points display */
.points-display {
  display: flex;
  align-items: center;
  gap: 7px;
}

.points-icon {
  font-size: 13px;
  color: var(--amber);
  line-height: 1;
  filter: drop-shadow(0 0 3px var(--amber-glow));
}

.points-value {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 15px;
  color: var(--amber);
  min-width: 28px;
  text-align: center;
  transition: color 0.3s ease;
  text-shadow: 0 0 12px var(--amber-glow);
}

.points-value.points-lost {
  animation: points-flash 0.6s ease;
}

@keyframes points-flash {
  0% { color: var(--amber); transform: scale(1); }
  25% { color: var(--error); transform: scale(1.2); }
  100% { color: var(--amber); transform: scale(1); }
}

.points-bar {
  width: 72px;
  height: 5px;
  background: var(--bg-surface);
  border-radius: 3px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.3);
}

.points-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--amber-dim), var(--amber));
  border-radius: 3px;
  transition: width 0.5s var(--ease-out);
  box-shadow: 0 0 6px var(--amber-glow);
}

.points-bar-fill.points-critical {
  background: linear-gradient(90deg, var(--error-dim), var(--error));
  box-shadow: 0 0 6px var(--error-glow);
}

/* --- Game Board --- */
#gameBoard {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 12px 2px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

#gameBoard::-webkit-scrollbar { display: none; }

/* --- Word Row --- */
.word-row {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 8px 10px 6px;
  border-radius: 10px;
  border: 1.5px solid transparent;
  background: var(--bg-primary);
  cursor: pointer;
  transition: all 0.25s var(--ease-out);
  position: relative;
  border-left: 3px solid transparent;
}

/* Difficulty-colored left accent */
.word-row[data-difficulty="1"] { border-left-color: #5CB85C; }
.word-row[data-difficulty="2"] { border-left-color: #A8C84A; }
.word-row[data-difficulty="3"] { border-left-color: #F5A623; }
.word-row[data-difficulty="4"] { border-left-color: #E8733A; }
.word-row[data-difficulty="5"] { border-left-color: #D9534F; }

.word-row:hover:not(.solved):not(.game-over) {
  border-color: var(--bg-surface);
  background: var(--bg-secondary);
}

/* Preserve left accent on hover */
.word-row[data-difficulty="1"]:hover:not(.solved):not(.game-over) { border-left-color: #5CB85C; }
.word-row[data-difficulty="2"]:hover:not(.solved):not(.game-over) { border-left-color: #A8C84A; }
.word-row[data-difficulty="3"]:hover:not(.solved):not(.game-over) { border-left-color: #F5A623; }
.word-row[data-difficulty="4"]:hover:not(.solved):not(.game-over) { border-left-color: #E8733A; }
.word-row[data-difficulty="5"]:hover:not(.solved):not(.game-over) { border-left-color: #D9534F; }

.word-row.selected {
  border-color: var(--amber-dim);
  border-left-color: var(--amber) !important;
  background: var(--bg-secondary);
  box-shadow: 0 0 20px var(--amber-ghost), inset 0 0 20px var(--amber-ghost);
}

.word-row.solved {
  border-color: transparent;
  border-left-color: var(--solved) !important;
  background: rgba(92, 184, 92, 0.05);
  cursor: default;
}

.word-row.wrong-flash {
  animation: row-shake 0.5s var(--ease-out);
}

@keyframes row-shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-6px); }
  30% { transform: translateX(5px); }
  45% { transform: translateX(-4px); }
  60% { transform: translateX(3px); }
  75% { transform: translateX(-2px); }
}

/* --- Tiles --- */
.word-tiles {
  display: flex;
  gap: var(--tile-gap);
  justify-content: center;
  margin-bottom: 3px;
}

.tile {
  width: var(--tile-size, 36px);
  height: var(--tile-size, 36px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: calc(var(--tile-size, 36px) * 0.5);
  line-height: 1;
  color: var(--text-primary);
  background: var(--tile-bg);
  border: 1.5px solid var(--tile-border);
  border-radius: var(--tile-radius);
  transition: all 0.3s var(--ease-out);
  position: relative;
  perspective: 600px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.15);
}

/* Subtle hex watermark on empty tiles */
.tile:empty::before {
  content: '';
  position: absolute;
  width: 60%;
  height: 60%;
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  background: var(--amber);
  opacity: 0.04;
}

.tile.revealed {
  background: var(--amber);
  color: var(--text-inverse);
  border-color: var(--amber-dim);
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
  box-shadow: 0 0 8px var(--amber-glow), inset 0 1px 0 rgba(255,255,255,0.15);
}

.tile.solved {
  background: var(--solved);
  color: var(--text-inverse);
  border-color: var(--solved-dim);
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
  box-shadow: 0 0 6px var(--solved-glow), inset 0 1px 0 rgba(255,255,255,0.1);
}

.tile.submit-typed {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--amber-dim);
}

.tile.submit-locked {
  opacity: 0.7;
}

.tile.submit-cursor {
  border-color: var(--amber);
  box-shadow: 0 0 8px var(--amber-glow);
  animation: cursor-blink 1s step-end infinite;
}

@keyframes cursor-blink {
  0%, 100% { border-color: var(--amber); }
  50% { border-color: var(--tile-border); }
}

/* Tile reveal animation */
.tile.revealing {
  animation: tile-flip 0.5s var(--ease-out) forwards;
}

@keyframes tile-flip {
  0% { transform: rotateX(0deg); }
  45% { transform: rotateX(90deg); }
  55% { transform: rotateX(90deg); }
  100% { transform: rotateX(0deg); }
}

/* Tile solved pulse */
.tile.solving {
  animation: tile-solve 0.6s var(--ease-out) forwards;
}

@keyframes tile-solve {
  0% { transform: scale(1); background: var(--amber); }
  40% { transform: scale(1.1); background: var(--amber-bright); }
  100% { transform: scale(1); background: var(--solved); }
}

/* --- Clue --- */
.word-clue {
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--text-secondary);
  text-align: center;
  padding: 2px 6px 0;
  font-style: italic;
  opacity: 0.85;
}

.word-row.solved .word-clue {
  color: var(--text-muted);
  opacity: 0.6;
}

/* Submit hint under selected row */
.submit-hint {
  font-size: 10px;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--amber);
  text-align: center;
  margin-top: 4px;
  animation: fadeIn 0.2s ease;
}

/* --- Keyboard --- */
#keyboard {
  padding: 6px 4px 8px;
  flex-shrink: 0;
  max-width: 520px;
  margin: 0 auto;
  width: 100%;
  border-top: 1px solid rgba(51, 46, 39, 0.6);
}

.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-bottom: 4px;
}

.key-spacer-half {
  flex: 0.5;
}

.key {
  flex: 1;
  max-width: 42px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  color: var(--key-text);
  background: linear-gradient(180deg, #504840 0%, var(--key-bg) 100%);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.06);
}

.key::after {
  content: '';
  position: absolute;
  inset: 0;
  background: white;
  opacity: 0;
  transition: opacity 0.15s ease;
  border-radius: 6px;
}

.key:active::after {
  opacity: 0.12;
}

.key-wide {
  flex: 1.6;
  max-width: 66px;
  font-size: 11px;
  letter-spacing: 0.5px;
}

.key.hit {
  background: linear-gradient(180deg, var(--amber-bright) 0%, var(--amber) 100%);
  color: var(--text-inverse);
  box-shadow: 0 1px 6px var(--amber-glow), inset 0 1px 0 rgba(255,255,255,0.2);
  text-shadow: 0 1px 1px rgba(0,0,0,0.15);
}

.key.miss {
  background: var(--bg-deep);
  color: var(--text-muted);
  opacity: 0.35;
  box-shadow: none;
}

.key.miss-flash {
  animation: key-miss-flash 0.4s ease;
}

@keyframes key-miss-flash {
  0% { background: var(--key-bg); }
  30% { background: var(--error-dim); }
  100% { background: var(--bg-deep); }
}

/* --- Footer --- */
#footer {
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--footer-h);
  flex-shrink: 0;
}

.footer-text {
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  opacity: 0.6;
}

.footer-text strong {
  color: var(--text-secondary);
  font-weight: 600;
  opacity: 1;
}

/* ============================================
   MODALS
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 8, 5, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

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

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--bg-surface);
  border-radius: 16px;
  width: 100%;
  max-width: 400px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
  position: relative;
  animation: modalSlideUp 0.35s var(--ease-out);
}

@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.modal-close:hover {
  color: var(--text-primary);
  background: var(--bg-surface);
}

.modal-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 1px;
  text-align: center;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.modal-body { font-size: 14px; }

/* --- Help Modal --- */
.modal-help {
  max-width: 380px;
}

.help-intro {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.55;
  font-size: 13.5px;
}

.help-intro strong {
  color: var(--amber);
  font-weight: 600;
}

.help-rules {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 20px;
}

.help-rule {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 0;
  border-bottom: 1px solid var(--bg-surface);
}

.help-rule:first-child { padding-top: 0; }
.help-rule:last-child { border-bottom: none; padding-bottom: 0; }

.help-rule-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--amber-ghost);
  border-radius: 8px;
  color: var(--amber);
  margin-top: 1px;
}

.help-rule-body {
  flex: 1;
  min-width: 0;
}

.help-rule-heading {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 3px;
  letter-spacing: 0.2px;
}

.help-rule-body p {
  color: var(--text-secondary);
  line-height: 1.5;
  font-size: 13px;
}

.help-rule-body p strong {
  color: var(--amber);
  font-weight: 600;
}

.help-rule-body p em {
  font-style: italic;
  color: var(--text-primary);
}

.help-difficulty {
  background: var(--bg-primary);
  border-radius: 10px;
  padding: 14px 16px;
}

.help-diff-label {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 10px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  font-weight: 500;
}

.diff-track {
  padding: 0 4px;
}

.diff-gradient {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, #5CB85C 0%, #A8C84A 25%, #F5A623 50%, #E8733A 75%, #D9534F 100%);
  margin-bottom: 6px;
}

.diff-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  font-weight: 500;
}

/* --- Stats Modal --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.stat-cell {
  text-align: center;
  padding: 12px 4px 10px;
  background: var(--bg-primary);
  border-radius: 10px;
  border: 1px solid var(--bg-surface);
}

.stat-value {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 24px;
  color: var(--amber);
  line-height: 1;
}

.stat-label {
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  margin-top: 6px;
  font-weight: 500;
}

.stats-subtitle {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 12px;
}

.star-dist {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dist-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dist-label {
  font-size: 13px;
  color: var(--text-secondary);
  width: 18px;
  text-align: right;
  flex-shrink: 0;
}

.dist-bar-track {
  flex: 1;
  height: 22px;
  background: var(--bg-primary);
  border-radius: 4px;
  overflow: hidden;
}

.dist-bar {
  height: 100%;
  min-width: 24px;
  background: var(--amber-dim);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-inverse);
  transition: width 0.5s var(--ease-out);
}

.dist-bar.highlight {
  background: var(--amber);
}

/* --- Results Modal --- */
.modal-result {
  text-align: center;
}

.result-header {
  margin-bottom: 16px;
}

.result-bee {
  font-size: 40px;
  margin-bottom: 4px;
  animation: bee-bounce 0.6s var(--ease-bounce);
}

@keyframes bee-bounce {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.result-badge {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--text-inverse);
  background: linear-gradient(135deg, var(--amber), #FFD700, var(--amber));
  background-size: 200% 200%;
  animation: shimmer 2s ease infinite;
  padding: 4px 14px;
  border-radius: 20px;
  margin-top: 4px;
}

@keyframes shimmer {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.result-stars {
  font-size: 32px;
  letter-spacing: 4px;
  margin-bottom: 12px;
}

.result-grid {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 12px;
}

.result-cell {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.result-cell.win { background: var(--solved); }
.result-cell.lose { background: var(--error-dim); }

.result-guesses {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

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

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 42px;
  background: none;
  color: var(--amber);
  border: 1.5px solid var(--amber-dim);
  border-radius: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary svg {
  opacity: 0.8;
}

.btn-primary:hover {
  background: rgba(218, 165, 32, 0.08);
  border-color: var(--amber);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  width: 100%;
  height: 38px;
  background: none;
  color: var(--text-muted);
  border: 1px solid var(--bg-surface);
  border-radius: 10px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  border-color: var(--text-muted);
  color: var(--text-secondary);
}

.share-toast {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--solved);
  color: white;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 16px;
  border-radius: 20px;
  animation: toast-pop 2s var(--ease-out) forwards;
}

@keyframes toast-pop {
  0% { opacity: 0; transform: translateX(-50%) translateY(10px); }
  15% { opacity: 1; transform: translateX(-50%) translateY(0); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* ============================================
   GAME COMPLETION CELEBRATION
   ============================================ */
.celebration-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}

.hex-burst {
  position: absolute;
  width: 20px;
  height: 23px;
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  background: var(--amber);
  opacity: 0;
  animation: hex-float 1.5s var(--ease-out) forwards;
}

@keyframes hex-float {
  0% { opacity: 0.8; transform: scale(0.5) translateY(0); }
  100% { opacity: 0; transform: scale(1) translateY(-100px); }
}

/* ============================================
   LEADERBOARD
   ============================================ */

.leaderboard-section {
  margin-top: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid;
  border-image: linear-gradient(90deg, transparent 0%, var(--amber-dim) 50%, transparent 100%) 1;
}

/* Name input */
.name-input-group {
  text-align: center;
}

.name-label {
  display: block;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.name-input-row {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.name-input {
  flex: 1;
  max-width: 200px;
  height: 42px;
  background: var(--bg-primary);
  border: 1.5px solid var(--bg-surface);
  border-radius: 10px;
  padding: 0 14px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  outline: none;
  transition: border-color 0.2s ease;
}

.name-input::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

.name-input:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 2px var(--amber-glow);
}

.name-input.input-error {
  animation: shake-input 0.4s ease;
  border-color: var(--error);
}

@keyframes shake-input {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

.btn-submit-score {
  height: 42px;
  padding: 0 20px;
  background: var(--amber);
  color: var(--text-inverse);
  border: none;
  border-radius: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-submit-score:hover:not(:disabled) {
  background: var(--amber-bright);
  transform: translateY(-1px);
}

.btn-submit-score:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Leaderboard content */
.leaderboard-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.leaderboard-title svg {
  color: var(--amber);
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.leaderboard-loading,
.leaderboard-empty {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  padding: 16px 0;
  font-style: italic;
}

.leaderboard-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--bg-primary);
  transition: all 0.15s ease;
}

.leaderboard-entry.highlight {
  background: rgba(212, 168, 67, 0.12);
  border: 1px solid rgba(212, 168, 67, 0.25);
  padding: 6px 9px; /* compensate for border */
}

.lb-rank {
  width: 26px;
  text-align: center;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
}

.leaderboard-entry:nth-child(1) .lb-rank,
.leaderboard-entry:nth-child(2) .lb-rank,
.leaderboard-entry:nth-child(3) .lb-rank {
  font-size: 16px;
}

.lb-name {
  flex: 1;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-entry.highlight .lb-name {
  color: var(--amber);
}

.lb-crown {
  font-size: 12px;
}

.lb-stars {
  font-size: 9px;
  letter-spacing: 0.5px;
  color: var(--amber-dim);
  flex-shrink: 0;
}

.lb-score {
  width: 32px;
  text-align: right;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--amber);
  flex-shrink: 0;
}

.leaderboard-footer {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 10px;
  font-style: italic;
}

/* ============================================
   RESPONSIVE
   ============================================ */

/* Small phones */
@media (max-width: 360px) {
  :root {
    --tile-gap: 3px;
  }

  .logo-text { font-size: 19px; letter-spacing: 2px; }
  .key { height: 44px; font-size: 13px; }
  .key-wide { font-size: 10px; }
  .word-clue { font-size: 11px; }
  #gameBoard { padding: 4px 8px 2px; gap: 3px; }
  .word-row { padding: 6px 8px 5px; }
}

/* Tablets and up */
@media (min-width: 600px) {
  .logo-text { font-size: 26px; letter-spacing: 5px; }
  .key { height: 54px; font-size: 15px; }
  .word-clue { font-size: 13px; }
  .modal { padding: 28px; }
}

/* Desktop */
@media (min-width: 1024px) {
  #app {
    max-width: 600px;
    margin: 0 auto;
  }
}

/* Landscape phone */
@media (max-height: 600px) and (orientation: landscape) {
  :root {
    --header-h: 40px;
    --info-h: 28px;
  }
  .key { height: 40px; }
  .word-row { padding: 4px 8px 3px; }
  #gameBoard { gap: 3px; padding: 4px 8px 2px; }
  .word-clue { font-size: 10px; }
}
