/* Turbo Connect - Mobile-first, lightweight layout */

body main.turbo-connect-main {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: 0.9rem 0.9rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  box-sizing: border-box;
}

.game-board header {
  text-align: center;
}

.game-board header h1 {
  font-size: 1.45rem;
  margin: 0 0 0.25rem;
}

.game-board header .tagline {
  font-size: 0.8rem;
  margin: 0;
  opacity: 0.8;
}

/* Stats strip */
.game-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.stat-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.stat-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.7;
}

.stat-value {
  font-size: 1.05rem;
  font-weight: 600;
}

#timer {
  color: #22d3ee;
}

#score {
  color: #4ade80;
}

#strikes {
  color: #f97316;
}

.sound-btn {
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.9);
  color: #e5e7eb;
  border-radius: 10px;
  padding: 0.35rem 0.55rem;
  font-size: 0.85rem;
  cursor: pointer;
  min-width: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sound-btn:hover {
  border-color: rgba(148, 163, 184, 0.7);
}

/* Board container + canvas */
.game-board {
  width: 95%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(30, 64, 175, 0.4);
  padding: 0.5rem;
  box-sizing: border-box;
  /* Ensure proper centering - adjust if board appears off-center */
  position: relative;
  left: 0;
  right: 0;
}

.board-canvas-shell {
  width: 100%;
  box-sizing: border-box;
  position: relative;
  border-radius: 16px;
  padding: var(--border-width, 8px);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  background: linear-gradient(
    135deg,
    #ff0080,
    #ff8c00,
    #ffd700,
    #32cd32,
    #00bfff,
    #1e90ff,
    #8a2be2,
    #ff0080
  );
  background-size: 400% 400%;
  animation: rainbow-gradient 3s ease infinite;
  box-shadow: 
    0 0 20px rgba(255, 0, 128, var(--glow-intensity, 0.5)),
    0 0 40px rgba(255, 140, 0, var(--glow-intensity, 0.4)),
    0 0 60px rgba(255, 215, 0, var(--glow-intensity, 0.3)),
    0 0 80px rgba(50, 205, 50, var(--glow-intensity, 0.2));
  transition: 
    padding 0.05s ease-out,
    box-shadow 0.05s ease-out;
}

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

.game-canvas {
  width: calc(100% - (2 * var(--border-width, 8px)));
  max-width: 100%;
  height: auto;
  display: block;
  padding: 0;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.95);
  flex: 1 1 auto;
  margin: 0 auto;
  box-sizing: border-box;
}

/* Selected words */
.selected-words {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.3);
  box-sizing: border-box;
}

.selected-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.75;
  margin-bottom: 0.35rem;
}

.selected-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.selected-word-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: rgba(15, 23, 42, 0.9);
}

.selected-word-badge.group-1 {
  border-color: rgba(96, 165, 250, 0.7);
  background: rgba(96, 165, 250, 0.15);
  color: #bfdbfe;
}

.selected-word-badge.group-2 {
  border-color: rgba(52, 211, 153, 0.7);
  background: rgba(52, 211, 153, 0.15);
  color: #bbf7d0;
}

.selected-word-badge.group-3 {
  border-color: rgba(251, 191, 36, 0.7);
  background: rgba(251, 191, 36, 0.15);
  color: #fde68a;
}

.selected-word-badge.group-4 {
  border-color: rgba(244, 114, 182, 0.7);
  background: rgba(244, 114, 182, 0.15);
  color: #fbcfe8;
}

/* Found categories */
.found-categories {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.3);
  box-sizing: border-box;
}

.categories-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.75;
  margin-bottom: 0.35rem;
}

.categories-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.category-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  border: 1px solid rgba(34, 197, 94, 0.6);
  background: rgba(34, 197, 94, 0.15);
  font-size: 0.75rem;
}

.category-name {
  color: #bbf7d0;
}

.category-level {
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 600;
}

.category-level.level-1 {
  background: rgba(251, 191, 36, 0.2);
  color: #fbbf24;
}

.category-level.level-2 {
  background: rgba(34, 197, 94, 0.2);
  color: #22c55e;
}

.category-level.level-3 {
  background: rgba(59, 130, 246, 0.2);
  color: #3b82f6;
}

.category-level.level-4 {
  background: rgba(168, 85, 247, 0.2);
  color: #a855f7;
}

.category-level.level-bonus {
  background: rgba(249, 115, 22, 0.2);
  color: #f97316;
}

.no-categories {
  font-size: 0.75rem;
  opacity: 0.75;
  font-style: italic;
}

/* Actions */
.game-actions {
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
  width: 100%;
}

.btn {
  padding: 0.6rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  text-align: center;
  touch-action: manipulation;
}

.game-actions .btn {
  flex: 1 1 0;
}

.btn-primary {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #ffffff;
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.6);
  color: #e5e7eb;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.9);
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  width: 100%;
  max-width: 480px;
  background: #020617;
  border-radius: 16px;
  padding: 1.25rem 1.5rem 1.5rem;
  box-sizing: border-box;
}

.modal-content h2 {
  margin: 0 0 0.75rem;
  font-size: 1.4rem;
}

.final-score {
  margin: 1rem 0 1.25rem;
}

.score-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.9);
  margin-bottom: 0.5rem;
}

.score-label {
  font-size: 0.95rem;
  opacity: 0.8;
}

.score-value {
  font-size: 1.15rem;
  font-weight: 600;
  color: #4ade80;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}

.instructions-content {
  font-size: 0.9rem;
  line-height: 1.5;
  opacity: 0.9;
}

.instructions-content p {
  margin: 0.5rem 0;
}

.instructions-content ul {
  margin: 0.5rem 0;
  padding-left: 1.25rem;
}

.instructions-content li {
  margin: 0.25rem 0;
}

.sound-setting {
  padding: 0.6rem 0.5rem;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 10px;
  margin-bottom: 0.75rem;
  background: rgba(15, 23, 42, 0.5);
}

.sound-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.sound-toggle input {
  width: 16px;
  height: 16px;
}

.sound-setting small {
  display: block;
  margin-top: 0.35rem;
  color: rgba(224, 230, 240, 0.7);
  font-size: 0.75rem;
}

/* Larger screens */
@media (min-width: 768px) {
  body main.turbo-connect-main {
    max-width: 640px;
  }

  .game-actions {
    flex-direction: row;
  }

  .game-actions .btn {
    flex: 1;
  }

  .modal-actions {
    flex-direction: row;
  }
}
