:root {
  --bg: #0b0f1c;
  --glass: rgba(14, 19, 34, 0.78);
  --line: rgba(255, 255, 255, 0.09);
  --text: #e8edf7;
  --muted: rgba(232, 237, 247, 0.62);
  --accent: #66b8ff;
  --accent2: #7ee0d3;
  --warn: #ffad5c;
  --tile: rgba(255, 255, 255, 0.045);
  --tile-hover: rgba(255, 255, 255, 0.08);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font: 13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
h1 { font: 600 22px/1.15 var(--serif); letter-spacing: 0.2px; }
h1 em { font-style: italic; color: var(--accent); }
h2 { font-size: 16px; font-weight: 600; line-height: 1.25; }
h3 { font-size: 12.5px; font-weight: 650; margin-bottom: 4px; }
.small { font-size: 11.5px; }
.tiny { font-size: 10.5px; }
.muted { color: var(--muted); }
.warn { color: var(--warn); }
[hidden] { display: none !important; }

#map { position: fixed; inset: 0; width: 100%; height: 100%; border: 0; background: var(--bg); }
.mapwait { position: fixed; inset: 0; display: grid; place-items: center; color: var(--muted); pointer-events: none; }
#rings, #flashlayer { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#flashlayer { background: #fff; mix-blend-mode: screen; opacity: 0; }

.card { position: fixed; background: var(--glass); border: 1px solid var(--line); border-radius: 14px;
  backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35); }

/* ---- header */
.head { top: 14px; left: 14px; padding: 12px; width: 340px; display: grid; gap: 9px; }
.row { display: flex; gap: 8px; }
.qwrap { position: relative; flex: 1; min-width: 0; display: flex; }
.suggest { position: absolute; top: calc(100% + 6px); left: 0; right: -110px; margin: 0; padding: 4px; list-style: none; z-index: 5;
  background: rgba(14, 19, 34, 0.97); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); }
