body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    margin: 0;
    padding: 0;
    background: #fff;
    color: #111827;
}

.banner {
    width: 100%;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
}

.banner-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem 1.5rem 1.1rem;
}

.banner-eyebrow {
    display: inline-flex;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.2em;
    color: #6b7280;
    font-weight: 700;
}

.banner h1 {
    margin: 0.35rem 0 0.25rem;
    font-size: 2.2rem;
}

.banner-subtitle {
    margin: 0;
    color: #6b7280;
}

.page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem;
}

.game-layout {
    margin-top: 1rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

#puzzle-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    min-height: 350px;
    flex: 1 1 auto;
    gap: 0.75rem;
}

.svg-root {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

#puzzle-container svg {
    display: block;
    width: min(560px, 100%);
    height: auto;
}

.sidebar {
    flex: 0 0 240px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 1rem;
    color: #111827;
}

.help-btn {
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    border: 1px solid #d1d5db;
    background: #fff;
    color: #111827;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.help-btn:hover {
    border-color: #111827;
}

.digit-pad {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.numpad {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.5rem;
}

.pad-btn {
    padding: 0.6rem 0.8rem;
    border-radius: 10px;
    border: 1px solid #d1d5db;
    background: #fff;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
}

.pad-btn.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.pad-btn .btn-icon {
    width: 1.15rem;
    height: 1.15rem;
    display: block;
}

.pad-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.pad-btn.mode {
    background: #f3f4f6;
}

.pad-btn.toggle {
    background: #f3f4f6;
}

.pad-btn.toggle.active {
    background: #111827;
    color: #fff;
    border-color: #111827;
}

.pad-btn.toggle.active .btn-icon,
.pad-btn.mode.active .btn-icon {
    filter: invert(1);
}

.pad-btn.mode.active {
    background: #111827;
    color: #fff;
    border-color: #111827;
}

.pad-btn.erase {
    width: 100%;
    border-radius: 10px;
    background: #fff5f5;
    color: #b91c1c;
    border-color: #fecdd3;
}

.controls {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
}

button {
    padding: 0.5rem 1rem;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
}

.btn-primary {
    background: #111827;
    color: white;
}

.btn-secondary {
    background: #e5e7eb;
    color: #111827;
}

.mode-toggle {
    display: inline-flex;
    border: 1px solid #d1d5db;
    border-radius: 999px;
    overflow: hidden;
}

.mode-toggle button {
    border-radius: 0;
    border: none;
    background: transparent;
    padding: 0.5rem 0.9rem;
    font-weight: 600;
}

.mode-toggle button+button {
    border-left: 1px solid #d1d5db;
}

.mode-toggle button.active {
    background: #111827;
    color: #fff;
}

#status {
    font-size: 0.9rem;
    color: #6b7280;
    min-height: 1.25rem;
}

.puzzle-title {
    margin: 0 0 0.5rem;
    font-size: 1.4rem;
}

.variants {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    min-height: 1.5rem;
}

.variant-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    color: #111827;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

pre {
    background: #f3f4f6;
    padding: 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    overflow-x: auto;
}

@media (max-width: 820px) {
  .game-layout {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .sidebar {
    flex-basis: auto;
  }

  #puzzle-container {
    min-height: auto;
    align-items: stretch;
  }

  .banner-inner {
    padding: 1.25rem 1.25rem 1rem;
  }

  .banner h1 {
    font-size: 1.8rem;
  }
}

/* Selection helpers for SVG */
svg rect.highlight-cell.selected {
    stroke: #111827;
    stroke-width: 2;
    stroke-opacity: 0.6;
}

svg rect.highlight-cell.same-value {
    fill: rgba(17, 24, 39, 0.08);
}

/* Simple modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    z-index: 50;
}

.modal {
    width: min(420px, 100%);
    background: #fff;
    border-radius: 14px;
    padding: 1rem;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.25);
}

.modal h2 {
    margin: 0 0 0.5rem;
    font-size: 1.1rem;
}

.modal h3 {
    margin: 0.8rem 0 0.4rem;
    font-size: 0.95rem;
    color: #111827;
}

.help-list {
    margin: 0;
    padding-left: 1.1rem;
    color: #374151;
    font-size: 0.9rem;
}

.help-list li + li {
    margin-top: 0.35rem;
}

.modal p {
    margin: 0 0 1rem;
    color: #374151;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
