/* Material 3 (Compose material3 1.3) baseline colours with the app's own primary, secondary
   and tertiary (ui/Theme.kt), type scale and component shapes, so the page looks like the app. */
:root {
  color-scheme: light dark;
  --primary: #3f51b5;
  --on-primary: #ffffff;
  --primary-container: #eaddff;
  --on-primary-container: #21005d;
  --secondary: #7e57c2;
  --on-secondary: #ffffff;
  --secondary-container: #e8def8;
  --on-secondary-container: #1d192b;
  --tertiary: #e65100;
  --on-tertiary: #ffffff;
  --tertiary-container: #ffd8e4;
  --on-tertiary-container: #31111d;
  --surface: #fef7ff;
  --on-surface: #1d1b20;
  --surface-variant: #e7e0ec;
  --on-surface-variant: #49454f;
  --surface-container-low: #f7f2fa;
  --surface-container: #f3edf7;
  --surface-container-high: #ece6f0;
  --surface-container-highest: #e6e0e9;
  --outline: #79747e;
  --outline-variant: #cac4d0;
  --inverse-surface: #322f35;
  --inverse-on-surface: #f5eff7;
  --gold: #ffc107;
  --mono: "Roboto Mono", "Droid Sans Mono", ui-monospace, Menlo, Consolas, monospace;
  --font: Roboto, "Google Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --primary: #9fa8da;
    --on-primary: #381e72;
    --primary-container: #4f378b;
    --on-primary-container: #eaddff;
    --secondary: #b39ddb;
    --on-secondary: #332d41;
    --secondary-container: #4a4458;
    --on-secondary-container: #e8def8;
    --tertiary: #ffb74d;
    --on-tertiary: #492532;
    --tertiary-container: #633b48;
    --on-tertiary-container: #ffd8e4;
    --surface: #141218;
    --on-surface: #e6e0e9;
    --surface-variant: #49454f;
    --on-surface-variant: #cac4d0;
    --surface-container-low: #1d1b20;
    --surface-container: #211f26;
    --surface-container-high: #2b2930;
    --surface-container-highest: #36343b;
    --outline: #938f99;
    --outline-variant: #49454f;
    --inverse-surface: #e6e0e9;
    --inverse-on-surface: #322f35;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overscroll-behavior: none; } /* no pull-to-refresh */
body {
  background: var(--surface);
  color: var(--on-surface);
  font-family: var(--font);
  font-size: 14px;
  line-height: 20px;
  letter-spacing: 0.25px;
  -webkit-tap-highlight-color: transparent;
}
#app { height: 100%; }
button, input { font: inherit; color: inherit; letter-spacing: inherit; }

/* The app keeps a phone's width on a big screen. */
.screen {
  height: 100%;
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  position: relative;
}
.scroll { flex: 1; overflow-y: auto; overscroll-behavior-y: contain; padding: 0 16px; display: flex; flex-direction: column; gap: 12px; }
.scroll > :last-child { margin-bottom: 4px; }

/* Type scale */
.display-small { font-size: 36px; line-height: 44px; letter-spacing: 0; font-weight: 400; }
.headline-small { font-size: 24px; line-height: 32px; letter-spacing: 0; }
.title-large { font-size: 22px; line-height: 28px; letter-spacing: 0; }
.title-medium { font-size: 16px; line-height: 24px; letter-spacing: 0.15px; font-weight: 500; }
.title-small { font-size: 14px; line-height: 20px; letter-spacing: 0.1px; font-weight: 500; }
.body-large { font-size: 16px; line-height: 24px; letter-spacing: 0.5px; }
.body-medium { font-size: 14px; line-height: 20px; letter-spacing: 0.25px; }
.body-small { font-size: 12px; line-height: 16px; letter-spacing: 0.4px; }
.label-large { font-size: 14px; line-height: 20px; letter-spacing: 0.1px; font-weight: 500; }
.label-small { font-size: 11px; line-height: 16px; letter-spacing: 0.5px; font-weight: 500; }
.bold { font-weight: 700; }
.mono { font-family: var(--mono); letter-spacing: 0; }
.center { text-align: center; }
.variant { color: var(--on-surface-variant); }
.col { display: flex; flex-direction: column; }
.row { display: flex; flex-direction: row; align-items: center; }
.grow { flex: 1; min-width: 0; }
.gap4 { gap: 4px; } .gap6 { gap: 6px; } .gap8 { gap: 8px; } .gap12 { gap: 12px; }
.wrap { flex-wrap: wrap; }

/* Top app bar */
.top-bar { height: 64px; flex: none; display: flex; align-items: center; padding: 0 4px; position: relative; }
.top-bar .title { font-size: 22px; line-height: 28px; font-weight: 700; }
.top-bar.centered .title { position: absolute; left: 0; right: 0; text-align: center; pointer-events: none; }
.top-bar.centered .actions { margin-left: auto; }
.top-bar .nav { margin-right: 4px; }
.top-bar .btn.text { padding: 0 12px; }
.top-bar .btn.icon, .btn.icon { padding: 0; width: 40px; min-width: 40px; }

/* Buttons */
.btn {
  height: 40px; min-width: 48px; padding: 0 24px; border-radius: 20px; border: none;
  font-size: 14px; font-weight: 500; letter-spacing: 0.1px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; position: relative;
  overflow: hidden; white-space: nowrap; user-select: none; flex: none;
  background: transparent; color: var(--primary);
}
.btn::after { content: ""; position: absolute; inset: 0; background: currentColor; opacity: 0; transition: opacity 0.15s; }
.btn:hover::after { opacity: 0.08; }
.btn:active::after { opacity: 0.12; }
.btn:focus-visible { outline: 2px solid var(--secondary); outline-offset: 2px; }
.btn.filled { background: var(--primary); color: var(--on-primary); }
.btn.tonal { background: var(--secondary-container); color: var(--on-secondary-container); }
.btn.outlined { border: 1px solid var(--outline); color: var(--primary); }
.btn.text { padding: 0 12px; }
.btn.wide { width: 100%; }
.map-nav .btn.icon { padding: 0; }
.btn.flex { flex: 1; min-width: 0; padding: 0 12px; }
.btn:disabled { cursor: default; color: color-mix(in srgb, var(--on-surface) 38%, transparent); }
.btn:disabled::after { opacity: 0; }
.btn.filled:disabled, .btn.tonal:disabled { background: color-mix(in srgb, var(--on-surface) 12%, transparent); }
.btn.outlined:disabled { border-color: color-mix(in srgb, var(--on-surface) 12%, transparent); }
.btn.tall { height: auto; min-height: 40px; white-space: normal; padding: 10px 24px; text-align: center; }

/* Chips */
.chip {
  height: 32px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--outline-variant);
  background: transparent; color: var(--on-surface-variant); font-size: 14px; font-weight: 500;
  letter-spacing: 0.1px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  white-space: nowrap; flex: none; position: relative; overflow: hidden;
}
.chip.assist { color: var(--on-surface); border-color: var(--outline); }
.chip.selected { background: var(--secondary-container); color: var(--on-secondary-container); border-color: transparent; padding-left: 8px; }
.chip.selected::before { content: "✓"; font-size: 16px; width: 18px; text-align: center; }
.chip::after { content: ""; position: absolute; inset: 0; background: currentColor; opacity: 0; }
.chip:hover::after { opacity: 0.08; }
.chip:disabled { opacity: 0.38; cursor: default; }
.chip:disabled::after { opacity: 0; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.flow { display: flex; flex-wrap: wrap; gap: 0 6px; }
.flow .chip { margin: 4px 0; }

/* Cards and surfaces */
.card { background: var(--surface-container-highest); border-radius: 12px; color: var(--on-surface); }
.card.primary { background: var(--primary-container); color: var(--on-primary-container); }
.card.tertiary { background: var(--tertiary-container); color: var(--on-tertiary-container); }
.card.raised { box-shadow: 0 3px 6px rgba(0, 0, 0, 0.25), 0 1px 3px rgba(0, 0, 0, 0.2); }
.pad16 { padding: 16px; }
.surface-variant { background: var(--surface-variant); border-radius: 16px; }
.surface-plain { background: var(--surface); color: var(--on-surface); border-radius: 8px; }
.secondary-surface { background: var(--secondary-container); color: var(--on-secondary-container); border-radius: 12px; cursor: pointer; }
.elevated2 { background: color-mix(in srgb, var(--primary) 7%, var(--surface)); }
.highlight { background: var(--tertiary); color: var(--on-tertiary); font-weight: 700; }

/* Progress */
.progress { height: 4px; width: 100%; border-radius: 2px; background: var(--secondary-container); overflow: hidden; position: relative; flex: none; }
.progress > div { height: 100%; background: var(--primary); border-radius: 2px; transition: width 0.2s; }
.progress.indeterminate > div { position: absolute; width: 40%; animation: indet 1.6s infinite cubic-bezier(0.4, 0, 0.2, 1); }
@keyframes indet { 0% { left: -40%; } 100% { left: 100%; } }

/* Keypad */
.bottom { flex: none; padding-bottom: env(safe-area-inset-bottom); }
.keypad { padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.keypad .row { gap: 6px; }
.key { height: 52px; flex: 1; padding: 0; font-size: 24px; font-weight: 400; }
.key.search { font-size: 18px; font-weight: 500; }
.key.back { background: transparent; color: var(--on-surface); border-radius: 0; }

/* Text field */
.field {
  height: 56px; border: 1px solid var(--outline); border-radius: 4px; background: transparent;
  padding: 0 16px; font-size: 16px; letter-spacing: 0.5px; min-width: 0; outline: none;
}
.field:focus { border: 2px solid var(--primary); padding: 0 15px; }
.field::placeholder { color: var(--on-surface-variant); }
textarea.field { height: auto; min-height: 56px; padding: 16px; resize: none; line-height: 24px; }
textarea.field:focus { padding: 15px; }

/* Dialogs */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.32); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 24px 0; }
.dialog {
  background: var(--surface-container-high); color: var(--on-surface); border-radius: 28px;
  min-width: 280px; max-width: min(560px, calc(100vw - 48px)); max-height: 100%;
  padding: 24px; display: flex; flex-direction: column; gap: 16px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}
