:root {
  --bg: #0f172a;
  --panel: #111827;
  --panel-2: #1f2937;
  --board: #e2e8f0;
  --light: #f8fafc;
  --dark: #0b1120;
  --accent: #f59e0b;
  --accent-2: #22c55e;
  --danger: #ef4444;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --border: rgba(148, 163, 184, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #020817, var(--bg));
  color: var(--text);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

button,
select,
input {
  font: inherit;
}

.app {
  width: min(1100px, 95vw);
  padding: 14px 18px 18px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 10px;
}

.eyebrow {
  margin: 0 0 6px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.74rem;
  color: var(--muted);
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
}

.status-box {
  min-width: 140px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.status-box .label {
  color: var(--muted);
  font-size: 0.8rem;
}

#timer {
  font-size: 1.7rem;
  font-weight: 700;
}

.panel {
  background: rgba(17, 24, 39, 0.9);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: 0 18px 30px rgba(2, 6, 23, 0.22);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  margin-bottom: 10px;
  min-height: 86px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 140px;
  justify-content: flex-end;
}

.field label {
  color: var(--muted);
  font-size: 0.85rem;
}

select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.checkbox-field {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  min-width: unset;
  padding-top: 20px;
}

.checkbox-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-2);
}

.button-row {
  display: flex;
  gap: 10px;
  margin-left: auto;
}

button {
  border: none;
  border-radius: 10px;
  padding: 11px 16px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
}

button.primary {
  background: linear-gradient(135deg, #f59e0b, #f97316);
  color: #111827;
}

button.secondary {
  background: rgba(148, 163, 184, 0.18);
  color: var(--text);
  border: 1px solid var(--border);
}

.board-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  background: rgba(17, 24, 39, 0.9);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 18px 14px;
  box-shadow: 0 18px 30px rgba(2, 6, 23, 0.22);
}

.legend {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.85rem;
  align-items: center;
}

.dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.dot.path { background: rgba(34, 197, 94, 0.8); }
.dot.current { background: rgba(245, 158, 11, 0.95); }
.dot.goal { background: rgba(239, 68, 68, 0.9); }

.board {
  width: min(82vmin, 700px);
  aspect-ratio: 1;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  border: 2px solid rgba(15, 23, 42, 0.8);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.35);
  background: #e2e8f0;
  table-layout: fixed;
}

.square {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  min-width: 0;
  min-height: 0;
  padding: 0;
  line-height: 1;
  font-weight: 700;
  font-size: clamp(2.1rem, 4vw, 3.6rem);
  color: #0f172a;
  border: 1px solid rgba(15, 23, 42, 0.16);
  user-select: none;
  transition: filter 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
  overflow: hidden;
}

.square.light {
  background: #f8fafc;
}

.square.dark {
  background: #cbd5e1;
}

.square.goal::after {
  content: "";
  position: absolute;
  inset: 8%;
  border: 2px solid rgba(239, 68, 68, 0.9);
  border-radius: 11px;
}

.square.current {
  box-shadow: inset 0 0 0 3px rgba(245, 158, 11, 0.85);
}

.square.path {
  box-shadow: inset 0 0 0 3px rgba(34, 197, 94, 0.85);
}

.square.dimmed {
  opacity: 0.22;
  filter: brightness(0.4);
}

.square.future {
  opacity: 0.7;
  filter: brightness(0.9);
}

.square.start {
  box-shadow: inset 0 0 0 3px rgba(168, 85, 247, 0.9);
}

.square:hover {
  filter: brightness(0.96);
}

.info {
  margin-top: 10px;
}

.info p {
  margin-top: 0;
  font-size: 1.02rem;
  line-height: 1.5;
}

.info ul {
  margin: 10px 0 0;
  padding-left: 20px;
  color: var(--muted);
}

@media (max-width: 700px) {
  .button-row {
    width: 100%;
    margin-left: 0;
  }

  .button-row button {
    flex: 1;
  }
}
