/* Word Hunt game styles */

/* Override default layout constraints */
main {
  max-width: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
}

#game-root {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #0f1923;
  color: #e0e8f0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* ── Header ─────────────────────────────────────────────────────── */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 70px 14px 20px; /* extra right padding avoids overlap with fixed theme toggle (40px + 10px gap) */
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
}

.back-btn {
  color: #7a9ab0;
  text-decoration: none;
  font-size: 0.88em;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  transition: all 0.2s;
  white-space: nowrap;
}

.back-btn:hover,
.back-btn:focus {
  background: rgba(255, 255, 255, 0.1);
  color: #e0e8f0;
}

.back-btn:focus-visible {
  outline: 2px solid #5568d3;
  outline-offset: 2px;
}

.game-header h1 {
  font-size: 1.4em;
  font-weight: 700;
  margin: 0;
  color: #ffffff;
  letter-spacing: 0.02em;
}

#score-display {
  font-size: 0.88em;
  color: #7a9ab0;
  min-width: 60px;
  text-align: right;
}

/* ── Game body ──────────────────────────────────────────────────── */
.game-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* ── Found-words sidebar ─────────────────────────────────────────── */
.found-words-panel {
  width: 280px;
  min-width: 260px;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  padding: 20px;
  overflow-y: auto;
  flex-shrink: 0;
}

.puzzle-info {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.puzzle-info h2 {
  font-size: 1em;
  font-weight: 700;
  color: #fff;
  margin: 0 0 3px;
}

#date-display {
  font-size: 0.78em;
  color: #5a7080;
  margin: 0 0 12px;
}

.progress-bar-wrap {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  height: 5px;
  margin-bottom: 6px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #5568d3, #7088e8);
  border-radius: 4px;
  transition: width 0.5s ease;
  width: 0%;
}

#progress-text {
  font-size: 0.82em;
  color: #6a8090;
  margin: 0;
}

.found-words-section h2 {
  font-size: 0.92em;
  font-weight: 700;
  color: #c0d0e0;
  margin: 0 0 14px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.length-group {
  margin-bottom: 18px;
}

.length-group h3 {
  font-size: 0.82em;
  font-weight: 600;
  color: #7a9ab0;
  margin: 0 0 7px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.word-list {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 10px;
  margin-bottom: 5px;
}

.found-word {
  font-size: 0.9em;
  color: #b8cedd;
  font-weight: 500;
}

.words-remaining {
  font-size: 0.76em;
  color: #7a9ab0;
  margin: 0;
  font-style: italic;
}

.words-remaining.complete {
  color: #4caf7d;
  font-style: normal;
}

/* ── Grid panel ──────────────────────────────────────────────────── */
.grid-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 20px;
  gap: 20px;
  overflow-y: auto;
}

/* ── Current-word display ────────────────────────────────────────── */
.word-display-area {
  text-align: center;
  min-height: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.current-word {
  font-size: 2em;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #e4eef8;
  min-height: 1.2em;
  text-transform: uppercase;
}

.word-feedback {
  font-size: 0.88em;
  color: #4a6070;
  min-height: 1.3em;
  transition: color 0.2s;
}

.word-feedback.success {
  color: #4caf7d;
}

.word-feedback.error {
  color: #e05c6c;
}

/* ── Letter grid ─────────────────────────────────────────────────── */
.letter-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  max-width: 340px;
  width: 100%;
}

.letter-tile {
  aspect-ratio: 1;
  background: #182b3c;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  font-size: 1.55em;
  font-weight: 700;
  color: #b8d0e4;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.12s, box-shadow 0.15s;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  line-height: 1;
}

.letter-tile:hover {
  background: #1f3a50;
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.letter-tile:focus-visible {
  outline: 2px solid #5568d3;
  outline-offset: 2px;
}

.letter-tile.selected {
  background: #1e3f60;
  border-color: #4a68c8;
  color: #e4f0ff;
  transform: translateY(-2px);
  box-shadow: 0 4px 18px rgba(74, 104, 200, 0.45);
}

.letter-tile.first-selected {
  background: #2a4e74;
  border-color: #6080d8;
}

/* Shake animation for invalid word */
.letter-tile.shake {
  animation: shake 0.38s ease;
}

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

/* Flash animation for correctly found word */
.letter-tile.found {
  background: #1a5040 !important;
  border-color: #4caf7d !important;
  color: #9ce8c0 !important;
  animation: found-bounce 0.45s ease;
}

@keyframes found-bounce {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.12); }
  65%  { transform: scale(0.94); }
  100% { transform: scale(1); }
}

