:root{
  --bg:#f7f8fa;
  --ink:#1f2937;
  --muted:#6b7280;
  --accent:#2563eb;
  --ok:#16a34a;
  --danger:#ef4444;
  --chip:#e5e7eb;
  --ring:#93c5fd;
  --ring-muted:#cbd5e1;

  --even:#38bdf8;   /* blue   */
  --odd:#8b5cf6;    /* purple */
  --used:#cbd5e1;   /* grey for used nodes */
  --edge:#475569;
  --edgeDim:#9aa3b2;
  --surface:#ffffff;
}

* { box-sizing: border-box; }

body{
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

/* Layout */
.page{
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  padding: 24px;
}
.sidebar.hidden{ display:none; }
.main{ min-width: 0; } /* prevent overflow */

h1{ margin: 0 0 8px; }
.rules{ margin: 0 0 16px; color: var(--muted); }

#status{
  margin: 12px 0 18px;
  font-weight: 600;
}

.board{
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
    gap: 10px;
    justify-content: start;
    max-width: 900px;
}

button.number{
  width: 64px;       /* ✅ fixed width */
  height: 48px;      /* consistent height */
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: var(--chip);
  color: var(--ink);
  font-weight: 700;
  font-size: 18px;
  text-align: center; /* center digits */
  cursor: pointer;
  transition: transform .06s ease, background .15s ease, box-shadow .15s ease, outline-color .15s ease;
  box-shadow: 0 1px 0 rgba(0,0,0,.05);
  outline: 3px solid transparent;
  outline-offset: 2px;
}

button.number:hover:not(:disabled){ background: #dbeafe; }
button.number:active:not(:disabled){ transform: translateY(1px); }
button.number:disabled{
  background: #e7e9ee;
  color: #9ca3af;
  cursor: not-allowed;
}

.controls{ margin-top: 16px; display: flex; gap: 10px; flex-wrap: wrap; }

.controls button {
  width: 200px;   /* ✅ ensures consistent width */
  text-align: center; /* keep text centered */
}


.reset{
  padding: 10px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--ok);
  color: white;
  font-weight: 700;
  cursor: pointer;
}
.reset:hover{ filter: brightness(0.95); }
.secondary{
  padding: 10px 16px;
  border: 0;
  border-radius: 8px;
  background: #0ea5e9;
  color: white;
  font-weight: 700;
  cursor: pointer;
}
.secondary.outline{
  background: transparent;
  color: var(--accent);
  border: 2px solid var(--accent);
}
.secondary:hover{ filter: brightness(0.95); }

/* Highlight styles */
button.number.valid{
  outline-color: var(--ring);
  box-shadow: 0 0 0 4px rgba(147,197,253,.35);
  background: #eef6ff;
}
button.number.valid:disabled{
  outline-color: var(--ring-muted);
  box-shadow: 0 0 0 3px rgba(203,213,225,.6);
  background: #eef2f7;
}

/* Network (custom SVG) */
.network{
  margin-top: 18px;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 6px 18px rgba(0,0,0,.06);
  max-width: 900px;
}
.network.hidden{ display:none; }

.edge{ stroke: var(--edge); stroke-width: 2; opacity: .8; }
.edge-dim{ stroke: var(--edgeDim); opacity: .75; }
.node-circle{ stroke: white; stroke-width: 3; }
.node-even{ fill: var(--even); }
.node-odd{  fill: var(--odd); }
.node-used{ fill: var(--used); }
.node-label{
  font: 700 16px/1 system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  fill: var(--ink);
}

.legend{ margin-top: 8px; color: var(--muted); display: flex; gap: 10px; align-items: center; }
.chip{
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--chip);
  font-size: 12px; font-weight: 700;
}
.chip.even{ background: var(--even); color: white; }
.chip.odd{  background: var(--odd);  color: white; }
.chip.used{ background: var(--used); color: #475569; }

/* Sidebar (history) */
.sidebar{
  background: var(--surface);
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 6px 18px rgba(0,0,0,.06);
  min-height: 180px;
}
.sidebar h2{
  margin: 4px 0 8px;
  font-size: 18px;
}
.table-wrap{ overflow: auto; max-height: calc(100vh - 160px); }
.table{
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table th, .table td{
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
}
.table thead th{
  position: sticky; top: 0;
  background: #f1f5f9; z-index: 1;
}
.table tbody tr:nth-child(even) td{ background: #fafafa; }

/* Modal */
.modal{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 1000;
}
.modal.hidden{ display: none; }

.modal__content{
  width: min(400px, 92vw);
  background: white;
  border-radius: 14px;
  padding: 18px 18px 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,.18);
  animation: pop .15s ease-out;
}
@keyframes pop { from { transform: scale(.98); opacity: .7 } to { transform: scale(1); opacity: 1 } }

.modal__content h2{
  margin: 0 0 8px;
  color: var(--danger);
}

.modal__content p{ margin: 0 0 12px; font-size: 18px; }

.modal .btn{
padding: 14px 24px;
font-size: 18px;
border: 0;
border-radius: 8px;
background: var(--accent);
color: white;
font-weight: 700;
cursor: pointer;
display: block;
margin-left: auto;
}
.modal .btn:hover{ filter: brightness(0.95); }

.node-current {
  fill: none;
  stroke: #000000; /* amber highlight */
  stroke-width: 4;
  r: 22;
}

.chip.current{ background: #f59e0b; color: white; }