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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1a2e;
  color: #eee;
  min-height: 100vh;
  padding: 12px;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
}


/* ── Tabs ─────────────────────────────────────────────────────────────── */

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 0;
}

.tab {
  padding: 12px 24px;
  background: #2a2a4a;
  border: none;
  color: #aaa;
  cursor: pointer;
  border-radius: 8px 8px 0 0;
  font-size: 16px;
  transition: background 0.4s, color 0.4s;
  margin-bottom: 4px;
}

.tab:hover  { background: #3a3a5a; color: #fff; }
.tab.active { background: #4a4a6a; color: #fff; margin-bottom: 0; }


/* ── Solver panels ────────────────────────────────────────────────────── */

.solver-panel {
  display: none;
  background: #2a2a4a;
  border-radius: 0 12px 12px 12px;
  padding: 16px;
}

.solver-panel.active { display: block; }


/* ── Info box ─────────────────────────────────────────────────────────── */

.info-box {
  background: #1a1a2e;
  padding: 12px;
  border-radius: 8px;
}

.info-box h3 {
  margin-bottom: 8px;
  color: #9c27b0;
  font-size: 16px;
}

.info-box--sphere h3 { color: #1976d2; }
.info-box--ot h3     { color: #00796b; }

.info-box p {
  font-size: 13px;
  margin-bottom: 8px;
}

.free-tip {
  color: #9c27b0;
  font-size: 13px;
  margin-top: 8px;
}


/* ── Legend ───────────────────────────────────────────────────────────── */

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.legend-item {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}


/* ── Layout ───────────────────────────────────────────────────────────── */

.main-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 8px;
}

@media (min-width: 700px) {
  .main-content    { flex-direction: row; align-items: flex-start; }
  .left-panel      { flex-shrink: 0; }
  .right-panel     { flex: 1; min-width: 0; }
}

.right-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}


/* ── Grid ─────────────────────────────────────────────────────────────── */

.grid-wrapper {
  background: #1a1a2e;
  padding: 12px;
  border-radius: 8px;
  display: inline-block;
}

.grid {
  display: grid;
  grid-template-columns: repeat(5, 64px);
  grid-template-rows: repeat(5, 64px);
  gap: 4px;
}

@media (max-width: 400px) {
  .grid      { grid-template-columns: repeat(5, 48px); grid-template-rows: repeat(5, 48px); }
  .grid-wrapper { padding: 8px; }
}


/* ── Cells ────────────────────────────────────────────────────────────── */

.cell {
  width: 60px;
  height: 60px;
  border: 2px solid #444;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 11px;
  cursor: pointer;
  background: #3a3a5a;
  color: #fff;
  transition: all 0.15s;
  user-select: none;
  position: relative;
}

.cell:hover  { border-color: #888; }
.cell:active { transform: scale(0.95); }

@media (max-width: 400px) {
  .cell { width: 48px; height: 48px; font-size: 10px; }
}

/* Highlight rings */
.cell.highlight-1 { box-shadow: 0 0 0 3px #4CAF50; }
.cell.highlight-2 { box-shadow: 0 0 0 3px #FFC107; }
.cell.highlight-3 { box-shadow: 0 0 0 3px #FF9800; }

.cell.highlight-certain {
  box-shadow: 0 0 0 3px #FFD700, 0 0 14px 4px #FFD70088;
  animation: pulse-certain 1s ease-in-out infinite alternate;
}

@keyframes pulse-certain {
  from { box-shadow: 0 0 0 3px #FFD700, 0 0 10px 2px #FFD70055; }
  to   { box-shadow: 0 0 0 3px #FFD700, 0 0 18px 6px #FFD700aa; }
}

/* Transparency variants */
.cell.transparent  { opacity: 0.5; }
.cell.certain-blue { opacity: 0.45; background: #1976d2; border-color: #1976d2 !important; }
.cell.certain-hint { opacity: 0.55; }

/* Probability labels */
.cell-prob  { font-size: 10px; margin-top: 2px;  opacity: 0.9;  font-weight: 600; }
.cell-prob2 { font-size: 9px;  margin-top: 1px;  opacity: 0.85; font-weight: 600; color: #ffd700; }

/* Mini color swatches inside certain-ambiguous cells */
.cell-swatches { display: flex; gap: 2px; margin-top: 3px; justify-content: center; flex-wrap: wrap; }
.cell-swatch   { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }


/* ── Color classes ────────────────────────────────────────────────────── */

.color-purple  { background: #9c27b0; }
.color-red     { background: #d32f2f; }
.color-orange  { background: #f57c00; }
.color-yellow  { background: #fbc02d; color: #333; }
.color-green   { background: #388e3c; }
.color-teal    { background: #00796b; }
.color-blue    { background: #1976d2; }
.color-light   { background: #f5f0e0; color: #333; }
.color-dark    { background: #0d0d1a; border-color: #667 !important; }

.color-rainbow {
  background: linear-gradient(135deg, #e0004d 0%, #ff5500 20%, #ffd000 40%, #00bb44 60%, #0055ff 80%, #8800cc 100%);
  color: #fff;
  text-shadow: 0 1px 3px #000a;
}

.color-rare {
  background: linear-gradient(
    135deg,
    #f57c00 0%,   #f57c00 21%,
    #d32f2f 21%,  #d32f2f 42%,
    #0d0d1a 42%,  #0d0d1a 65%,
    #f5f0e0 65%,  #f5f0e0 80%,
    #8800cc 80%,  #8800cc 100%
  );
  color: #fff;
}


/* ── Status bar ───────────────────────────────────────────────────────── */

.status-bar,
.status-bar-top,
.status-bar-bottom {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.status-item {
  padding: 6px 12px;
  background: #1a1a2e;
  border-radius: 6px;
  font-size: 13px;
  position: relative;
  cursor: help;
}

.status-item.warning  { background: #d32f2f; }
.status-item.status-purple { background: #9c27b0; }


/* ── Controls ─────────────────────────────────────────────────────────── */

.controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
  align-items: center;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-primary          { background: #4CAF50; color: #fff; }
.btn-primary:hover    { background: #45a049; }
.btn-secondary        { background: #555; color: #fff; }
.btn-secondary:hover  { background: #666; }


/* ── Recommendation card ──────────────────────────────────────────────── */

.recommendation {
  background: #1a1a2e;
  padding: 16px;
  border-radius: 8px;
  border-left: 4px solid #4CAF50;
}

.recommendation--ot { border-left-color: #00796b; }

.recommendation h3   { margin-bottom: 8px; font-size: 16px; }
.recommendation .best-move { font-size: 16px; color: #4CAF50; }
.recommendation .details   { margin-top: 8px; font-size: 13px; color: #aaa; line-height: 1.5; }


/* ── Results panel ────────────────────────────────────────────────────── */

.results {
  background: #1a1a2e;
  border-radius: 8px;
  padding: 16px;
  max-height: 400px;
  overflow-y: auto;
}

.results h3 { margin-bottom: 12px; font-size: 16px; }

.results-content {
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 11px;
  white-space: pre-wrap;
  line-height: 1.4;
  word-break: break-word;
}


/* ── Tooltip ──────────────────────────────────────────────────────────── */

.tooltip {
  position: relative;
  display: inline-block;
  border-bottom: 1px dotted #888;
  cursor: unset;
}

.tooltip .tooltiptext {
  visibility: hidden;
  width: 200px;
  background-color: #1a1a2e;
  color: #eee;
  text-align: left;
  border-radius: 6px;
  padding: 8px;
  position: absolute;
  z-index: 100;
  bottom: -100%;
  left: 50%;
  margin-left: -100px;
  opacity: 0;
  font-size: 11px;
  line-height: 1.4;
  border: 1px solid #444;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
  transition: opacity 0.3s ease 0.1s, visibility 0.2s ease 0.1s;
}

.tooltip:hover .tooltiptext {
  visibility: visible;
  opacity: 1;
  transition-delay: 1s;
}


/* ── Ourotrace specifics ──────────────────────────────────────────────── */

.ot-rare-selector {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.ot-rare-label { color: #aaa; }
.ot-rare-hint  { color: #666; font-size: 11px; }

.ot-nrare-btn          { background: #3a3a5a; color: #aaa; padding: 4px 14px; font-size: 13px; }
.ot-nrare-btn.active-btn { background: #00796b; color: #fff; }

.ot-warn {
  margin-top: 8px;
  font-size: 11px;
  color: #7a9a7a;
  line-height: 1.5;
  background: #1a2a1a;
  border-radius: 6px;
  padding: 8px;
  max-width: 360px;
}

.ot-warn-text { color: #ffd700; }
