/* ===== Kakuro Layout ===== */

.toolbar-row2 {
  margin-top: 6px;
}

/* Legend strip */
.kk-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(95vw, 460px);
  margin: 6px auto 2px;
  padding: 5px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-muted);
}
.kk-legend-svg {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  background: #5a4f46;
  border-radius: 3px;
  color: #f0e8de;
}
body.dark .kk-legend-svg { background: #2c2520; }
.kk-legend-text { flex: 1; }

/* Run info bar */
.kk-run-info {
  display: flex;
  justify-content: center;
  gap: 20px;
  max-width: min(95vw, 460px);
  margin: 6px auto 0;
  padding: 5px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
}
.kk-run-info[hidden] { display: none; }
.kk-run-clue { display: flex; align-items: center; gap: 5px; }
.kk-run-clue .kk-run-dir { font-size: 11px; color: var(--text-muted); }
.kk-run-clue .kk-run-sum { color: var(--accent); font-weight: 800; }
.kk-run-clue .kk-run-filled { color: var(--text-muted); font-size: 12px; }
.kk-run-clue.kk-run-ok .kk-run-sum { color: #2a7a2a; }
body.dark .kk-run-clue.kk-run-ok .kk-run-sum { color: #7dde7d; }

/* Board container */
#board-container {
  overflow: auto;
  max-width: 100%;
}
#board-container.is-paused { visibility: hidden; }

/* The Kakuro grid */
.kakuro-table {
  border-collapse: collapse;
  margin: 0 auto;
  user-select: none;
  border: 2px solid rgba(80, 68, 58, 0.55);
}

body.dark .kakuro-table {
  border-color: rgba(200, 185, 168, 0.45);
}

.kakuro-table td {
  width: clamp(30px, 9vw, 44px);
  height: clamp(30px, 9vw, 44px);
  padding: 0;
  border: 1px solid rgba(80, 68, 58, 0.30);
  position: relative;
}

body.dark .kakuro-table td {
  border-color: rgba(200, 185, 168, 0.20);
}

/* Black/wall cells */
.kk-black {
  background: #5a4f46;
  border-color: #5a4f46 !important;
  pointer-events: none;
}

body.dark .kk-black {
  background: #2c2520;
  border-color: #2c2520 !important;
}

/* SVG divider line inside black cells */
.kk-black svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Corner/edge black with no clue */
.kk-black-empty {
  background: #5a4f46;
  border-color: #5a4f46 !important;
  pointer-events: none;
}

body.dark .kk-black-empty {
  background: #2c2520;
  border-color: #2c2520 !important;
}

/* Clue text inside black cells */
.clue-down {
  position: absolute;
  top: 2px;
  right: 3px;
  font-size: clamp(8px, 2.2vw, 11px);
  font-weight: 700;
  color: #f0e8de;
  line-height: 1;
}

.clue-across {
  position: absolute;
  bottom: 2px;
  left: 3px;
  font-size: clamp(8px, 2.2vw, 11px);
  font-weight: 700;
  color: #f0e8de;
  line-height: 1;
}

/* White input cells */
.kk-white {
  background: var(--surface);
  cursor: pointer;
  transition: background 0.1s;
}

.kk-white:hover {
  background: var(--surface-hover, #f0ebe4);
}

body.dark .kk-white:hover {
  background: var(--surface-hover, #2c241c);
}

.kk-white.selected {
  background: #fff8d8 !important;
  box-shadow: inset 0 0 0 2px rgba(237, 194, 46, 0.7);
  z-index: 1;
}

body.dark .kk-white.selected {
  background: #4a3f1f !important;
}

/* Highlight same run as selected */
.kk-white.run-highlight {
  background: #faf2dc;
}

body.dark .kk-white.run-highlight {
  background: #2c2418;
}

/* Error state */
.kk-white.error {
  background: #fcd6cc !important;
  color: var(--danger) !important;
}

body.dark .kk-white.error {
  background: #5a2418 !important;
}

/* Correct state after check */
.kk-white.correct {
  background: #d4f4d4 !important;
  color: #2a7a2a !important;
}

body.dark .kk-white.correct {
  background: #1a3a1a !important;
  color: #7dde7d !important;
}

/* Revealed cell */
.kk-white.revealed {
  color: var(--text-muted) !important;
  font-style: italic;
}

/* Cell value text */
.cell-val {
  font-size: clamp(13px, 3.5vmin, 20px);
  font-weight: 700;
  color: #1976d2;
  pointer-events: none;
}

body.dark .cell-val {
  color: #64b5f6;
}

.kk-white.revealed .cell-val {
  color: var(--text-muted) !important;
}

/* Number pad */
.numpad {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  max-width: min(95vw, 460px);
  margin: 14px auto 0;
}

.numpad button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-strong);
  border-radius: 999px;
  padding: 11px 0;
  font-weight: 800;
  font-size: 17px;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.1s ease;
  font-family: inherit;
  box-shadow: var(--shadow-sm);
}

.numpad button:hover {
  background: var(--surface-hover);
  transform: scale(1.08);
}

.numpad button.erase-btn {
  font-size: 14px;
  grid-column: span 1;
}

/* Win overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 100;
  animation: fadein 0.3s ease-in-out;
}

.overlay[hidden] {
  display: none;
}

.overlay-text {
  font-size: clamp(32px, 7vmin, 52px);
  font-weight: 800;
  color: var(--text-strong);
  text-align: center;
}

.overlay-sub {
  font-size: 20px;
  color: var(--text);
}

@keyframes fadein {
  from { opacity: 0; }
  to { opacity: 1; }
}