.dialog .d-title { font-size: 24px; line-height: 32px; }
.dialog .d-icon { text-align: center; }
.dialog .d-text { color: var(--on-surface-variant); overflow-y: auto; overscroll-behavior-y: contain; min-height: 0; flex: 1; }
.dialog .d-buttons { display: flex; justify-content: flex-end; gap: 8px; }
.dialog .d-title.center { text-align: center; }

/* Switch and checkbox */
.switch { width: 52px; height: 32px; border-radius: 16px; border: 2px solid var(--outline); background: var(--surface-container-highest); position: relative; cursor: pointer; flex: none; padding: 0; }
.switch::before { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; background: var(--outline); top: 6px; left: 6px; transition: all 0.15s; }
.switch.on { background: var(--primary); border-color: var(--primary); }
.switch.on::before { width: 24px; height: 24px; top: 2px; left: 22px; background: var(--on-primary); }
.check { display: inline-flex; align-items: center; cursor: pointer; user-select: none; }
.check .box { width: 18px; height: 18px; margin: 11px; border: 2px solid var(--on-surface-variant); border-radius: 2px; display: flex; align-items: center; justify-content: center; font-size: 14px; line-height: 1; font-weight: 700; }
.check.on .box { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }

/* Dial */
.dial { position: relative; touch-action: none; display: flex; align-items: center; justify-content: center; flex: none; }
.dial canvas { position: absolute; inset: 0; }
.dial .middle { position: relative; display: flex; flex-direction: column; align-items: center; pointer-events: none; }

