:root {
  --bg: #0d1117;
  --panel: #161b22;
  --line: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #1f6feb;
  --accent-hi: #388bfd;
  --island: #21262d;
  --island-edge: #6e7681;
  --ok: #2ea043;
  --over: #f85149;
  --bridge: #c9d1d9;
}

* { box-sizing: border-box; }

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

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
}

header {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

h1 {
  font-size: 1.5rem;
  margin: 0;
  letter-spacing: 0.5px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hub-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  white-space: nowrap;
}

.hub-link:hover {
  color: var(--text);
  border-color: var(--island-edge);
}

.subtitle {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.9rem;
}

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

.difficulty {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.difficulty button {
  background: var(--panel);
  color: var(--muted);
  border: none;
  border-right: 1px solid var(--line);
  padding: 7px 11px;
  cursor: pointer;
  font-size: 0.85rem;
}

.difficulty button:last-child { border-right: none; }
.difficulty button:hover { color: var(--text); }
.difficulty button.active {
  background: var(--accent);
  color: #fff;
}

button {
  font-family: inherit;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  padding: 8px 14px;
  cursor: pointer;
  font-size: 0.9rem;
}

button:hover { border-color: var(--island-edge); }

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button.primary:hover { background: var(--accent-hi); }

main {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.play-area {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  align-items: center;
}

#board-wrap {
  position: relative;
  flex: 0 0 auto;
  width: min(100%, 500px);
  aspect-ratio: 1 / 1;
}

#win-panel {
  flex: 0 0 auto;
  width: 184px;
  align-self: center;
  background: var(--panel);
  border: 1px solid var(--ok);
  border-radius: 12px;
  padding: 18px 20px;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

#board {
  width: 100%;
  height: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  touch-action: none;
  display: block;
}

.status {
  margin: 12px 0 4px;
  color: var(--muted);
  font-size: 0.95rem;
  min-height: 1.2em;
  text-align: center;
}

.status.solved { color: var(--ok); font-weight: 600; }

.help {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
  text-align: center;
  max-width: 560px;
}

.hidden { display: none !important; }

.win-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ok);
  margin-bottom: 6px;
}

.win-sub { color: var(--muted); margin-bottom: 16px; font-size: 0.9rem; }

#loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: rgba(13, 17, 23, 0.6);
  color: var(--muted);
  font-size: 1.1rem;
}
