/* Dark-only theme (Daniel's preference): no light variant, ignores the system setting. */
:root {
  --bg: #121214;
  --surface: #1d1d20;
  --surface-2: #26262a;
  --text: #f2f2f4;
  --muted: #9a9aa2;
  --line: #34343a;
  --line-strong: #c9c9cf;
  --accent: #5fb3a0;
  --accent-soft: #1f3a34;
  --accent-text: #0d1f1b;
  --danger: #ff6b5e;
  --danger-soft: #4a2320;
  --good: #5fc27f;
  --sel: #23415f;
  --peer: #232327;
  --same: #2f557b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --r: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  min-height: 100dvh;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

.wrap {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) max(16px, env(safe-area-inset-right)) calc(env(safe-area-inset-bottom) + 24px) max(16px, env(safe-area-inset-left));
}

/* top bar */
.bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  margin-bottom: 8px;
}
.bar h1 { font-size: 20px; margin: 0; flex: 1; letter-spacing: -.01em; }
.bar .timer { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 15px; min-width: 52px; text-align: right; }
.icon-btn {
  width: 44px; height: 44px;
  display: inline-grid; place-items: center;
  border: 0; border-radius: 12px; background: transparent; cursor: pointer;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn svg { width: 24px; height: 24px; }

/* hub */
.hub-title { font-size: 32px; font-weight: 700; letter-spacing: -.02em; margin: 8px 0 4px; }
.hub-sub { color: var(--muted); margin: 0 0 20px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  background: var(--surface);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 16px;
  min-height: 132px;
  display: flex; flex-direction: column; gap: 6px;
  position: relative;
}
.tile:active { transform: scale(.98); }
.tile .glyph { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.tile .glyph svg { width: 24px; height: 24px; }
.tile .name { font-weight: 650; font-size: 17px; margin-top: auto; }
.tile .meta { color: var(--muted); font-size: 13px; }
.tile.soon { opacity: .55; box-shadow: none; background: var(--surface-2); }
.tile.soon:active { transform: none; }

/* segmented control */
.seg {
  display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 3px; margin: 4px 0 16px;
}
.seg button {
  flex: 1; min-height: 40px; border: 0; border-radius: 9px; background: transparent; cursor: pointer; font-size: 15px; font-weight: 550;
}
.seg button[aria-pressed="true"] { background: var(--surface); box-shadow: var(--shadow); }

/* level grid */
.levels { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.lvl {
  aspect-ratio: 1; min-height: 44px;
  border: 0; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow);
  font-weight: 600; font-size: 16px; cursor: pointer; position: relative;
  font-variant-numeric: tabular-nums;
}
.lvl.done { background: var(--accent-soft); color: var(--accent); }
.lvl.cur { outline: 2px solid var(--accent); outline-offset: -2px; }
.lvl .tick { position: absolute; right: 5px; top: 3px; font-size: 11px; }

.primary {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 52px; border: 0; border-radius: 14px;
  background: var(--accent); color: var(--accent-text); font-size: 17px; font-weight: 650; cursor: pointer;
  margin-bottom: 16px;
}
.primary:active { filter: brightness(.95); }
.secondary {
  min-height: 48px; border: 0; border-radius: 14px; background: var(--surface-2);
  font-size: 16px; font-weight: 600; cursor: pointer; width: 100%;
}

/* toolbar under boards */
.tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.tool {
  min-height: 56px; border: 0; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 12px; color: var(--muted); cursor: pointer;
}
.tool svg { width: 22px; height: 22px; color: var(--text); }
.tool[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.tool[aria-pressed="true"] svg { color: var(--accent); }
.tool:active { transform: scale(.97); }

.label-row { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 14px; margin: 2px 2px 10px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; }
.toggle input { width: 20px; height: 20px; accent-color: var(--accent); }

/* win overlay */
.overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .35);
  display: grid; place-items: center; padding: 24px; z-index: 10;
  animation: fade .2s ease-out;
}
.overlay[hidden] { display: none; }
.card {
  background: var(--surface); border-radius: 20px; padding: 24px; width: min(360px, 100%);
  text-align: center; box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
  animation: pop .25s cubic-bezier(.2, .9, .3, 1.2);
}
.card h2 { margin: 4px 0 6px; font-size: 24px; }
.card p { color: var(--muted); margin: 0 0 18px; }
.card .big { font-size: 40px; }
.card .stats { display: flex; justify-content: center; gap: 28px; margin: 0 0 20px; }
.card .stats div { display: flex; flex-direction: column; }
.card .stats b { font-size: 22px; font-variant-numeric: tabular-nums; }
.card .stats span { font-size: 13px; color: var(--muted); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.9); opacity: 0; } }

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px;
  opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 20; white-space: nowrap;
}
.toast.show { opacity: 1; }

.view[hidden] { display: none; }
.empty-note { color: var(--muted); font-size: 14px; text-align: center; margin: 18px 0 0; }
