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

body {
  background: #1a1a2e;
  color: #eee;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

#app {
  width: 100%;
  max-width: 480px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

header {
  text-align: center;
  width: 100%;
}

h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 2px;
  background: linear-gradient(135deg, #e94560, #f5a623);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#date-display {
  font-size: 0.85rem;
  color: #888;
  margin-top: 2px;
}

#stats {
  display: flex;
  gap: 20px;
  justify-content: center;
  margin-top: 8px;
  font-size: 0.95rem;
  color: #ccc;
}

#stats span {
  background: #16213e;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid #2a2a4a;
}

#message-bar {
  height: 28px;
  font-size: 1rem;
  font-weight: 600;
  color: #f5a623;
  text-align: center;
  transition: opacity 0.4s;
}

#grid-container {
  width: 100%;
  display: flex;
  justify-content: center;
}

#grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: 6px;
  width: min(90vw, 380px);
  height: min(90vw, 380px);
}

.cell {
  background: #16213e;
  border: 2px solid #2a2a4a;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, transform 0.1s, border-color 0.15s;
  color: #f0f0f0;
  text-transform: uppercase;
  position: relative;
}

.cell:hover {
  background: #1e2d5a;
  border-color: #4a4a7a;
}

.cell.sel {
  background: #2a4a1a;
  border-color: #66cc33;
  box-shadow: 0 0 12px rgba(100, 210, 50, 0.5);
  transform: scale(1.06);
  z-index: 2;
}


.cell.dragging {
  opacity: 0.35;
  transform: scale(0.92);
}

.cell.drag-over {
  background: #1a2e4a !important;
  border-color: #4488ff !important;
  border-style: dashed !important;
  box-shadow: 0 0 14px rgba(68, 136, 255, 0.5);
}

.cell.breaking {
  animation: break-away 0.5s forwards;
}

@keyframes break-away {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3) rotate(10deg); opacity: 0.7; background: #f5a623; }
  100% { transform: scale(0) rotate(20deg); opacity: 0; }
}

.cell.fall-in {
  animation: fall-in 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes fall-in {
  from { transform: translateY(-60px); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}

.cell.empty {
  background: #0d1117;
  border-color: #1a1a2e;
  cursor: default;
}

.cell.swap-anim {
  animation: swap-flash 0.2s ease-out;
}

@keyframes swap-flash {
  0% { background: #16213e; }
  50% { background: #4a6aa0; }
  100% { background: #16213e; }
}

#controls {
  display: flex;
  gap: 10px;
}

#restart-btn {
  background: #16213e;
  color: #aaa;
  border: 1px solid #2a2a4a;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

#restart-btn:hover {
  background: #2a1e1e;
  color: #e88;
  border-color: #5a3a3a;
}


#undo-btn {
  background: #16213e;
  color: #aaa;
  border: 1px solid #2a2a4a;
  padding: 6px 18px;
  border-radius: 20px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

#undo-btn:hover {
  background: #1e2d5a;
  color: #eee;
}

#hints-panel {
  width: 100%;
  background: #0f1824;
  border: 1px solid #2a2a4a;
  border-radius: 12px;
  padding: 12px 14px;
  animation: pop-in 0.2s ease-out;
}

#hints-panel.hidden {
  display: none;
}

#hints-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}

#hints-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #888;
}

#hints-count {
  font-size: 0.75rem;
  color: #555;
}

.hint-toggle {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.hint-lvl-btn {
  flex: 1;
  background: #16213e;
  color: #666;
  border: 1px solid #2a2a4a;
  padding: 4px 0;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: background 0.15s, color 0.15s;
}

.hint-lvl-btn.active {
  background: #1e3a6e;
  color: #88bbff;
  border-color: #3a6aae;
}

.hint-item {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 7px 4px;
  border-bottom: 1px solid #1a1a2e;
}

.hint-item:last-child { border-bottom: none; }

.hint-num {
  font-size: 0.7rem;
  font-weight: 700;
  color: #555;
  text-align: center;
}

.hint-clue {
  font-size: 0.82rem;
  color: #b0c0d8;
  line-height: 1.3;
}

.hint-answer {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: #446;
  white-space: nowrap;
  font-family: monospace;
}

.hint-item-done .hint-clue  { color: #4a7a4a; }
.hint-item-done .hint-answer {
  color: #66bb66;
  letter-spacing: 1px;
}

#found-words-container {
  width: 100%;
  min-height: 40px;
}

#found-words {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.found-word-tag {
  background: #1b4332;
  border: 1px solid #2d6a4f;
  color: #95d5b2;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  animation: pop-in 0.2s ease-out;
}

@keyframes pop-in {
  from { transform: scale(0.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

#win-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#win-overlay.hidden {
  display: none;
}

#win-box {
  background: #16213e;
  border: 2px solid #5588ff;
  border-radius: 20px;
  padding: 40px;
  text-align: center;
  animation: pop-in 0.3s ease-out;
}

#win-box h2 {
  font-size: 2rem;
  background: linear-gradient(135deg, #e94560, #f5a623);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
}

#win-stats {
  color: #ccc;
  margin-bottom: 24px;
  font-size: 1rem;
}

#next-board-info {
  margin-top: 20px;
}

#next-label {
  font-size: 0.8rem;
  color: #777;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

#next-board-countdown {
  font-size: 2rem;
  font-weight: 800;
  font-family: monospace;
  letter-spacing: 3px;
  background: linear-gradient(135deg, #e94560, #f5a623);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#how-btn {
  background: #16213e;
  color: #aaa;
  border: 1px solid #2a2a4a;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

#how-btn:hover {
  background: #1e2d5a;
  color: #eee;
}

#how-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

#how-overlay.hidden {
  display: none;
}

#how-box {
  position: relative;
  background: #16213e;
  border: 2px solid #2a4a7a;
  border-radius: 20px;
  padding: 32px 28px 28px;
  max-width: 440px;
  width: 90vw;
  animation: pop-in 0.25s ease-out;
}

#how-box h2 {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 1px;
  background: linear-gradient(135deg, #e94560, #f5a623);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 16px;
  text-align: center;
}

#close-how-btn {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  color: #666;
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

#close-how-btn:hover {
  color: #eee;
  background: #2a2a4a;
}

#instructions {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#instructions li {
  font-size: 0.85rem;
  color: #b0c0d8;
  line-height: 1.45;
  padding-left: 20px;
  position: relative;
}

#instructions li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: #f5a623;
}

#instructions li strong {
  color: #e0e8f8;
}
