/* 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%; }
.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); }