/* ── Controls ────────────────────────────────────────────────────── */
.grid-controls {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 340px;
}

.control-btn {
  flex: 1;
  padding: 12px 10px;
  border: none;
  border-radius: 10px;
  font-size: 0.9em;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s, transform 0.1s;
}

.control-btn:active {
  transform: scale(0.97);
}

.control-btn.primary {
  background: #3d56c0;
  color: #fff;
}

.control-btn.primary:hover {
  background: #4d66d0;
}

.control-btn.primary:focus-visible {
  outline: 2px solid #7090f0;
  outline-offset: 2px;
}

.control-btn.secondary {
  background: rgba(255, 255, 255, 0.07);
  color: #8090a4;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.control-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #b0c0d0;
}

.control-btn.secondary:focus-visible {
  outline: 2px solid #5568d3;
  outline-offset: 2px;
}

/* ── Keyboard hint ───────────────────────────────────────────────── */
.keyboard-hint {
  font-size: 0.74em;
  color: #8090a4;
  text-align: center;
}

/* ── Completion message ──────────────────────────────────────────── */
.completion-msg {
  padding: 18px 22px;
  background: rgba(76, 175, 125, 0.12);
  border: 1px solid rgba(76, 175, 125, 0.28);
  border-radius: 14px;
  text-align: center;
  max-width: 340px;
  width: 100%;
}

.completion-msg h3 {
  color: #4caf7d;
  font-size: 1.1em;
  margin: 0 0 6px;
}

.completion-msg p {
  color: #8090a4;
  font-size: 0.88em;
  margin: 0;
  line-height: 1.4;
}

.share-btn {
  display: inline-block;
  margin-top: 14px;
  padding: 8px 22px;
  background: #3d56c0;
  color: #fff;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.88em;
  font-weight: 600;
  transition: background 0.18s;
}

.share-btn:hover {
  background: #4d66d0;
}

.share-btn:focus-visible {
  outline: 2px solid #7090f0;
  outline-offset: 2px;
}

/* ── Responsive: desktop tall screens ───────────────────────────── */
@media (min-width: 769px) and (min-height: 500px) {
  html, body {
    height: 100%;
    overflow: hidden;
  }

  main {
    height: 100%;
    overflow: hidden;
  }

  #game-root {
    height: 100%;
    overflow: hidden;
  }

  .game-body {
    overflow: hidden;
  }

  .found-words-panel {
    overflow-y: auto;
  }

  .grid-panel {
    overflow-y: auto;
  }
}

/* ── Responsive: mobile ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .game-body {
    flex-direction: column;
  }

  /* Visually swap panels on mobile: grid on top, words below */
  .found-words-panel {
    order: 2;
    width: 100%;
    min-width: 0;
    border-right: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 16px;
  }

  .grid-panel {
    order: 1;
    padding: 18px 14px;
    gap: 14px;
  }

  .letter-grid {
    max-width: 300px;
    gap: 8px;
  }

  .letter-tile {
    font-size: 1.35em;
    border-radius: 10px;
  }

  .current-word {
    font-size: 1.7em;
  }

  .grid-controls,
  .completion-msg {
    max-width: 300px;
  }

  .length-group {
    margin-bottom: 14px;
  }
}

@media (max-width: 400px) {
  .letter-grid {
    max-width: 256px;
    gap: 6px;
  }

  .letter-tile {
    font-size: 1.2em;
    border-radius: 8px;
  }

  .grid-controls,
  .completion-msg {
    max-width: 256px;
  }

  .game-header h1 {
    font-size: 1.15em;
  }
}