/* Map */
.map-box { flex: 1; position: relative; min-height: 0; }
.map-box canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.empty-map { position: absolute; inset: 0; padding: 32px; display: flex; align-items: center; justify-content: center; text-align: center; }
.point-card { position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 2; }
.digit-level { position: absolute; inset: 0; display: flex; flex-direction: column; }
.digit-rows { flex: 1; overflow-y: auto; overscroll-behavior-y: contain; position: relative; }
.digit-row { position: absolute; left: 0; right: 0; height: 28px; display: flex; align-items: center; padding: 0 16px; }
.digit-row.tap { cursor: pointer; }
.digit-row .place { width: 96px; flex: none; font-size: 10px; color: var(--on-surface-variant); font-family: var(--mono); }
.digit-row .digits { font-family: var(--mono); font-size: 16px; white-space: pre; letter-spacing: 0; }
.mine-hit { background: var(--tertiary); color: var(--on-tertiary); font-weight: 700; }
.other-hit { background: var(--primary-container); color: var(--on-primary-container); font-weight: 700; }
.centre-hit { background: var(--surface-variant); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20;
  background: var(--inverse-surface); color: var(--inverse-on-surface); padding: 14px 16px;
  border-radius: 4px; box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}
.gold { color: var(--gold); }

/* First Finder badge */
.badge {
  padding: 16px; border-radius: 16px; border: 2px solid var(--gold);
  background: color-mix(in srgb, var(--gold) 14%, var(--surface)); color: var(--on-surface);
}
.badge-title { color: color-mix(in srgb, var(--gold) 55%, var(--on-surface)); letter-spacing: 2px; }

