:root {
  --blue-1: #1a47ff;
  --blue-2: #4fb0ff;
  --panel-bg: linear-gradient(180deg, #ffca5f, #ffae34);
  --tile-color: #ffffff;
  --tile-shadow: rgba(0, 0, 0, 0.2);
  --text-dark: #1a1a1a;
  --accent: #ff7b21;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Poppins', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: radial-gradient(circle at top, #2149ff, #0a1034);
  color: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.app-wrapper {
  width: min(1200px, 100%);
  background: rgba(255, 255, 255, 0.08);
  border-radius: 28px;
  padding: 32px;
  box-shadow: 0 25px 55px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
}

.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.logo {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 1px;
}

.header-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.primary-btn,
.secondary-btn,
.google-btn {
  border: none;
  border-radius: 999px;
  padding: 10px 20px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s;
}

.primary-btn {
  background: #fff;
  color: #0a1749;
  box-shadow: 0 4px 14px rgba(255, 255, 255, 0.3);
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.google-btn {
  background: #fff;
  color: #1f1f1f;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.primary-btn:hover,
.secondary-btn:hover,
.google-btn:hover {
  transform: translateY(-2px);
}

.game-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 28px;
}

.words-panel {
  background: var(--panel-bg);
  border-radius: 24px;
  padding: 20px;
  color: var(--text-dark);
  min-height: 560px;
  box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.35);
}

.words-panel h2 {
  margin-top: 0;
  margin-bottom: 12px;
}

.score-meter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  margin-bottom: 10px;
}

.status-line {
  font-size: 0.95rem;
  margin: 10px 0 18px;
  color: rgba(0, 0, 0, 0.75);
}

.status-line.error {
  color: #a10f0f;
}

.words-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 420px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.words-list li {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 12px;
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  color: #1c1c1c;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.hidden-stats {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.hidden-stats h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.hidden-stat-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hidden-stat-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.7);
  padding: 6px 10px;
  border-radius: 10px;
  font-weight: 600;
  color: #2a2a2a;
}

.board-panel {
  background: var(--panel-bg);
  border-radius: 32px;
  padding: 30px;
  min-height: 600px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #1e1e1e;
  box-shadow: inset 0 0 15px rgba(255, 255, 255, 0.35);
}

.board-shell {
  position: relative;
  padding: 30px;
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.55));
  box-shadow: inset 0 -12px 20px rgba(0, 0, 0, 0.08);
  touch-action: none;
  user-select: none;
}

.board-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(60px, 1fr));
  gap: 16px;
  touch-action: none;
}

.board-grid.disabled {
  pointer-events: none;
  opacity: 0.5;
}

.tile {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 22px;
  background: var(--tile-color);
  border: none;
  font-size: clamp(1.8rem, 4vw, 2.7rem);
  font-weight: 700;
  color: #222;
  box-shadow: 0 16px 25px var(--tile-shadow);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.2s ease, box-shadow 0.12s;
}

.tile:hover {
  transform: translateY(-3px);
}

.tile.selected {
  background: #ffe7b8;
  box-shadow: 0 10px 18px rgba(255, 167, 37, 0.6);
}

.tile.valid {
  background: #c9ffd9;
}

.tile.invalid {
  background: #ffd6d6;
}

.bottom-info {
  margin-top: 28px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 18px;
  padding: 18px 24px;
  align-items: center;
}

.timer-block {
  font-size: 1rem;
  font-weight: 600;
  text-transform: uppercase;
  color: #25308f;
}

#timerValue {
  font-size: clamp(2rem, 6vw, 2.8rem);
  font-weight: 700;
  color: #101540;
}

.current-word-block {
  text-align: center;
  flex: 1;
}

.current-word-block strong {
  display: block;
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  margin-top: 6px;
}

.progress-block {
  flex: 1;
}

.progress-bar {
  width: 100%;
  height: 14px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 999px;
  margin-top: 10px;
  overflow: hidden;
}

.progress-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #2b71ff, #73d2ff);
  border-radius: inherit;
  transform-origin: left;
  transition: width 0.2s ease;
}

.points-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.points-float {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: #1a6b2a;
  font-weight: 700;
  font-size: 1.4rem;
  animation: floatUp 1s ease forwards;
}

@keyframes floatUp {
  0% {
    opacity: 1;
    transform: translate(-50%, -20px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -80px) scale(1.3);
  }
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 32, 0.75);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
  z-index: 20;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: #fff;
  color: #121212;
  border-radius: 20px;
  padding: 30px;
  width: min(420px, 90%);
  position: relative;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.3);
}

.modal-close {
  position: absolute;
  right: 12px;
  top: 12px;
  border: none;
  background: transparent;
  font-size: 1.5rem;
  cursor: pointer;
  color: #333;
}

.auth-content {
  width: min(460px, 94%);
}

#authForm {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#authForm input {
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  padding: 10px 12px;
  font-size: 1rem;
}

.auth-actions {
  display: flex;
  gap: 10px;
}

.divider {
  text-align: center;
  margin: 16px 0;
  font-weight: 600;
  color: rgba(0, 0, 0, 0.55);
}

.leaderboard-list {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
  max-height: 400px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.leaderboard-list li {
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(63, 97, 255, 0.08);
  display: flex;
  justify-content: space-between;
  font-weight: 600;
}

.final-score {
  font-size: 1.4rem;
  margin: 16px 0;
}

.small-hint {
  font-size: 0.85rem;
  color: rgba(0, 0, 0, 0.6);
}

.all-words-section {
  margin-top: 18px;
  max-height: 280px;
  overflow-y: auto;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  padding-top: 12px;
}

.all-words-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-weight: 600;
}

.length-group {
  background: rgba(0, 0, 0, 0.03);
  border-radius: 12px;
  padding: 10px 12px;
}

.length-title {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: #1b2a60;
}

.pills-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.all-words-pill {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(17, 64, 255, 0.12);
  color: #1a237e;
  font-size: 0.95rem;
}

.all-words-pill.found {
  background: rgba(30, 150, 0, 0.15);
  color: #13630a;
}

@media (max-width: 960px) {
  .game-layout {
    grid-template-columns: 1fr;
  }

  .words-panel {
    min-height: unset;
  }
}

@media (max-width: 640px) {
  body {
    padding: 12px;
  }

  .app-wrapper {
    padding: 20px;
  }

  .main-header {
    flex-direction: column;
    gap: 12px;
  }

  .header-buttons {
    width: 100%;
    justify-content: center;
  }

  .board-panel {
    padding: 20px;
  }

  .board-grid {
    gap: 10px;
  }

  .tile {
    border-radius: 18px;
    font-size: 1.8rem;
  }

  .bottom-info {
    flex-direction: column;
    text-align: center;
  }

  .auth-actions {
    flex-direction: column;
  }
}
