/* Hexulo. Two themes on data-theme; the canvas reads the --board-* tokens. */

:root,
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111216;
  --bg-glow: #191b22;
  --panel: #1d2029;
  --panel-hi: #262a35;
  --line: #2e3340;
  --ink: #f3f1ec;
  --muted: #9aa0ad;
  --accent: #ffc83d;
  --accent-ink: #231a00;
  --board-tray: #1d1f25;
  --board-track: #282b34;
  --board-hole: #101218;
  --board-ink: #f3f1ec;
  --shadow: 0 10px 30px rgb(0 0 0 / 0.35);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f4f0;
  --bg-glow: #ffffff;
  --panel: #ffffff;
  --panel-hi: #f4f0e6;
  --line: #e4ded1;
  --ink: #1d2027;
  --muted: #6b7180;
  --accent: #1d2027;
  --accent-ink: #ffffff;
  --board-tray: #e2ddd2;
  --board-track: #d6d0c4;
  --board-hole: #f7f4ee;
  --board-ink: #1d2027;
  --shadow: 0 10px 30px rgb(60 50 30 / 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: radial-gradient(120% 70% at 50% 0%, var(--bg-glow), var(--bg) 70%) fixed, var(--bg);
  color: var(--ink);
  font: 16px/1.45 ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

button,
a {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  text-decoration: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 760px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}

/* ─── Top bar ─────────────────────────────────────────────────────────── */

.bar {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 60px;
  padding: 8px 12px;
}

.bar-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  padding-left: 4px;
}

.bar-title strong {
  font-size: 18px;
}

.bar-title span {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
}

.icon-btn:hover {
  background: var(--panel);
  color: var(--ink);
}