.suggest li { display: flex; align-items: baseline; gap: 6px; padding: 6px 8px; border-radius: 7px; cursor: pointer; white-space: nowrap; overflow: hidden; }
.suggest li:hover, .suggest li.on { background: rgba(102, 184, 255, 0.15); }
.suggest span { color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; }
.suggest em { margin-left: auto; font-style: normal; font-size: 10px; color: var(--accent); flex: none; }
input[type=search] { flex: 1; min-width: 0; padding: 7px 10px; border-radius: 9px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06); outline: none; }
input[type=search]:focus { border-color: var(--accent); }
.primary { display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 9px; padding: 7px 12px; cursor: pointer;
  font-weight: 600; color: #08101e; background: linear-gradient(135deg, var(--accent2), var(--accent)); white-space: nowrap; }
.primary svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.primary:hover { filter: brightness(1.08); }
.ghost { border: 1px solid var(--line); background: var(--tile); border-radius: 8px; padding: 5px 10px; cursor: pointer; }
.ghost:hover { background: var(--tile-hover); }

/* ---- panel */
.panel { top: 14px; right: 14px; bottom: 14px; width: 344px; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 16px;
  scrollbar-width: thin; }
.panel section { display: grid; gap: 5px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.sheet-handle { display: none; }
.topline { display: flex; gap: 11px; align-items: center; }
.grow { flex: 1; min-width: 0; }
.play { width: 42px; height: 42px; border-radius: 50%; border: 0; cursor: pointer; flex: none; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent2), var(--accent)); color: #08101e; }
.play svg { width: 20px; height: 20px; fill: currentColor; }
.play .i-play { display: none; } .play.paused .i-play { display: block; } .play.paused .i-pause { display: none; }
.words { font-weight: 600; font-size: 14px; color: var(--muted); }
.words.wet { color: var(--accent); }
.vol { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.vol svg { width: 17px; height: 17px; fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
input[type=range] { flex: 1; accent-color: var(--accent); }

/* ---- mode grid */
.modes { display: grid; gap: 10px; }
.group-label { font-size: 9.5px; font-weight: 650; letter-spacing: 0.9px; text-transform: uppercase; color: var(--muted); margin-bottom: 5px; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.tile { position: relative; display: grid; justify-items: center; gap: 4px; padding: 6px 2px; border-radius: 11px; cursor: pointer;
  border: 1px solid transparent; background: var(--tile); transition: background 0.15s, border-color 0.2s, transform 0.12s; }
.tile:hover { background: var(--tile-hover); }
.tile:active { transform: scale(0.97); }
.tile.on { background: rgba(102, 184, 255, 0.14); border-color: rgba(102, 184, 255, 0.85); }
.art { position: relative; width: 100%; height: 40px; display: grid; place-items: center; overflow: hidden; border-radius: 9px; }
.glyph { width: 26px; height: 26px; fill: none; stroke: rgba(232, 237, 247, 0.62); stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round;
  vector-effect: non-scaling-stroke; position: relative; }
.tile:hover .glyph { stroke: rgba(232, 237, 247, 0.85); }
.tile.on .glyph { stroke: var(--accent); stroke-width: 1.5; }
.tname { font-size: 9.5px; letter-spacing: -0.1px; font-weight: 500; color: rgba(232, 237, 247, 0.7); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tile.on .tname { font-weight: 650; color: var(--text); }
/* a few streaks drifting down behind the chosen glyph */
.drops { position: absolute; inset: 0; opacity: 0; transition: opacity 0.3s; pointer-events: none;
  background-image: linear-gradient(170deg, transparent 0 45%, rgba(102, 184, 255, 0.32) 46% 54%, transparent 55%);
  background-size: 9px 13px; animation: fall 0.9s linear infinite; mask-image: linear-gradient(transparent, #000 20%, #000 80%, transparent); }
.tile.on .drops { opacity: 1; }
@keyframes fall { from { background-position: 0 0; } to { background-position: -2px 13px; } }
@media (prefers-reduced-motion: reduce) { .drops { animation: none; } }
.mode-now { display: flex; gap: 8px; align-items: flex-start; margin-top: 4px; }
.mode-now .glyph { width: 18px; height: 18px; stroke: var(--accent); stroke-width: 1.4; flex: none; margin-top: 1px; }

/* ---- rose, legend, meters */
#rose { width: 100%; height: 190px; }
.legend { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 3px 8px; font-size: 10px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.legend i { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.field { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
select { background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-radius: 7px; padding: 3px 6px; }
.meter { display: grid; grid-template-columns: 100px 1fr; align-items: center; gap: 8px; }
.bar { height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.4s; }
#dry { justify-self: start; margin-top: 2px; }

/* ---- weather controls */
.switch { display: flex; justify-content: space-between; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.knob { width: 34px; height: 20px; border-radius: 10px; background: rgba(255, 255, 255, 0.16); position: relative; flex: none; transition: background 0.2s; }
.knob::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.switch input:checked + .knob { background: var(--accent); }
.switch input:checked + .knob::after { transform: translateX(14px); }
.switch input:focus-visible + .knob { outline: 2px solid var(--accent); outline-offset: 2px; }
#sliders { display: grid; gap: 6px; margin-top: 8px; }
.slider { display: grid; grid-template-columns: 78px 1fr 60px; align-items: center; gap: 6px; font-size: 11.5px; }
.slider output { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.check { display: flex; gap: 6px; align-items: center; font-size: 11.5px; }
footer { display: grid; gap: 3px; }

.spinner { display: inline-block; width: 9px; height: 9px; border: 1.5px solid var(--muted); border-top-color: transparent; border-radius: 50%;
  animation: spin 0.8s linear infinite; vertical-align: -1px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- start veil */
.veil { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(6, 9, 18, 0.55);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); transition: opacity 0.5s; z-index: 10; }
.veil.gone { opacity: 0; pointer-events: none; }
.veil-card { max-width: 420px; text-align: center; display: grid; gap: 14px; justify-items: center; }
.veil-card h1 { font-size: 34px; }
.veil-card p { color: var(--muted); font-size: 14px; line-height: 1.5; }
.veil-art { width: 56px; height: 56px; fill: none; stroke: var(--accent); stroke-width: 1.1; stroke-linecap: round; stroke-linejoin: round; }
.primary.big { font-size: 15px; padding: 11px 22px; border-radius: 12px; }

.toast { position: fixed; left: 50%; top: 18px; transform: translate(-50%, -20px); opacity: 0; transition: 0.3s; padding: 8px 14px;
  border-radius: 10px; background: var(--glass); border: 1px solid var(--line); z-index: 11; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- phones: the panel becomes a bottom sheet */
@media (max-width: 760px) {
  .head { left: 16px; right: 16px; width: auto; top: max(12px, env(safe-area-inset-top)); padding: 10px; gap: 7px; }
  .head h1 { font-size: 18px; }
  .head p { display: none; }
  .panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 78vh; background: rgba(12, 16, 30, 0.95); border-radius: 16px 16px 0 0; padding: 0 16px 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom)); transform: translateY(calc(100% - 132px)); transition: transform 0.3s; }
  body.sheet-open .panel { transform: none; }
  .sheet-handle { display: block; position: sticky; top: 0; height: 22px; margin: 0 -16px; border: 0; background: transparent; cursor: pointer; z-index: 1; }
  .sheet-handle span { display: block; width: 38px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.3); margin: 0 auto; }
  .veil-card h1 { font-size: 28px; }
}
