/* =========================================
   SUDOKU GRID & POSSIBILITIES
========================================= */
#sudoku-board {
  display: grid;
  grid-template-columns: repeat(9, 65px);
  grid-template-rows: repeat(9, 65px);
  gap: 1px;
  background-color: var(--accent);
  border: 3px solid var(--accent);
  box-shadow: 0 0 30px rgba(20, 184, 166, 0.5);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.cell-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cell-input {
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  outline: none;
  text-align: center;
  font-size: 32px;
  font-weight: 600;
  color: var(--text-main);
  z-index: 2;
  font-family: "Inter", sans-serif;
}

.cell-possibilities {
  position: absolute;
  top: 4px;
  left: 6px;
  font-size: 11px;
  line-height: 1.15;
  color: #ef4444;
  white-space: pre;
  z-index: 1;
  font-family: monospace;
  pointer-events: none;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.bg-dark1 {
  background-color: rgba(15, 23, 42, 0.95);
}
.bg-dark2 {
  background-color: rgba(30, 41, 59, 0.95);
}
.user-input {
  color: var(--text-main);
}
.solved-input {
  color: var(--accent);
  font-style: italic;
  text-shadow: 0 0 8px rgba(20, 184, 166, 0.5);
}
.guess-input {
  color: #a855f7;
  font-style: italic;
  text-shadow: 0 0 8px rgba(168, 85, 247, 0.5);
}

/* =========================================
   CONTROLS & BUTTONS
========================================= */
.controls {
  margin-top: 30px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  width: 450px;
  position: relative;
}

button {
  background: rgba(15, 23, 42, 0.8);
  color: var(--primary);
  border: 1px solid var(--primary);
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: all 0.3s ease;
  backdrop-filter: blur(4px);
  font-family: "Inter", sans-serif;
}

button:hover:not(:disabled) {
  background: var(--gradient);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 15px rgba(20, 184, 166, 0.4);
  transform: translateY(-2px);
}

button:disabled {
  border-color: var(--border-color);
  color: var(--text-muted);
  cursor: not-allowed;
  background: rgba(15, 23, 42, 0.5);
}

.upload-btn {
  grid-column: span 2;
  background: rgba(15, 23, 42, 0.8);
  color: var(--accent);
  border: 1px dashed var(--accent);
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
  text-align: center;
  transition: all 0.3s ease;
  backdrop-filter: blur(4px);
}
.upload-btn:hover {
  background: rgba(20, 184, 166, 0.2);
  box-shadow: 0 4px 15px rgba(20, 184, 166, 0.2);
}

/* =========================================
   OVERLAYS (Crop & Loading)
========================================= */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.9);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.loading-overlay.active {
  opacity: 1;
  pointer-events: all;
}

#loadingText {
  color: var(--accent);
  font-family: monospace;
  font-weight: bold;
  letter-spacing: 2px;
}

.crop-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.95);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.crop-overlay.active {
  opacity: 1;
  pointer-events: all;
}
.crop-container {
  background: var(--card-bg);
  border: 2px solid var(--accent);
  padding: 20px;
  border-radius: 8px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 0 20px rgba(20, 184, 166, 0.4);
  text-align: center;
}
.crop-image-wrapper {
  width: 100%;
  max-height: 60vh;
  overflow: hidden;
  margin-bottom: 20px;
  background: #000;
}
.crop-image-wrapper img {
  max-width: 100%;
  display: block;
  -webkit-user-drag: none;
  pointer-events: none;
}
.crop-controls {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.crop-controls button {
  flex: 1;
}
.cancel-btn {
  border-color: #ef4444;
  color: #ef4444;
}
.cancel-btn:hover:not(:disabled) {
  background: #ef4444;
  color: #fff;
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

/* =========================================
   SIDE TABS & REPLAY VIEW
========================================= */
.side-tabs {
  display: flex;
  background: rgba(15, 23, 42, 0.95);
  border: 2px solid var(--accent);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  overflow: hidden;
}
.side-tab-btn {
  flex: 1;
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 12px;
  font-family: monospace;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.side-tab-btn:hover {
  background: rgba(20, 184, 166, 0.1);
  color: var(--accent);
}
.side-tab-btn.active {
  background: rgba(30, 41, 59, 0.95);
  color: var(--accent);
  font-weight: bold;
  border-bottom: 2px solid var(--accent);
}
.side-panel-content {
  background: rgba(30, 41, 59, 0.95);
  border: 2px solid var(--accent);
  border-radius: 0 0 8px 8px;
  padding: 20px;
  box-shadow: 0 0 20px rgba(20, 184, 166, 0.3);
  min-height: 250px;
  backdrop-filter: blur(4px);
}

/* =========================================
   TERMINAL REPLAY SYSTEM (CRT MONITOR)
========================================= */
.crt-monitor {
  position: relative;
  background-color: #020617;
  border: 4px solid #334155;
  border-radius: 8px;
  height: 140px;
  margin-bottom: 15px;
  overflow: hidden;
  box-shadow:
    inset 0 0 15px rgba(0, 0, 0, 0.9),
    0 0 15px rgba(20, 184, 166, 0.2);
}

.screen-glare {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.05) 0%,
    rgba(255, 255, 255, 0) 50%
  );
  pointer-events: none;
  z-index: 2;
}

.step-message {
  font-family: "Courier New", Courier, monospace;
  color: var(--accent);
  font-size: 13px;
  padding: 15px;
  height: 100%;
  overflow-y: auto;
  line-height: 1.6;
  text-shadow: 0 0 5px rgba(20, 184, 166, 0.6);
  background: linear-gradient(
    rgba(20, 184, 166, 0.03) 50%,
    rgba(0, 0, 0, 0.2) 50%
  );
  background-size: 100% 4px;
  border-bottom: none;
  margin-bottom: 0;
  display: block;
}

.step-message::-webkit-scrollbar {
  width: 6px;
}
.step-message::-webkit-scrollbar-track {
  background: #020617;
}
.step-message::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 3px;
}

.step-controls {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.step-controls button {
  flex: 1;
  padding: 10px 5px;
  font-size: 12px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--primary);
  color: var(--text-main);
}

.step-controls button:hover:not(:disabled) {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

/* =========================================
   TIMELINE SLIDER (SCRUBBER)
========================================= */
#stepSlider {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: #020617;
  border: 1px solid var(--border-color);
  border-radius: 3px;
  outline: none;
}
#stepSlider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 10px rgba(20, 184, 166, 0.8);
  transition: transform 0.1s;
}
#stepSlider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}
#stepSlider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 10px rgba(20, 184, 166, 0.8);
  border: none;
}
#stepSlider:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
#stepSlider:disabled::-webkit-slider-thumb {
  background: var(--text-muted);
  box-shadow: none;
  cursor: not-allowed;
}
