/* Strands Game - Styles */
:root {
  --bg: #1a1a2e;
  --bg-card: #16213e;
  --grid-bg: #0f3460;
  --cell-bg: #1a1a3e;
  --cell-border: #2a2a5e;
  --cell-selected: #e94560;
  --cell-found: #4e8dff;
  --cell-spangram: #ffd700;
  --text: #eee;
  --text-dim: #888;
  --accent: #e94560;
  --accent2: #0f3460;
  --font-mono: 'Courier New', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Header */
header {
  width: 100%;
  max-width: 520px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--cell-border);
}

.logo {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 1px;
  background: linear-gradient(135deg, #4e8dff, #ffd700);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-right {
  display: flex;
  gap: 12px;
  align-items: center;
}

.header-btn {
  background: none;
  border: 1px solid var(--cell-border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.header-btn:hover { background: var(--cell-border); }
.header-btn.active { background: var(--cell-selected); border-color: var(--cell-selected); }

/* Theme & Info Bar */
.theme-bar {
  width: 100%;
  max-width: 520px;
  padding: 10px 16px;
  text-align: center;
  background: var(--bg-card);
}

.theme-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 4px;
}

.theme-text {
  font-size: 17px;
  font-weight: 600;
  font-style: italic;
}

.info-bar {
  width: 100%;
  max-width: 520px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  font-size: 13px;
  color: var(--text-dim);
}

.info-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Grid */
.grid-wrapper {
  width: 100%;
  max-width: 520px;
  padding: 0 12px;
  margin: 0 auto;
  position: relative;
  touch-action: manipulation;
}

.grid-container {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 4px;
  padding: 10px;
  background: var(--grid-bg);
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}

.grid-cell {
  background: var(--cell-bg);
  border: 2px solid var(--cell-border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(14px, 4vw, 22px);
  font-weight: 700;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all 0.15s ease;
  aspect-ratio: 1;
  position: relative;
}

.grid-cell:hover {
  background: var(--cell-border);
}

.grid-cell.selected {
  background: var(--cell-selected) !important;
  border-color: #ff6b81;
  transform: scale(1.05);
  z-index: 2;
  box-shadow: 0 0 12px rgba(233, 69, 96, 0.5);
}

.grid-cell.found-word {
  background: var(--cell-found) !important;
  border-color: #6aadff;
  cursor: default;
}

.grid-cell.found-spangram {
  background: var(--cell-spangram) !important;
  border-color: #ffed4a;
  cursor: default;
  color: #333;
}

/* Selected word preview */
.selected-preview {
  text-align: center;
  padding: 8px;
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--cell-selected);
  min-height: 40px;
  display: none;
}

/* Controls */
.controls {
  width: 100%;
  max-width: 520px;
  display: flex;
  gap: 10px;
  padding: 10px 16px;
  justify-content: center;
}

.btn {
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn:active { transform: scale(0.95); }

.btn-primary {
  background: var(--cell-selected);
  color: white;
  flex: 1;
  max-width: 200px;
}

.btn-primary:disabled {
  background: #444;
  color: #666;
  cursor: default;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--cell-border);
}

.btn-hint {
  background: #2d2d00;
  color: var(--cell-spangram);
  border: 1px solid #5a5a00;
}

.btn-shuffle {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--cell-border);
}

/* Word List Panel */
.word-list-panel {
  width: 100%;
  max-width: 520px;
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.word-item {
  padding: 4px 14px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 500;
  background: var(--bg-card);
  border: 1px solid var(--cell-border);
  transition: all 0.3s;
}

.word-item.found {
  background: var(--cell-found);
  color: white;
  border-color: var(--cell-found);
}

.word-item.pending {
  color: var(--text-dim);
  letter-spacing: 3px;
  opacity: 0.5;
  font-size: 12px;
}

.word-item.found-spangram-item {
  background: var(--cell-spangram);
  color: #333;
  border-color: var(--cell-spangram);
  font-weight: 700;
}

.word-item.pending-spangram {
  background: transparent;
  color: var(--cell-spangram);
  border-color: #5a5a00;
  font-size: 12px;
  letter-spacing: 3px;
  opacity: 0.6;
}

/* Feedback */
.feedback {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  padding: 10px 24px;
  border-radius: 20px;
  font-size: 15px;
  font-weight: 600;
  opacity: 0;
  transition: all 0.3s;
  z-index: 100;
  pointer-events: none;
  white-space: nowrap;
}

.feedback.active {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.feedback.success { background: #1a6b3c; color: #fff; }
.feedback.warning { background: #6b4f1a; color: #fff; }
.feedback.info { background: #1a3a6b; color: #fff; }
.feedback.hint { background: #3a3a00; color: #ffd700; }
.feedback.win { background: linear-gradient(135deg, #1a6b3c, #ffd700); color: #fff; }

/* Timer */
.timer {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-dim);
}

/* Results Overlay */
.results-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
}

.results-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.results-card {
  background: var(--bg-card);
  border: 1px solid var(--cell-border);
  border-radius: 16px;
  padding: 32px;
  max-width: 400px;
  width: 90%;
  text-align: center;
}

.results-title {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 4px;
}

.results-subtitle {
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 16px;
  font-style: italic;
}

.results-emojis {
  font-family: monospace;
  font-size: 14px;
  line-height: 1.6;
  margin: 16px 0;
  letter-spacing: 2px;
}

.results-stats {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin: 16px 0;
  font-size: 14px;
  color: var(--text-dim);
}

.results-btn {
  background: var(--cell-selected);
  color: white;
  padding: 12px 32px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 16px;
}

.results-btn:hover { opacity: 0.9; }

/* Mode Switcher */
.mode-bar {
  width: 100%;
  max-width: 520px;
  display: flex;
  gap: 0;
  padding: 0 16px;
}

.mode-btn {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--cell-border);
  background: var(--bg-card);
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-btn:first-child { border-radius: 8px 0 0 8px; }
.mode-btn:last-child { border-radius: 0 8px 8px 0; }
.mode-btn:not(:last-child) { border-right: none; }

.mode-btn.active {
  background: var(--accent2);
  color: white;
  border-color: var(--cell-found);
}

/* Bottom spacing */
.bottom-spacer { height: 40px; }

/* Responsive */
@media (max-width: 420px) {
  header { padding: 8px 12px; }
  .logo { font-size: 17px; }
  .grid-container { gap: 3px; padding: 8px; }
  .controls { padding: 8px 12px; }
  .btn { padding: 8px 16px; font-size: 13px; }
  .word-list-panel { padding: 8px 12px; }
}

/* Ad space placeholder */
.ad-space {
  width: 100%;
  max-width: 520px;
  min-height: 50px;
  background: var(--bg-card);
  border-radius: 8px;
  margin: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-dim);
  border: 1px dashed var(--cell-border);
}

/* Loading state */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-dim);
}