/* Live */
.live-row {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; padding: 12px 16px; flex: none;
  border: none; font: inherit; text-align: left; cursor: pointer; position: relative; overflow: hidden;
}
.live-row::after { content: ""; position: absolute; inset: 0; background: currentColor; opacity: 0; }
.live-row:hover::after { opacity: 0.06; }
.live-row:focus-visible { outline: 2px solid var(--secondary); outline-offset: 2px; }
.live-digits { word-break: break-all; }
.pad-note { padding: 4px 4px 16px; }
.live-new { color: color-mix(in srgb, var(--gold) 55%, var(--on-surface)); }
@media (max-width: 400px) {
  .top-bar.centered .title { font-size: 18px; position: static; flex: 1; min-width: 0; text-align: left; padding-left: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .top-bar.centered .actions { margin-left: 0; }
  .top-bar.centered .btn.text { padding: 0 8px; }
}

/* Milestone badges */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.badge-tile {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 8px; border-radius: 12px;
  font: inherit; text-align: center; color: var(--on-surface); cursor: pointer; min-width: 0;
}
.badge-tile.earned { border: 2px solid var(--gold); background: color-mix(in srgb, var(--gold) 14%, var(--surface)); }
.badge-tile.locked { border: 1px dashed var(--outline); background: transparent; cursor: default; opacity: 0.7; }
.badge-tile:focus-visible { outline: 2px solid var(--secondary); outline-offset: 2px; }
.badge-icon {
  width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; background: var(--surface-variant); color: var(--on-surface-variant);
}
.badge-tile.earned .badge-icon { background: var(--gold); color: #3a2c00; }
.badge-detail { color: var(--on-surface-variant); overflow-wrap: anywhere; }

/* Immersive Pi Map: the map fills the screen, the controls float over it, see-through. */
.map-screen .map-box { position: absolute; inset: 0; }
.map-screen .digit-level { padding-top: calc(64px + env(safe-area-inset-top)); }
.glass {
  background: color-mix(in srgb, var(--surface-container-high) 78%, transparent);
  color: var(--on-surface); border: none;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
}
.map-top {
  position: absolute; left: 0; right: 0; top: 0; z-index: 3; display: flex; align-items: center; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 8px 8px; pointer-events: none;
}
.map-top > * { pointer-events: auto; }
.round {
  width: 44px; height: 44px; border-radius: 22px; flex: none; padding: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; color: var(--on-surface);
}
.round.small { width: 36px; height: 36px; background: transparent; border: none; color: inherit; }
.seg { display: flex; height: 44px; border-radius: 22px; padding: 4px; gap: 2px; min-width: 0; }
.seg button {
  border: none; background: transparent; color: var(--on-surface-variant); border-radius: 18px; padding: 0 12px;
  font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.seg button.on { background: var(--secondary-container); color: var(--on-secondary-container); }
.map-search { display: flex; align-items: center; height: 44px; border-radius: 22px; padding: 0 4px 0 16px; gap: 4px; }
.map-search input { border: none; background: transparent; outline: none; font-size: 16px; height: 100%; min-width: 0; }
.map-find {
  border: none; background: var(--primary); color: var(--on-primary); border-radius: 18px; height: 36px; padding: 0 14px;
  font-weight: 500; cursor: pointer; flex: none;
}
.map-find:disabled { background: color-mix(in srgb, var(--on-surface) 12%, transparent); color: color-mix(in srgb, var(--on-surface) 38%, transparent); cursor: default; }
.menu-scrim { position: absolute; inset: 0; z-index: 4; }
.map-menu {
  position: absolute; right: 8px; top: calc(60px + env(safe-area-inset-top)); z-index: 5; width: 280px; max-width: calc(100% - 16px);
  border-radius: 16px; padding: 4px 0;
}
.map-menu .check { padding: 0 8px; }
.menu-item {
  display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 16px; border: none; background: transparent;
  color: inherit; text-align: left; font-size: 14px; cursor: pointer;
}
.menu-note { padding: 0 16px 12px; }
.map-bottom {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 0 8px calc(12px + env(safe-area-inset-bottom)); pointer-events: none;
}
.map-bottom > * { pointer-events: auto; }
.map-pill { display: flex; align-items: center; border-radius: 24px; padding: 2px 4px; min-height: 48px; max-width: 100%; }
.pill-text { padding: 0 8px; min-width: 0; }
.map-screen .point-card { position: relative; left: auto; right: auto; bottom: auto; width: 100%; padding: 4px 16px 8px; touch-action: none; transition: transform 0.2s; }
.glass-card {
  background: color-mix(in srgb, var(--primary-container) 82%, transparent); color: var(--on-primary-container);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
}
.grab { width: 32px; height: 4px; border-radius: 2px; background: currentColor; opacity: 0.4; align-self: center; margin: 4px 0 2px; }
.card-acts { margin-top: 2px; }
.card-act {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border: none;
  background: transparent; color: inherit; border-radius: 12px; font-size: 12px; font-weight: 500; cursor: pointer;
}
.card-act:hover, .round.small:hover, .menu-item:hover { background-color: color-mix(in srgb, currentColor 8%, transparent); }
.menu-icon { width: 20px; text-align: center; font-size: 18px; flex: none; }
/* Pi Map place filter */
.map-filter {
  position: absolute; left: 8px; right: 8px; top: calc(60px + env(safe-area-inset-top)); z-index: 5; max-width: 420px; margin: 0 auto;
  border-radius: 16px; padding: 16px; gap: 12px;
}
.range-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.range-field { gap: 4px; }
.range-field input {
  height: 44px; border-radius: 8px; border: 1px solid var(--outline); background: transparent; padding: 0 12px; font-size: 16px; min-width: 0; outline: none;
}
.range-field input:focus { border: 2px solid var(--primary); padding: 0 11px; }
.range-acts { justify-content: flex-end; }
.error-text { color: var(--tertiary); }
.range-pill { padding: 0 4px 0 0; min-height: 40px; }
.range-open {
  display: flex; align-items: center; gap: 8px; border: none; background: transparent; color: inherit; padding: 0 4px 0 14px; min-height: 40px;
  cursor: pointer; min-width: 0; text-align: left;
}
.stretch-btn {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: none; border-radius: 12px; text-align: left; cursor: pointer;
  background: var(--primary); color: var(--on-primary);
}
.stretch-btn .col { gap: 2px; }

/* Ko-fi card under the quick searches */
.support {
  display: flex; gap: 12px; align-items: flex-start; margin: 8px 0 12px; padding: 14px 16px; border-radius: 16px;
  background: var(--secondary-container); color: var(--on-secondary-container);
}
.support-icon { font-size: 24px; line-height: 28px; }
.support-text { gap: 4px; min-width: 0; }
.support-btn {
  align-self: flex-start; margin-top: 6px; padding: 6px 16px; border-radius: 999px; text-decoration: none;
  background: var(--primary); color: var(--on-primary);
}
.support-btn:hover, .support-btn:focus-visible { filter: brightness(1.08); text-decoration: underline; }