.moves {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ─── Home ────────────────────────────────────────────────────────────── */

.home {
  justify-content: center;
  gap: 28px;
  padding: 0 20px calc(20px + env(safe-area-inset-bottom));
  overflow-y: auto;
}

.hero {
  text-align: center;
}

.hero .mark {
  filter: drop-shadow(0 6px 0 rgb(0 0 0 / 0.25));
  animation: bob 4s ease-in-out infinite;
}

.hero h1 {
  margin: 14px 0 4px;
  font-size: clamp(40px, 11vw, 64px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}

.hero p {
  margin: 0;
  color: var(--muted);
  font-size: 18px;
}

@keyframes bob {
  50% {
    transform: translateY(-6px) rotate(-3deg);
  }
}

.menu {
  display: grid;
  gap: 12px;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: var(--muted);
}

.card:active {
  transform: translateY(1px);
}

.card strong {
  font-size: 20px;
}

.card > span:not(.card-kicker, .chip, .meter) {
  color: var(--muted);
  font-size: 15px;
}

.card-kicker {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.card-daily {
  border-color: transparent;
  background: linear-gradient(135deg, #34c47c, #2a9fd6);
  color: #fff;
}

.card-daily > span:not(.chip),
.card-daily .card-kicker {
  color: rgb(255 255 255 / 0.85) !important;
}

.chip {
  position: absolute;
  top: 14px;
  right: 14px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgb(0 0 0 / 0.22);
  font-size: 13px;
  font-weight: 700;
}

.meter {
  height: 6px;
  margin-top: 8px;
  border-radius: 999px;
  background: var(--panel-hi);
  overflow: hidden;
}

.meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.4s ease;
}

.card.locked {
  opacity: 0.55;
  cursor: default;
  box-shadow: none;
}

.card.locked:hover {
  transform: none;
  border-color: var(--line);
}

.foot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.foot a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.link {
  border: 0;
  background: none;
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ─── Steps ───────────────────────────────────────────────────────────── */

.steps {
  overflow-y: auto;
  padding: 4px 16px calc(24px + env(safe-area-inset-bottom));
  gap: 16px;
}

.steps-lead {
  margin: 0;
  color: var(--muted);
}

.step-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.step {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  aspect-ratio: 1;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  transition: transform 0.15s ease;
}

.step strong {
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
}

.step span {
  color: var(--muted);
  font-size: 13px;
}

.step:hover {
  transform: translateY(-2px);
}

.step.done {
  background: var(--panel-hi);
}

.step.done strong::after {
  content: " ✓";
  color: #34c47c;
  font-size: 18px;
}

.step.now {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--shadow);
}

.step.now span {
  color: inherit;
  opacity: 0.75;
}

.step.locked {
  opacity: 0.4;
  cursor: default;
}

.step.locked:hover {
  transform: none;
}

.card-wide {
  flex-direction: row;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

/* ─── Play ────────────────────────────────────────────────────────────── */

.play {
  position: relative;
}

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
}

.stage canvas.scene {
  pointer-events: none;
}

.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.hint.challenge {
  color: var(--ink);
  font-weight: 600;
}

.vs {
  margin: -6px 0 10px;
  color: var(--muted);
  font-weight: 600;
}

.hint {
  min-height: 2.9em;
  margin: 0 auto;
  padding: 0 24px;
  max-width: 460px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.dock {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 6px 16px calc(16px + env(safe-area-inset-bottom));
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  font-weight: 650;
  transition: transform 0.12s ease, opacity 0.2s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-icon {
  width: 48px;
  padding: 0;
  color: var(--muted);
}

.btn-main {
  min-width: 148px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn-primary {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-ink);
}

.btn-block {
  width: 100%;
}

.sheet {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  padding: 22px 20px 18px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--panel);
  box-shadow: 0 -10px 50px rgb(0 0 0 / 0.35);
  text-align: center;
  animation: rise 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.sheet h2 {
  margin: 0 0 12px;
  font-size: 26px;
  font-weight: 800;
}

@keyframes rise {
  from {
    transform: translateY(40px);
    opacity: 0;
  }
}

.stats {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin: 0 0 18px;
}

.stats dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stats dd {
  margin: 2px 0 0;
  font-size: 28px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ─── Dialogs ─────────────────────────────────────────────────────────── */

.panel {
  width: min(440px, calc(100vw - 24px));
  max-height: calc(100dvh - 40px);
  padding: 22px 20px 20px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.panel::backdrop {
  background: rgb(10 12 16 / 0.55);
  backdrop-filter: blur(3px);
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 24px;
  font-weight: 800;
}

.rules {
  display: grid;
  gap: 14px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}

.rules li {
  display: grid;
  grid-template-columns: 96px 1fr;
  align-items: center;
  gap: 14px;
}

.rules svg {
  justify-self: center;
  max-width: 96px;
  height: auto;
}

.rules p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.small {
  color: var(--muted);
  font-size: 13px;
}

.install {
  margin-top: 16px;
}

.preview {
  display: block;
  width: 100%;
  height: 34px;
  margin: 4px 0 6px;
}

.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  font-weight: 600;
}

.toggle i {
  position: relative;
  width: 46px;
  height: 28px;
  border-radius: 999px;
  background: var(--panel-hi);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: background 0.2s ease;
}

.toggle i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ink);
  transition: transform 0.2s ease;
}

.toggle[aria-checked="true"] i {
  background: #3ec28f;
}

.toggle[aria-checked="true"] i::after {
  transform: translateX(18px);
  background: #fff;
}

.field {
  display: grid;
  gap: 8px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}

.segs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: var(--panel-hi);
}

.seg {
  flex: 1;
  min-height: 38px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.seg[aria-pressed="true"] {
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.2);
}

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow);
  z-index: 10;
}

@media (min-width: 700px) {
  .sheet {
    left: 50%;
    right: auto;
    width: 420px;
    transform: translateX(-50%);
    animation: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

.faded {
  visibility: hidden;
}

/* The admin page and the sign-in page: plain, readable tables. */
.admin {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.admin header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
}

.admin h1 {
  margin: 0;
  font-size: 24px;
}

.admin header form {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

.admin a {
  color: var(--ink);
}

.admin table {
  width: 100%;
  margin-top: 12px;
  border-collapse: collapse;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.admin th,
.admin td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

.admin th:first-child,
.admin td:first-child {
  text-align: left;
}

.admin th {
  color: var(--muted);
  font-weight: 600;
}

#login form {
  margin: 12px 0;
}

/* Text only screen readers read. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* The leaderboard list. */
.leaders {
  display: grid;
  gap: 2px;
  margin: 8px 0 14px;
  padding: 0;
  list-style: none;
  font-variant-numeric: tabular-nums;
}

.leaders li {
  display: grid;
  grid-template-columns: 2.2em 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 9px 10px;
  border-radius: 10px;
}

.leaders li:nth-child(odd) {
  background: var(--panel-hi);
}

.leaders li.you {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  font-weight: 700;
}

.leaders .place {
  color: var(--muted);
}

.leaders .who {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaders .num {
  color: var(--muted);
}

/* The sign-in note on the result card. */
.nudge {
  margin: 4px 0 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-hi);
  font-size: 14px;
}

.nudge p {
  margin: 0 0 10px;
}

.acct-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.acct .small {
  margin: 0 0 8px;
  font-weight: 400;
}

/* The account and privacy pages. */
.account form {
  margin: 14px 0;
}

.account .field input {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
}

.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 14px 0;
  font-size: 15px;
}

.check input {
  width: 20px;
  height: 20px;
  margin-top: 2px;
}

.btn.danger {
  border-color: #e0574d;
  color: #e0574d;
}

.prose {
  max-width: 680px;
  line-height: 1.6;
}

.prose h2 {
  margin-top: 28px;
  font-size: 19px;
}
