/* 100 Game — styles */

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
}

.title {
  font-size: 28px;
  font-weight: 700;
  color: #e94560;
  margin-bottom: 16px;
  letter-spacing: 2px;
}

/* Layout */
.app {
  display: flex;
  gap: 20px;
  max-width: 760px;
  width: 100%;
}

.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* Status bar */
.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 10px 16px;
  background: #16213e;
  border-radius: 8px;
  font-size: 15px;
  min-height: 44px;
  transition: background 0.3s;
}

.status-bar.won {
  background: #0d6b3d;
}

.status-bar.stuck {
  background: #8b1a1a;
}

.prediction {
  color: #f0a500;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
}

.prediction.hidden {
  display: none;
}

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 2px;
  width: min(520px, calc(100vw - 230px));
  background: #16213e;
  border-radius: 8px;
  padding: 4px;
}

.cell {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  background: #0f3460;
  border-radius: 3px;
  font-size: clamp(11px, 2.2vw, 15px);
  font-weight: 700;
  color: #506080;
  cursor: pointer;
  transition: background 0.12s, box-shadow 0.12s, color 0.12s;
  user-select: none;
}

.cell:hover {
  background: #1a4a7a;
}

.cell.filled {
  background: #1a3050;
  color: #7088a8;
  cursor: default;
}

.cell.filled:hover {
  background: #1a3050;
}

.cell.current {
  background: #e94560;
  color: #fff;
  box-shadow: 0 0 10px rgba(233, 69, 96, 0.5);
  cursor: default;
}

.cell.current:hover {
  background: #e94560;
}

.cell.valid-move {
  background: #0a6640;
  color: #fff;
  cursor: pointer;
  animation: pulse 1.5s ease-in-out infinite;
  font-size: clamp(10px, 2vw, 13px);
}

.cell.valid-move:hover {
  background: #0d8050;
  box-shadow: 0 0 8px rgba(13, 128, 80, 0.4);
}

.cell.preview {
  background: #f0a500 !important;
  color: #1a1a2e !important;
  box-shadow: 0 0 14px rgba(240, 165, 0, 0.6);
  animation: none;
}

.cell.idle-hover:hover {
  background: #2a5a8a;
  cursor: pointer;
}

@keyframes pulse {
  0%, 100% { opacity: 0.75; }
  50% { opacity: 1; }
}

/* Controls */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  width: 100%;
}

button {
  padding: 8px 14px;
  border: none;
  border-radius: 6px;
  background: #0f3460;
  color: #e0e0e0;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

button:hover:not(:disabled) {
  background: #1a5a9a;
}

button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

button.hidden {
  display: none;
}

button.danger {
  background: #8b1a1a;
}

.checkbox-control {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: #8090b0;
  cursor: pointer;
  user-select: none;
}

.checkbox-control input[type="checkbox"] {
  accent-color: #f0a500;
  cursor: pointer;
}

button.danger:hover {
  background: #a52020;
}

.speed-control {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #8090b0;
}

#speed-slider {
  width: 80px;
  accent-color: #e94560;
}

#speed-value {
  min-width: 40px;
  font-variant-numeric: tabular-nums;
}

/* History panel */
.history-panel {
  width: 170px;
  min-width: 170px;
  background: #16213e;
  border-radius: 8px;
  padding: 12px;
  max-height: calc(min(520px, calc(100vw - 230px)) + 80px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.history-panel h3 {
  font-size: 13px;
  color: #8090b0;
  margin-bottom: 4px;
}

.history-hint {
  font-size: 10px;
  color: #506080;
  margin-bottom: 8px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
  overflow-y: auto;
}

.history-item {
  padding: 3px 6px;
  font-size: 11px;
  font-family: 'Consolas', 'SF Mono', monospace;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.12s;
  white-space: nowrap;
}

.history-item:hover {
  background: #1a4a7a;
}

.history-item.active {
  background: #e94560;
  color: #fff;
}

/* Keyboard hint */
.keyboard-hint {
  margin-top: 14px;
  font-size: 11px;
  color: #404060;
  text-align: center;
  max-width: 600px;
  line-height: 1.6;
}

/* Responsive — stack vertically on narrow screens */
@media (max-width: 680px) {
  .app {
    flex-direction: column;
    align-items: center;
  }

  .grid {
    width: min(520px, calc(100vw - 32px));
  }

  .history-panel {
    width: 100%;
    max-height: 140px;
    flex-direction: column;
  }

  .history-list {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 2px;
  }

  .history-item {
    padding: 2px 5px;
    font-size: 10px;
  }
}
