/* Copyright © 2026 Evan Cunningham <evan@mediathread.net> */
/* Coast Dashboard v2: designed for a 10" 1280x800 touch screen. */
:root {
  color-scheme: light;
  --ink: #18223b;
  --muted: #5d6477;
  --line: #d9dde7;
  --paper: #eef1f7;
  --card: #fffefa;
  --teal: #17306c;
  --teal-bright: #4563a9;
  --link: var(--teal);
  --surface: #ffffff;
  --soft: #eef1f7;
  --soft2: #e7eaf1;
  --soft3: #dce2ef;
  --rule: #b9c1d6;
  --strong: #152b5f;
  --faint: #868b97;
  --dot: #c3cbdd;
  --coral: #e27d62;
  --sun: #efbd61;
  --t-ferry: #234a96;
  --t-weather: #2a8199;
  --t-restaurants: #bb613f;
  --t-tides: #1b6b7b;
  --t-roads: #4d5f76;
  --t-power: #6e4e9b;
  --t-air: #41875a;
  --t-water: #2f77a8;
  --t-webcams: #51698a;
  --t-screenoff: #2a2e38;
  --bar-h: 72px;
  --foot-h: 68px;
  --sans: "DM Sans", "Avenir Next", system-ui, sans-serif;
  --display: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  width: 100%; height: 100%; margin: 0; overflow: hidden;
  overscroll-behavior: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
/* Native-app feel: no visible scrollbars anywhere, scrolling still works. */
* { scrollbar-width: none; -ms-overflow-style: none; }
*::-webkit-scrollbar { display: none; width: 0; height: 0; }
img, svg { -webkit-user-drag: none; }
body {
  display: grid;
  grid-template-rows: var(--bar-h) minmax(0, 1fr) var(--foot-h);
  color: var(--ink);
  background-color: var(--paper);
  background-image: radial-gradient(var(--dot) 0.7px, transparent 0.7px);
  background-size: 18px 18px;
  font-family: var(--sans);
  font-size: 20px;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  transition: filter 1s ease;
}
body.is-night { filter: brightness(0.55) saturate(0.85); }
button, input, select, a { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
a { color: var(--link); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #e28a68; outline-offset: 2px; }
sup { font-size: .45em; vertical-align: top; position: relative; top: .15em; }

.stale-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 50; padding: 8px 14px; color: #fff; background: #b3261e; font-size: 18px; font-weight: 700; text-align: center; }

/* App bar */
.app-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 8px 28px 0;
  color: var(--ink);
}
.bar-left { display: flex; align-items: center; gap: 18px; min-width: 0; }
.app-title { grid-column: 2; color: var(--ink); margin: 0; font-family: var(--display); font-size: 32px; font-weight: 500; letter-spacing: .2px; text-align: center; }
.back-button {
  min-height: 52px;
  padding: 0 20px 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--rule);
  border-radius: 26px;
  color: var(--link);
  background: var(--surface);
  font-size: 22px;
  font-weight: 600;
}
.back-button:active { background: var(--soft3); }
.clock-block {
  display: grid; justify-items: start; line-height: 1.1;
  margin: -6px -12px; padding: 6px 12px;
  border: 0; border-radius: 14px; background: transparent;
  color: inherit; text-align: left; cursor: pointer;
}
.clock-block:active { opacity: .6; }
.clock { font-size: 32px; font-weight: 700; font-variant-numeric: tabular-nums; }
.today { font-size: 17px; color: var(--muted); }
body[data-view]:not([data-view="home"]) .clock-block { display: none; }

.views { position: relative; min-height: 0; padding: 8px 28px 14px; }
.view { height: 100%; min-height: 0; animation: arrive 260ms ease-out backwards; }
@keyframes arrive { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Footer: status on the left, settings gear bottom right */
.app-footer { display: flex; align-items: center; justify-content: flex-start; padding: 0 28px; overflow: hidden; }
body[data-view="home"] { --foot-h: 0px; }
body:not([data-view="home"]) { --foot-h: 40px; }
.app-bar .settings-fab { justify-self: end; grid-column: 3; width: 48px; height: 48px; }
.footer-status { color: var(--muted); font-size: 17px; }
.footer-status > span { display: none; }
body[data-view="ferry"] .foot-ferry,
body[data-view="weather"] .foot-weather,
body[data-view="restaurants"] .foot-restaurants,
body[data-view="events"] .foot-events,
body[data-view="tides"] .foot-tides,
body[data-view="roads"] .foot-roads,
body[data-view="power"] .foot-power,
body[data-view="air"] .foot-air,
body[data-view="water"] .foot-water,
body[data-view="webcams"] .foot-webcams { display: inline; }
.settings-fab {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border: 0; border-radius: 0;
  color: var(--muted);
  background: transparent;
  box-shadow: none;
  opacity: .75;
  padding: 0;
  transition: opacity 140ms ease, color 140ms ease, transform 180ms ease;
}
.settings-fab:hover {
  opacity: 1;
  color: var(--ink);
}
.settings-fab:active {
  opacity: 1;
  color: var(--teal-bright);
  background: transparent;
  transform: rotate(25deg) scale(.95);
}

.action-button {
  min-height: 52px; padding: 0 22px;
  border: 1px solid var(--rule); border-radius: 10px;
  color: var(--link); background: var(--surface);
  font-size: 20px; font-weight: 700;
}
.action-button:active { background: var(--soft3); }
.action-button.is-primary { border-color: var(--teal); color: #fff; background: var(--teal); }
.action-button:disabled { opacity: .5; }
.eyebrow { margin: 0 0 6px; color: var(--muted); font-size: 16px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; }

/* Home tiles */
.view-home { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); gap: 14px; padding-bottom: 4px; }
.tile {
  min-height: 0;
  padding: 26px 30px;
  display: flex; align-items: center; gap: 26px;
  border: 0; border-radius: 22px;
  color: #fff; text-align: left;
  background-image: linear-gradient(135deg, rgba(0,0,0,.22), rgba(255,255,255,.14));
  box-shadow: 0 6px 18px rgba(20, 30, 60, .22);
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.tile:active { transform: scale(.975); box-shadow: 0 2px 8px rgba(20, 30, 60, .25); }
.tile-ferry { background-color: var(--t-ferry); }
.tile-weather { background-color: var(--t-weather); }
.tile-events { background-color: var(--t-webcams); }
.tile-restaurants { background-color: var(--t-restaurants); }
.tile-tides { background-color: var(--t-tides); }
.tile-roads { background-color: var(--t-roads); }
.tile-power { background-color: var(--t-power); }
.tile-air { background-color: var(--t-air); }
.tile-ferry, .tile-events { grid-column: span 2; }
.tile-restaurants .tile-icon { display: none; }
.tile-water { background-color: var(--t-water); }
.tile-water.is-clear { background-color: #3f8a58; }
.tile-water.is-warn { background-color: #c8741f; }
.tile-water.is-bad { background-color: #a83a35; }
.tile-webcams { background-color: var(--t-webcams); }
.tile-screenoff { background-color: var(--t-screenoff); }
.blackout { position: fixed; inset: 0; z-index: 2000; background: #000; cursor: none; touch-action: manipulation; }
.blackout[hidden] { display: none; }
.tile { position: relative; overflow: hidden; padding: 16px 22px; gap: 18px; }
.tile-icon { width: 76px; height: 76px; border-radius: 20px; }
.tile-icon svg { width: 52px; height: 52px; }
.tile-glyph { font-size: 48px; }
.tile-name { font-size: 17px; }
.tile-main { font-size: 40px; }
.tile-sub { font-size: 19px; }
.tile-small .tile-main { font-size: 32px; white-space: nowrap; }
.tile-small .tile-sub { font-size: 18px; }
.tile-small .tile-sub, .tile-weather .tile-sub { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.2; }
.tile-roads.is-alert { background: linear-gradient(135deg, #8a5a10, #c98a1c); }
.tile-roads.is-closed, .tile-power.is-out { background: linear-gradient(135deg, #8e2a2a, #c4453f); }
.tile-roads.is-clear, .tile-power.is-clear { background: linear-gradient(135deg, #2f6b46, #54a06c); }
.tile-air.is-warn { background: linear-gradient(135deg, #8a5a10, #c98a1c); }
.tile-air.is-bad { background: linear-gradient(135deg, #8e2a2a, #c4453f); }

/* Data freshness: a small chip when data is fine, a coloured ribbon when it can't be trusted */
.fresh-chip {
  position: absolute; top: 10px; right: 14px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px; border-radius: 999px;
  background: rgba(0, 0, 0, .22); font-size: 14px; font-weight: 700; letter-spacing: .4px;
}
.fresh-chip::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: #7be39b; }
.fresh-ribbon {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 5px 14px; font-size: 16px; font-weight: 700; text-align: center;
  color: #1b1300; background: #ffc83d;
}
.fresh-ribbon[data-state="changed"] { background: #ff9a3d; }
.fresh-ribbon[data-state="offline"] { background: #ff6b5f; color: #fff; }
.tile.is-unsure { padding-bottom: 40px; }
.tile.is-unsure .tile-copy { opacity: .6; }
.tile.is-unsure .fresh-chip { display: none; }
.tile.is-loading .fresh-chip::before { background: #c9d0e4; }
.foot-fresh { flex: 1; margin: 0 16px; padding: 6px 14px; border-radius: 10px; font-size: 17px; font-weight: 700; color: #1b1300; background: #ffc83d; }
.foot-fresh[data-state="changed"] { background: #ff9a3d; }
.foot-fresh[data-state="offline"] { background: #ff6b5f; color: #fff; }
.foot-fresh[hidden] { display: none; }
.footer-status a { color: inherit; }

/* Detail views for the coastal tiles */
.view-tides { display: grid; grid-template-columns: 400px minmax(0, 1fr); gap: 22px; }
.view-detail { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 22px; }
.detail-card { border-radius: 18px; background: var(--card); box-shadow: 0 3px 14px rgba(20, 30, 60, .12); padding: 22px 26px; min-height: 0; }
.detail-list { overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; display: grid; gap: 12px; align-content: start; }
.detail-summary { display: flex; flex-direction: column; gap: 14px; }
.detail-lead { margin: 0; font-size: 22px; line-height: 1.35; color: var(--ink); }
.detail-note { margin: 6px 0 0; font-size: 16px; color: var(--muted); }
.status-badge { align-self: flex-start; padding: 10px 22px; border-radius: 14px; color: #fff; font-family: var(--display); font-size: 40px; background: #2f6b46; }
.status-badge.is-warn { background: #b57a14; }
.status-badge.is-bad { background: #b3342e; }
.detail-item { padding: 12px 16px; border-radius: 12px; border-left: 6px solid #b57a14; background: var(--soft); }
.detail-item h3 { margin: 0 0 4px; font-size: 21px; line-height: 1.25; }
.detail-item p { margin: 0; font-size: 17px; line-height: 1.35; color: var(--muted); }
.detail-item.is-bad { border-left-color: #b3342e; }
.detail-item.is-ok { border-left-color: #2f6b46; }
.detail-empty { margin: 0; font-size: 22px; color: var(--muted); }
.tide-now { display: flex; flex-direction: column; gap: 8px; }
.tide-level { display: flex; align-items: baseline; gap: 8px; }
.tide-level strong { font-family: var(--display); font-size: 84px; font-weight: 500; line-height: 1; }
.tide-unit { font-size: 28px; color: var(--muted); }
.tide-arrow { font-size: 44px; color: var(--teal-bright); }
.tide-trend { margin: 0; font-size: 22px; }
.tide-next { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.tide-next li { display: flex; justify-content: space-between; padding: 8px 14px; border-radius: 10px; background: var(--soft); font-size: 21px; }
.tide-next li strong { font-weight: 700; }
.tide-chart-card { display: flex; flex-direction: column; }
.tide-chart { flex: 1; min-height: 0; width: 100%; }
.tide-chart text { font: 600 13px var(--sans); fill: var(--muted); }
.tile-icon { flex: none; width: 96px; height: 96px; display: grid; place-items: center; border-radius: 24px; background: rgba(255,255,255,.16); }
.tile-glyph { font-size: 60px; line-height: 1; }
.tile-copy { min-width: 0; display: grid; gap: 4px; }
.tile-name { font-size: 20px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase; opacity: .85; }
.tile-main { font-family: var(--display); font-size: 46px; font-weight: 500; line-height: 1.08; }
.tile-sub { font-size: 22px; opacity: .9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Ferry */
.view-ferry { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 22px; }
.ferry-summary, .ferry-schedule-pane, .weather-now, .forecast-section, .view-restaurants {
  border-radius: 18px; background: var(--card); box-shadow: 0 3px 14px rgba(20, 30, 60, .12);
}
.ferry-summary { padding: 24px; display: flex; flex-direction: column; gap: 10px; }
.ferry-summary h2 { margin: 0; font-family: var(--display); font-size: 34px; font-weight: 500; line-height: 1.12; }
.route-bar { margin-top: 8px; display: flex; align-items: center; gap: 10px; }
.route-stop { display: grid; line-height: 1.2; }
.route-stop small { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 1px; }
.route-stop strong { font-size: 20px; }
.route-line { flex: 1; height: 2px; background: repeating-linear-gradient(90deg, var(--teal-bright) 0 7px, transparent 7px 13px); }
.crossing-time { margin: 0; color: var(--muted); font-size: 18px; }
.crossing-time strong { color: var(--link); font-size: 28px; }
.leaveby-subtitle { margin: 12px 0 0; font-size: 20px; font-weight: 700; }
.leaveby-note { margin: 0; color: var(--muted); font-size: 16px; line-height: 1.4; }
.ferry-summary .action-button { margin-top: auto; }
.ferry-schedule-pane { padding: 8px 22px 14px; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; }

.sailing-list { display: grid; }
.sailing-day + .sailing-day { margin-top: 12px; }
.sailing-day-heading { margin: 10px 0 2px; color: var(--muted); font-size: 15px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; }
.sailing-row { min-height: 68px; padding: 8px 0; display: grid; grid-template-columns: 124px minmax(0, 1fr) auto; gap: 14px; align-items: center; border-top: 1px solid var(--line); }
.sailing-time { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sailing-info { min-width: 0; display: grid; gap: 2px; }
.sailing-vessel { color: var(--muted); font-size: 18px; }
.sailing-capacity-detail { color: var(--muted); font-size: 17px; }
.sailing-leaveby { color: var(--strong); font-size: 18px; font-weight: 700; }
.sailing-leaveby.is-late { color: #b45309; }
.sailing-leaveby.is-missed { color: #8a5a5a; font-weight: 600; }
.sailing-state { padding: 9px 13px; border-radius: 6px; color: var(--muted); background: var(--soft2); font-size: 16px; font-weight: 700; text-transform: uppercase; white-space: nowrap; }
.sailing-state.is-open { color: var(--strong); background: var(--soft3); }
.sailing-state.is-low { color: #744519; background: #f7e7c8; }
.sailing-state.is-cancelled { color: #fff; background: #ad5748; }
.sailing-row.is-next .sailing-time { color: var(--link); }
.sailing-row.is-next .sailing-state { color: #fff; background: var(--teal); }
.sailing-row.is-past { min-height: 48px; }
.sailing-row.is-past .sailing-time, .sailing-row.is-past .sailing-vessel { color: var(--faint); }
.sailing-row.is-past .sailing-state { color: var(--faint); background: var(--soft2); }
.sailing-row.is-past .sailing-state.is-ontime { color: var(--strong); background: var(--soft3); }
.sailing-row.is-past .sailing-state.is-early { color: #1d5a78; background: #dcebf4; }
.sailing-row.is-past .sailing-state.is-late { color: #8a3a10; background: #f7e0cc; }
.sailing-row.is-cancelled { color: #18223b; padding-left: 8px; border-left: 4px solid #c0392b; background: #fdeeec; }
.sailing-row.is-cancelled .sailing-time { color: #b3261e; text-decoration: line-through; }
.sailing-row.is-cancelled .sailing-vessel { color: #b3261e; font-weight: 700; }
.sailing-row.is-typical .sailing-state { color: var(--muted); background: var(--soft2); }
.sailing-loading, .sailing-error { margin: 24px 0; color: var(--muted); font-size: 20px; }
.sailing-error { color: #ad5748; }
.sailing-alert { margin: 10px 0 4px; padding: 10px 14px; border-left: 5px solid #e0a800; border-radius: 4px; color: #5c4400; background: #fff3cd; font-size: 18px; font-weight: 700; }
.sailing-alert.is-cancelled { border-left-color: #b3261e; color: #8c1d18; background: #fdeeec; }
.earlier-toggle { width: 100%; min-height: 52px; margin: 4px 0; border: 0; border-bottom: 1px dashed var(--rule); color: var(--link); background: transparent; font-size: 19px; font-weight: 700; text-align: left; }
.earlier-sailings[hidden] { display: none; }
.later-sailings { margin-top: 6px; }
.later-note { margin: 2px 0 8px; color: var(--muted); font-size: 16px; line-height: 1.35; }


/* Weather */
.view-weather { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 22px; }
.weather-now { padding: 24px 30px; display: flex; flex-direction: column; gap: 8px; color: #fff; background: linear-gradient(135deg, #1d6f8a, #2e86a0); }
.weather-now .eyebrow { color: rgba(255,255,255,.8); }
.weather-hero { display: flex; align-items: center; gap: 22px; }
.weather-hero-icon { font-size: 92px; line-height: 1; }
.weather-hero-temp strong { font-family: var(--display); font-size: 128px; font-weight: 500; line-height: 1; }
.weather-hero-temp sup { font-size: 56px; }
.weather-condition { margin: 0; font-family: var(--display); font-size: 38px; }
.weather-wind { margin: 0; font-size: 22px; opacity: .9; }
.weather-range { display: flex; gap: 34px; margin-top: 6px; font-size: 22px; }
.weather-range strong { font-size: 24px; }
.weather-metrics { margin-top: auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.metric { padding: 12px 14px; display: grid; gap: 2px; border-radius: 12px; background: rgba(255,255,255,.15); }
.metric-label, .sunlight-row span { font-size: 16px; opacity: .85; }
.metric strong { font-size: 22px; }
.sunlight-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sunlight-row div { padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; border-radius: 12px; background: rgba(255,255,255,.15); }
.sunlight-row strong { font-size: 22px; }
.forecast-section { padding: 22px 26px; display: flex; flex-direction: column; }
.forecast-heading { display: flex; justify-content: space-between; align-items: baseline; }
.forecast-heading h2 { margin: 0; font-family: var(--display); font-size: 30px; font-weight: 500; }
.forecast-heading span { color: var(--muted); font-size: 15px; font-weight: 700; letter-spacing: 1px; }
.forecast-list { flex: 1; margin-top: 8px; display: grid; grid-auto-rows: 1fr; }
.forecast-day { display: grid; grid-template-columns: 110px 40px minmax(0, 1fr) 56px 90px; gap: 10px; align-items: center; border-top: 1px solid var(--line); font-size: 20px; }
.forecast-name { font-weight: 700; }
.forecast-icon { font-size: 30px; text-align: center; }
.forecast-condition { color: var(--muted); font-size: 18px; }
.forecast-rain { color: #2b6f8a; font-size: 18px; text-align: right; }
.forecast-temps { display: flex; justify-content: flex-end; gap: 10px; }
.forecast-temps span { color: var(--muted); }
.forecast-loading { margin: 18px 0; color: var(--muted); font-size: 20px; }

/* Restaurants */
.view-restaurants { padding: 18px 22px 14px; display: flex; flex-direction: column; gap: 12px; }
.restaurant-toolbar { flex: none; display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.restaurant-range { display: inline-flex; padding: 4px; gap: 4px; border-radius: 14px; background: var(--soft2); }
.restaurant-range button { min-height: 52px; padding: 0 24px; border: 0; border-radius: 11px; color: var(--link); background: transparent; font-size: 20px; font-weight: 700; }
.restaurant-range button[aria-pressed="true"] { color: #fff; background: var(--teal); }
.restaurant-summary-line { color: var(--muted); font-size: 19px; }
.restaurant-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; display: grid; grid-template-columns: 1fr 1fr; column-gap: 28px; align-content: start; }
.restaurant-list .forecast-loading { grid-column: 1 / -1; }
.restaurant-row { min-height: 78px; padding: 8px 0; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); }
.restaurant-copy { min-width: 0; display: grid; gap: 2px; }
.restaurant-copy strong { overflow: hidden; font-size: 21px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.restaurant-copy span { color: var(--muted); font-size: 17px; }
.restaurant-state { flex: none; display: grid; justify-items: end; gap: 3px; text-align: right; }
.restaurant-state b { padding: 3px 10px; border-radius: 5px; color: #fff; background: #2f457a; font-size: 15px; letter-spacing: .7px; }
.restaurant-state small { color: var(--muted); font-size: 16px; }
.restaurant-row.is-soon .restaurant-state b { background: #c98a00; }
.restaurant-row.is-soon .restaurant-state small { color: #8a5d00; font-weight: 700; }
.restaurant-row.is-closed .restaurant-state b { color: #6b4640; background: #f1dcd6; }
.restaurant-row.is-unknown .restaurant-state b { color: var(--muted); background: var(--soft2); }
.restaurant-row.is-closed .restaurant-copy strong, .restaurant-row.is-unknown .restaurant-copy strong { color: var(--muted); }
.restaurant-disclaimer { flex: none; margin: 0; color: var(--muted); font-size: 14px; }

/* Dialogs: settings */
.settings-dialog { width: min(1120px, calc(100vw - 40px)); max-height: calc(100vh - 40px); padding: 22px 28px 14px; border: 0; border-radius: 20px; color: var(--ink); background: var(--card); box-shadow: 0 24px 70px rgba(0,0,0,.45); }
.settings-dialog::backdrop { background: rgba(10, 14, 25, .62); }
.settings-dialog[open] { display: flex; flex-direction: column; }
.settings-dialog h2 { margin: 0 0 12px; font-family: var(--display); font-size: 32px; font-weight: 500; }
.dialog-close-form { position: absolute; top: 12px; right: 14px; margin: 0; }
.dialog-close { width: 52px; height: 52px; border: 0; border-radius: 50%; color: var(--muted); background: transparent; font-size: 36px; line-height: 1; }
.settings-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 230px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; gap: 0 24px; }
.settings-tabs { display: flex; flex-direction: column; gap: 8px; }
.settings-tabs button { min-height: 60px; padding: 0 18px; border: 0; border-radius: 12px; color: var(--link); background: var(--soft2); font-size: 21px; font-weight: 700; text-align: left; }
.settings-tabs button[aria-selected="true"] { color: #fff; background: var(--teal); }
.settings-panes { min-height: 0; max-height: calc(100vh - 250px); overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; padding-right: 6px; }
.settings-field { display: block; margin-bottom: 16px; font-size: 20px; font-weight: 700; }
.settings-field select, .settings-field input[type="text"], .settings-field input[type="number"] { display: block; width: 100%; min-height: 56px; margin-top: 6px; padding: 8px 14px; border: 1px solid var(--rule); border-radius: 10px; color: var(--ink); background: var(--surface); font-size: 21px; font-weight: 400; user-select: text; }
.settings-field input[type="range"] { display: block; width: 100%; height: 44px; margin-top: 6px; accent-color: var(--teal); }
.settings-field small { display: block; margin-top: 4px; color: var(--muted); font-size: 16px; font-weight: 400; }
.settings-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.settings-check { display: flex; align-items: center; gap: 12px; min-height: 52px; margin-bottom: 12px; font-size: 20px; font-weight: 700; }
.settings-check input { width: 28px; height: 28px; accent-color: var(--teal); }
.settings-footer { grid-column: 1 / -1; padding-top: 10px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.settings-credit { margin: 8px 0 0; color: var(--muted); font-size: 14px; text-align: center; }
.photo-dialog-body { display: flex; gap: 22px; align-items: center; }
.photo-qr { flex: none; width: 168px; height: 168px; border: 1px solid #dcdfe5; border-radius: 8px; background: #fff; }
.photo-qr svg { display: block; width: 100%; height: 100%; }
.photo-dialog-text p { margin: 0 0 8px; font-size: 19px; }
.photo-urls { margin: 0 0 10px; padding: 0; list-style: none; }
.photo-urls li { margin-bottom: 4px; font-size: 22px; font-weight: 700; word-break: break-all; user-select: text; }
.photo-note { margin: 0; color: var(--muted); font-size: 17px !important; }
#pane-photos h3 { margin: 16px 0 8px; color: var(--muted); font-size: 18px; }
.photo-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.photo-strip img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; background: var(--soft2); }

/* Photo-frame screensaver */
.screensaver { position: fixed; inset: 0; z-index: 1000; overflow: hidden; background: #000; cursor: none; touch-action: manipulation; }
.screensaver-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 2.5s ease; transform-origin: var(--focus-x, 50%) var(--focus-y, 50%); }
.screensaver-photo.is-visible, .screensaver-photo.is-leaving { animation: screensaver-drift var(--drift-duration, 40s) ease-in-out forwards; will-change: transform, opacity; }
.screensaver-photo.is-visible { opacity: 1; }
.screensaver-clock { position: absolute; padding: 10px 14px; color: rgba(255,255,255,.82); font-size: 32px; font-weight: 500; font-variant-numeric: tabular-nums; text-shadow: 0 1px 8px rgba(0,0,0,.8); transition: opacity 1.2s ease; }
.screensaver-clock small { display: block; font-size: 19px; font-weight: 400; opacity: .8; }
.screensaver-hint { position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%); padding: 10px 20px; border-radius: 999px; color: rgba(255,255,255,.92); background: rgba(0,0,0,.55); font-size: 22px; text-align: center; transition: opacity 1s ease; }
@keyframes screensaver-drift { from { transform: scale(1); } to { transform: scale(1.08); } }
@media (prefers-reduced-motion: reduce) { .screensaver-photo.is-visible, .screensaver-photo.is-leaving { animation: none; } .view { animation: none; } }

/* Water & waste */
.transfer-status { color: #18223b; display: flex; flex-direction: column; gap: 4px; padding: 14px 18px; border-radius: 14px; background: #fdecea; border-left: 8px solid #b3342e; }
.transfer-status.is-open { background: #e6f4ea; border-left-color: #2f6b46; }
.transfer-status.is-unknown { background: #fff4de; border-left-color: #b57a14; }
.transfer-status strong { font-family: var(--display); font-size: 28px; font-weight: 500; }
.transfer-status span { font-size: 15px; color: #5d6477; }
.site-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; min-height: 0; }
.transfer-week { display: grid; gap: 5px; }
.transfer-day { display: grid; grid-template-columns: 110px 1fr; column-gap: 12px; align-items: baseline; padding: 6px 14px; border-radius: 10px; background: var(--soft); font-size: 17px; }
.transfer-day em:empty { display: none; }
.transfer-day.is-closed { color: var(--muted); }
.transfer-day em { grid-column: 2; font-size: 15px; color: var(--muted); font-style: normal; }

/* Webcams */
.view-webcams { display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 12px; }
.cam-stage { position: relative; min-height: 0; overflow: hidden; border-radius: 18px; background: #0b0e14; box-shadow: 0 3px 14px rgba(20, 30, 60, .2); }
.cam-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; transition: opacity .7s ease; }
.cam-img.is-front { opacity: 1; }
.cam-label { position: absolute; left: 0; right: 0; top: 0; display: flex; flex-direction: column; padding: 14px 22px 26px; color: #fff; background: linear-gradient(rgba(0,0,0,.7), transparent); text-shadow: 0 1px 6px rgba(0,0,0,.8); }
.cam-label strong { font-family: var(--display); font-size: 36px; font-weight: 500; }
.cam-label span { font-size: 19px; opacity: .9; }
.cam-time { position: absolute; right: 16px; bottom: 14px; padding: 8px 16px; border-radius: 999px; color: #fff; background: rgba(0,0,0,.62); font-size: 20px; font-weight: 600; }
.cam-time.is-stale { background: #b57a14; }
.cam-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 72px; height: 110px; border: 0; border-radius: 16px; color: #fff; background: rgba(0,0,0,.38); font-size: 64px; line-height: 1; }
.cam-prev { left: 12px; }
.cam-next { right: 12px; }
.cam-nav:active { background: rgba(0,0,0,.6); }
.cam-bottom { display: flex; align-items: center; gap: 14px; }
.cam-strip {
  display: flex; gap: 10px; flex: 1;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  touch-action: pan-x;
  -webkit-overflow-scrolling: touch;
}
.cam-chip {
  flex: none; padding: 12px 20px;
  border: 2px solid transparent; border-radius: 14px;
  background: var(--card); color: var(--ink);
  font-size: 20px; font-weight: 600;
  box-shadow: 0 2px 8px rgba(20, 30, 60, .12);
  touch-action: pan-x;
  user-select: none;
}
.cam-chip.is-active { background: var(--teal); color: #fff; }
.cam-chip.is-stale { border-color: #b57a14; }
.cam-credit { max-width: 260px; font-size: 13px; color: var(--muted); line-height: 1.2; }

/* Smaller windows (desktop testing, phones) */
@media (max-width: 1000px) {
  .view-home { grid-template-columns: 1fr; grid-template-rows: none; overflow-y: auto; }
  .tile { min-height: 150px; }
  .view-ferry, .view-weather, .view-tides, .view-detail { grid-template-columns: 1fr; overflow-y: auto; }
  .tile-ferry, .tile-events { grid-column: auto; }
  .site-pair { grid-template-columns: 1fr; }
  .restaurant-list { grid-template-columns: 1fr; }
  .settings-layout { grid-template-columns: 1fr; }
  .settings-tabs { flex-direction: row; }
}

.cam-refresh { position: absolute; top: 14px; right: 14px; z-index: 3; min-height: 56px; padding: 0 22px; border: 0; border-radius: 14px; color: #fff; background: rgba(0,0,0,.5); font-size: 24px; font-weight: 600; }
.cam-refresh:active { background: rgba(0,0,0,.75); }
.cam-stage.is-loading .cam-refresh { opacity: .6; }
.cam-time { cursor: pointer; }
.view-detail .detail-list, .restaurant-list, .settings-panes, .cam-strip { -webkit-overflow-scrolling: touch; }
html[data-theme="seaglass"] {
  --ink: #12332f;
  --muted: #55706b;
  --line: #cfe3de;
  --paper: #eaf4f1;
  --card: #fbfffd;
  --teal: #1d6b66;
  --teal-bright: #3f9a92;
  --surface: #ffffff;
  --soft: #e3f0ec;
  --soft2: #d9e9e4;
  --soft3: #cde3dc;
  --rule: #aac8c0;
  --strong: #0f4a46;
  --faint: #7f9a95;
  --dot: #bcd8d1;
  --t-ferry: #1d6b66;
  --t-weather: #3a9a94;
  --t-restaurants: #d9826a;
  --t-tides: #2c8aa0;
  --t-roads: #5b7f86;
  --t-power: #7a6aa8;
  --t-air: #4c9a6a;
  --t-water: #2d8bb0;
  --t-webcams: #4f7f94;
  --t-screenoff: #25302f;
}
html[data-theme="sunset"] {
  --ink: #3a1f1a;
  --muted: #7a5d54;
  --line: #ecd5c7;
  --paper: #fbefe6;
  --card: #fffaf5;
  --teal: #8f3b3a;
  --teal-bright: #c4584a;
  --surface: #fffdfa;
  --soft: #f6e4d8;
  --soft2: #f0d9ca;
  --soft3: #ead0be;
  --rule: #d7b9a8;
  --strong: #6b2a2a;
  --faint: #a58a7e;
  --dot: #e8cdbb;
  --t-ferry: #b4493f;
  --t-weather: #d9772f;
  --t-restaurants: #c2566b;
  --t-tides: #8a4a8f;
  --t-roads: #7a5a56;
  --t-power: #6f4a96;
  --t-air: #b8862a;
  --t-water: #cc6a3a;
  --t-webcams: #8c5a6a;
  --t-screenoff: #2f2426;
}
html[data-theme="driftwood"] {
  --ink: #2b2822;
  --muted: #6c655a;
  --line: #ddd5c6;
  --paper: #f1ece3;
  --card: #fffdf8;
  --teal: #55604d;
  --teal-bright: #7d8c70;
  --surface: #fffefb;
  --soft: #ece6da;
  --soft2: #e4dccd;
  --soft3: #dbd1bf;
  --rule: #c8bda8;
  --strong: #3b4435;
  --faint: #9a9282;
  --dot: #d4cab7;
  --t-ferry: #55604d;
  --t-weather: #6f8a8c;
  --t-restaurants: #a8704c;
  --t-tides: #4f7a7a;
  --t-roads: #7b7468;
  --t-power: #8a6f86;
  --t-air: #6f8f55;
  --t-water: #5d86a0;
  --t-webcams: #75806c;
  --t-screenoff: #2c2a26;
}
html[data-theme="reef"] {
  --ink: #123547;
  --muted: #4f7384;
  --line: #cde7ea;
  --paper: #eaf8f8;
  --card: #ffffff;
  --teal: #0b7d8c;
  --teal-bright: #20b2b8;
  --surface: #ffffff;
  --soft: #e1f2f3;
  --soft2: #d6ecee;
  --soft3: #c8e5e8;
  --rule: #a8d3d8;
  --strong: #0a5663;
  --faint: #7aa0aa;
  --dot: #b8dde0;
  --t-ferry: #0b7d8c;
  --t-weather: #ef7d5c;
  --t-restaurants: #d94f6e;
  --t-tides: #16929f;
  --t-roads: #5f7f93;
  --t-power: #8a5fc0;
  --t-air: #35a36a;
  --t-water: #1c8fd0;
  --t-webcams: #d9902a;
  --t-screenoff: #1f2a33;
}
html[data-theme="midnight"] {
  color-scheme: dark;
  --ink: #e6edf8;
  --muted: #9fb0c9;
  --line: #243652;
  --paper: #0b1424;
  --card: #14233b;
  --teal: #1c4a86;
  --teal-bright: #5b8fd6;
  --link: #8db6f2;
  --surface: #1b2d49;
  --soft: #1a2b45;
  --soft2: #223654;
  --soft3: #2b4166;
  --rule: #3a5278;
  --strong: #bcd2f5;
  --faint: #7186a8;
  --dot: #1b2b44;
  --t-ferry: #1f4f9e;
  --t-weather: #1f7a96;
  --t-restaurants: #b3573a;
  --t-tides: #14606f;
  --t-roads: #4a5d78;
  --t-power: #6a4ba3;
  --t-air: #2f7a4d;
  --t-water: #2a6fa3;
  --t-webcams: #3f5a82;
  --t-screenoff: #11151d;
}
html[data-theme="kelp"] {
  color-scheme: dark;
  --ink: #e4f2ec;
  --muted: #98b5ab;
  --line: #21403a;
  --paper: #0c1a17;
  --card: #132723;
  --teal: #1d5a4c;
  --teal-bright: #4db89a;
  --link: #6fd1b3;
  --surface: #193029;
  --soft: #183029;
  --soft2: #20403a;
  --soft3: #295049;
  --rule: #35584f;
  --strong: #b8ebd9;
  --faint: #74988c;
  --dot: #17302a;
  --t-ferry: #1d6b5a;
  --t-weather: #2a8a8f;
  --t-restaurants: #b0603c;
  --t-tides: #17606a;
  --t-roads: #4b6360;
  --t-power: #6a5a9a;
  --t-air: #3a8a4e;
  --t-water: #2a7a9a;
  --t-webcams: #46685f;
  --t-screenoff: #0e1514;
}

/* Font pairs */
html[data-font="modern"] { --display: "Outfit", "Avenir Next", system-ui, sans-serif; --sans: "Inter", system-ui, sans-serif; }
html[data-font="nautical"] { --display: "Playfair Display", Georgia, serif; --sans: "Lato", system-ui, sans-serif; }
html[data-font="friendly"] { --display: "Baloo 2", "Nunito", system-ui, sans-serif; --sans: "Nunito", system-ui, sans-serif; }
html[data-font="rugged"] { --display: "Oswald", "Arial Narrow", sans-serif; --sans: "Source Sans 3", system-ui, sans-serif; }
html[data-font="tech"] { --display: "Space Grotesk", system-ui, sans-serif; --sans: "IBM Plex Sans", system-ui, sans-serif; }
html[data-font="system"] { --display: system-ui, "Helvetica Neue", Arial, sans-serif; --sans: system-ui, "Helvetica Neue", Arial, sans-serif; }

/* Settings: theme and font choosers */
.settings-heading { margin: 4px 0 10px; font-size: 22px; font-family: var(--display); font-weight: 500; }
.choice-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.choice { min-height: 78px; padding: 10px 14px; display: flex; flex-direction: column; justify-content: center; gap: 8px; border: 3px solid var(--rule); border-radius: 14px; color: var(--ink); background: var(--surface); text-align: left; font-size: 20px; font-weight: 700; }
.choice[aria-checked="true"] { border-color: var(--link); box-shadow: 0 0 0 2px var(--link); }
.choice small { color: var(--muted); font-size: 15px; font-weight: 400; }
.swatch { display: flex; height: 22px; border-radius: 6px; overflow: hidden; }
.swatch i { flex: 1; }
.font-sample { font-size: 26px; line-height: 1.1; }
.autosave-note { color: var(--muted); font-size: 16px; }

/* Wi-Fi setup */
.wifi-current { margin: 0 0 12px; font-size: 22px; font-weight: 700; }
.wifi-list { display: grid; gap: 8px; margin-bottom: 14px; }
.wifi-net { min-height: 60px; padding: 0 18px; display: flex; justify-content: space-between; align-items: center; border: 2px solid var(--rule); border-radius: 12px; color: var(--ink); background: var(--surface); font-size: 22px; font-weight: 600; text-align: left; }
.wifi-net small { color: var(--muted); font-size: 17px; font-weight: 400; }
.wifi-net.is-current { border-color: var(--link); }
.wifi-net:active { background: var(--soft3); }
.wifi-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0; }
.wifi-actions .action-button.is-danger { color: #b3261e; }
.wifi-status { min-height: 1.4em; margin: 8px 0 0; font-size: 19px; }
.wifi-pass-row { display: flex; gap: 10px; margin-bottom: 10px; }
.wifi-input { width: 100%; min-height: 58px; margin-bottom: 10px; padding: 8px 14px; border: 2px solid var(--rule); border-radius: 10px; color: var(--ink); background: var(--surface); font-size: 24px; user-select: text; }
.wifi-pass-row .wifi-input { margin: 0; }
.osk { display: grid; gap: 6px; padding: 8px; border-radius: 14px; background: var(--soft2); }
.osk-row { display: flex; gap: 6px; justify-content: center; }
.osk-key { flex: 1 1 0; min-width: 0; min-height: 52px; border: 0; border-radius: 9px; color: var(--ink); background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.25); font-size: 24px; font-weight: 600; }
.osk-key:active { background: var(--soft3); }
.osk-key.is-wide { flex: 1.6 1 0; font-size: 19px; color: var(--link); }
.osk-key.is-space { flex: 5 1 0; }
.osk-key.is-on { color: #fff; background: var(--teal); }

.wifi-setup { position: fixed; inset: 0; z-index: 1500; padding: 32px 48px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; color: var(--ink); background: var(--paper); text-align: center; }
.wifi-setup h2 { margin: 0; font-family: var(--display); font-size: 44px; font-weight: 500; }
.wifi-setup-steps { display: flex; gap: 56px; align-items: flex-start; justify-content: center; }
.wifi-step { display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: 360px; }
.wifi-step b { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--teal); font-size: 26px; }
.wifi-step-qr { width: 230px; height: 230px; padding: 6px; border-radius: 12px; background: #fff; }
.wifi-step-qr svg { display: block; width: 100%; height: 100%; }
.wifi-step p { margin: 0; font-size: 22px; line-height: 1.35; }
.wifi-step small { color: var(--muted); font-size: 19px; }
.wifi-setup-status { min-height: 1.4em; margin: 0; font-size: 24px; font-weight: 700; }

/* Rearranging tiles (touch, hold, drag) */
.view-home { grid-auto-flow: row dense; }
body.is-arranging .tile { animation: tile-jiggle .28s ease-in-out infinite alternate; touch-action: none; }
body.is-arranging .tile:nth-child(even) { animation-delay: -.14s; animation-direction: alternate-reverse; }
body.is-arranging .tile.is-dragging { animation: none; opacity: .25; }
.tile-ghost { position: fixed; z-index: 900; margin: 0; pointer-events: none; opacity: .94; box-shadow: 0 18px 40px rgba(0, 0, 0, .45); transform: scale(1.04); transition: none; animation: none; }
@keyframes tile-jiggle { from { transform: rotate(-.7deg); } to { transform: rotate(.7deg); } }
.arrange-bar { position: fixed; left: 50%; bottom: 14px; z-index: 950; display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 22px; border-radius: 999px; color: var(--ink); background: var(--surface); box-shadow: 0 8px 28px rgba(0, 0, 0, .4); transform: translateX(-50%); font-size: 20px; font-weight: 600; }
.arrange-bar button { min-height: 48px; padding: 0 22px; border: 0; border-radius: 999px; color: var(--link); background: var(--soft2); font-size: 20px; font-weight: 700; }
.arrange-bar button.is-primary { color: #fff; background: var(--teal); }
@media (prefers-reduced-motion: reduce) { body.is-arranging .tile { animation: none; outline: 2px dashed var(--link); } }

/* Games tile: Screen off and Games share one cell */
.tile-pair { display: grid; grid-template-rows: 1fr 1fr; gap: 10px; min-height: 0; }
.tile-half { min-height: 0; padding: 6px 18px; gap: 0; align-items: center; }
.tile-half .tile-copy { gap: 0; }
.tile-half .tile-name { font-size: 14px; }
.tile-half .tile-main { font-size: 27px; line-height: 1.05; }
.tile-games { background-color: var(--t-games, #6b4f9a); }

/* Games */
.view-games { display: grid; place-items: center; padding: 0 4px 4px; }
.games-menu { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 1fr); gap: 18px; width: 100%; height: 100%; }
.game-card { display: grid; place-content: center; justify-items: center; gap: 8px; border: 0; border-radius: 22px; color: #fff; background: var(--t-ferry); box-shadow: 0 4px 14px rgba(20, 30, 60, .25); font-size: 20px; }
.game-card:nth-child(2) { background: var(--t-weather); }
.game-card:nth-child(3) { background: var(--t-air); }
.game-card:nth-child(4) { background: var(--t-restaurants); }
.game-card:nth-child(5) { background: var(--t-power); }
.game-card:nth-child(6) { background: var(--t-tides); }
.game-card:active { transform: scale(.975); }
.game-card strong { font-family: var(--display); font-size: 34px; font-weight: 500; }
.game-card em { min-height: 1.2em; font-size: 18px; font-style: normal; opacity: .85; }
.game-emoji { font-size: 84px; line-height: 1; display: flex; justify-content: center; color: var(--link); }
.game-emoji svg { width: 84px; height: 84px; }
.game-emoji b { font-family: var(--font-display, inherit); font-size: 76px; }
.game-svg { display: inline-flex; }
.game-svg svg { width: 56px; height: 56px; }
.game-play { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 10px; width: 100%; height: 100%; }
.game-bar { display: flex; align-items: center; gap: 16px; }
.game-title { font-family: var(--display); font-size: 30px; font-weight: 500; }
.game-score { margin-left: auto; font-size: 24px; font-weight: 700; }
.game-stage { display: grid; place-items: center; min-height: 0; touch-action: none; user-select: none; }
.board-2048 { position: relative; display: grid; grid-template: repeat(4, 1fr) / repeat(4, 1fr); gap: 10px; padding: 10px; width: min(100%, 520px); aspect-ratio: 1; border-radius: 16px; background: var(--soft3); touch-action: none; }
.board-2048 .cell { display: grid; place-items: center; border-radius: 10px; color: #fff; background: var(--soft2); font-family: var(--display); font-size: 44px; font-weight: 700; transition: background .12s; }
.board-2048 .cell.pop { animation: cell-pop .16s ease-out; }
.board-2048 .cell[data-v="2"] { background: #6aa6c8; } .board-2048 .cell[data-v="4"] { background: #4f8fc0; }
.board-2048 .cell[data-v="8"] { background: #3f9a8a; } .board-2048 .cell[data-v="16"] { background: #3c8f5c; }
.board-2048 .cell[data-v="32"] { background: #c99a2c; } .board-2048 .cell[data-v="64"] { background: #d27a2a; }
.board-2048 .cell[data-v="128"] { background: #d8573f; font-size: 38px; } .board-2048 .cell[data-v="256"] { background: #b8416b; font-size: 38px; }
.board-2048 .cell[data-v="512"] { background: #8c4cb0; font-size: 38px; } .board-2048 .cell[data-v="1024"] { background: #5b4fc4; font-size: 32px; }
.board-2048 .cell[data-v="2048"] { background: #e2b72a; font-size: 32px; }
.board-2048 .cell.big { background: #222a44; font-size: 30px; }
@keyframes cell-pop { from { transform: scale(.7); } to { transform: scale(1); } }
.game-over { white-space: pre-line; position: absolute; inset: 0; z-index: 3; display: grid; place-content: center; justify-items: center; gap: 14px; border-radius: inherit; color: #fff; background: rgba(10, 16, 32, .82); font-family: var(--display); font-size: 40px; text-align: center; }
.game-over .action-button { font-family: var(--sans); }
.memory-board { position: relative; display: grid; grid-template: repeat(4, 1fr) / repeat(4, 1fr); gap: 12px; height: 100%; aspect-ratio: 1; max-width: 100%; }
.memory-card { border: 0; border-radius: 14px; color: #fff; background: var(--t-ferry); font-size: 64px; line-height: 1; box-shadow: 0 3px 8px rgba(0, 0, 0, .3); }
.memory-card .face { display: none; }
.memory-card.is-up, .memory-card.is-done { background: var(--surface); }
.memory-card.is-up .face, .memory-card.is-done .face { display: block; }
.memory-card .back { font-size: 44px; opacity: .5; }
.memory-card.is-up .back, .memory-card.is-done .back { display: none; }
.memory-card.is-done { opacity: .55; }
.snake-wrap { position: relative; height: 100%; max-width: 100%; aspect-ratio: 24 / 13; }
.snake-wrap canvas { width: 100%; height: 100%; border-radius: 14px; touch-action: none; }

.game-score { margin-left: auto; }
.game-bar #game-help { margin-left: 0; }
.how-to { background: rgba(10, 16, 32, .95); gap: 18px; padding: 24px 40px; font-size: 30px; z-index: 5; }
.how-to strong { font-weight: 500; }
.how-to-text { font-family: var(--sans); font-size: 24px; line-height: 1.4; max-width: 640px; }
.gull-board { position: relative; display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); gap: 14px; height: 100%; aspect-ratio: 1; max-width: 100%; }
.gull-hole { border: 0; border-radius: 50%; background: radial-gradient(circle at 50% 60%, rgba(0, 0, 0, .35), rgba(0, 0, 0, .12)); display: grid; place-items: center; color: #fff; overflow: hidden; }
.gull-hole .game-svg { transform: translateY(120%); transition: transform .12s ease-out; }
.gull-hole .game-svg svg { width: 96px; height: 96px; }
.gull-hole.is-up .game-svg { transform: none; }

/* Clock mode: full-screen nightstand clock, opened by tapping the time at the top left */
.clock-mode {
  --ck-fg: #fff;
  --ck-dim: rgba(255, 255, 255, .5);
  --ck-accent: #ff9f0a;
  --ck-card: #1b1b1e;
  --ck-card-hi: #26262a;
  --clock-font: "Oswald", "Barlow Condensed", "Arial Narrow", sans-serif;
  position: fixed; inset: 0; z-index: 1800;
  overflow: hidden; color: var(--ck-fg); background: #000;
  touch-action: none; user-select: none;
}
.clock-mode.is-red {
  --ck-fg: #e5382d;
  --ck-dim: rgba(229, 56, 45, .5);
  --ck-accent: #e5382d;
  --ck-card: #190605;
  --ck-card-hi: #220907;
}
.clock-mode.is-idle { cursor: none; }
.clock-stage { position: absolute; inset: 0; }
.clock-face { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; }
.clock-face.is-active { display: flex; animation: clock-in 300ms ease-out backwards; }
@keyframes clock-in { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }

.clock-chrome {
  position: absolute; left: 0; right: 0; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px 40px;
  background: linear-gradient(rgba(0, 0, 0, .85), transparent);
  transition: opacity 400ms ease;
}
.clock-mode.is-idle .clock-chrome { opacity: 0; pointer-events: none; }
.clock-btn, .clock-picker {
  border: 1px solid var(--ck-dim); border-radius: 999px;
  color: var(--ck-fg); background: rgba(255, 255, 255, .08);
}
.clock-btn { min-height: 52px; padding: 0 22px 0 16px; display: inline-flex; align-items: center; gap: 8px; font-size: 21px; font-weight: 600; }
.clock-btn:active { background: rgba(255, 255, 255, .2); }
.clock-btn[aria-pressed="true"] { color: #000; background: var(--ck-fg); }
.clock-picker { display: inline-flex; padding: 4px; gap: 4px; }
.clock-picker button { min-height: 44px; padding: 0 22px; border: 0; border-radius: 999px; color: var(--ck-dim); background: transparent; font-size: 20px; font-weight: 600; }
.clock-picker button[aria-checked="true"] { color: #000; background: var(--ck-fg); }

/* Digital: edge-to-edge condensed numerals */
.face-digital { flex-direction: column; gap: 3vh; }
.dg-time {
  display: flex; align-items: center; justify-content: center;
  font: 700 min(42vw, 84vh)/.9 var(--clock-font);
  font-variant-numeric: tabular-nums; letter-spacing: -.01em; white-space: nowrap;
}
.dg-colon { margin: 0 .02em; padding-bottom: .06em; color: var(--ck-accent); }
.dg-meta, .fc-meta {
  display: flex; align-items: baseline; justify-content: center; gap: 2.4vw;
  font: 500 max(3.6vh, 22px)/1 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--ck-dim);
}
.dg-meta b, .fc-meta b { color: var(--ck-fg); font-weight: 700; }

/* Analog: the dial takes the full height, date and weather flank it */
.face-analog { gap: 2.5vw; }
.an-dial { flex: none; height: min(97vh, 64vw); aspect-ratio: 1; }
.an-side { width: 17vw; display: flex; flex-direction: column; gap: 1vh; }
.an-side-left { align-items: flex-end; text-align: right; }
.an-side-right { align-items: flex-start; text-align: left; }
.an-big { font: 700 min(15vh, 10vw)/1 var(--clock-font); font-variant-numeric: tabular-nums; text-transform: uppercase; }
.an-small { font: 500 max(3.4vh, 20px)/1.2 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--ck-dim); }
.an-tick { stroke: var(--ck-dim); stroke-width: 2; stroke-linecap: round; }
.an-tick.is-hour { stroke: var(--ck-fg); stroke-width: 4; }
.an-num { fill: var(--ck-fg); font: 600 36px var(--sans); text-anchor: middle; dominant-baseline: central; }
.an-hand rect { fill: var(--ck-fg); stroke: #000; stroke-width: 3; paint-order: stroke; }
.an-sec rect, .an-sec circle { fill: var(--ck-accent); stroke: none; }
.an-cap { fill: var(--ck-accent); }
@media (max-aspect-ratio: 4/3) { .an-side { display: none; } .an-dial { height: auto; width: 96vw; } }

/* Flip: two big cards that fold over on each change */
.face-flip { flex-direction: column; gap: 3vh; }
.fc-row { display: flex; gap: 2.4vw; }
.fc { --cw: min(43vw, 74vh); --ch: min(72vh, calc(var(--cw) * 1.12)); position: relative; width: var(--cw); height: var(--ch); perspective: 2200px; }
.fc::after { content: ""; position: absolute; left: 0; right: 0; top: calc(50% - .3vh); height: .6vh; background: #000; z-index: 6; }
.fc-half { position: absolute; left: 0; right: 0; height: 50%; overflow: hidden; background: var(--ck-card); backface-visibility: hidden; }
.fc-top, .fc-flap-top { top: 0; border-radius: 3.4vh 3.4vh 0 0; transform-origin: 50% 100%; background: linear-gradient(var(--ck-card-hi), var(--ck-card)); }
.fc-bottom, .fc-flap-bottom { bottom: 0; border-radius: 0 0 3.4vh 3.4vh; transform-origin: 50% 0; }
.fc-half span {
  position: absolute; left: 0; right: 0; height: var(--ch); padding-bottom: calc(var(--ch) * .08);
  display: flex; align-items: center; justify-content: center;
  color: var(--ck-fg); font: 700 calc(var(--ch) * .74)/1 var(--clock-font); font-variant-numeric: tabular-nums;
}
.fc-top span, .fc-flap-top span { top: 0; }
.fc-bottom span, .fc-flap-bottom span { bottom: 0; }
.fc-flap-top, .fc-flap-bottom { visibility: hidden; z-index: 4; }
.fc.is-flipping .fc-flap-top, .fc.is-flipping .fc-flap-bottom { visibility: visible; }
.fc.is-flipping .fc-flap-top { animation: fc-fold 280ms ease-in both; }
.fc.is-flipping .fc-flap-bottom { animation: fc-unfold 280ms 280ms ease-out both; }
@keyframes fc-fold { from { transform: rotateX(0); } to { transform: rotateX(-90deg); } }
@keyframes fc-unfold { from { transform: rotateX(90deg); } to { transform: rotateX(0); } }
@media (prefers-reduced-motion: reduce) { .fc.is-flipping .fc-flap-top, .fc.is-flipping .fc-flap-bottom { animation: none; visibility: hidden; } }

/* Community events */
.tile-events .tile-main { font-size: 30px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-events .tile-copy { min-width: 0; }
.view-events { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 22px; }
.events-summary { display: flex; flex-direction: column; gap: 12px; }
.events-summary h2 { margin: 0; font-family: var(--display); font-size: 34px; font-weight: 500; line-height: 1.12; }
.events-filter-bar { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 8px; }
.event-filter-btn { min-height: 48px; padding: 0 18px; border: 0; border-radius: 999px; color: var(--link); background: var(--soft2); font-size: 18px; font-weight: 700; }
.event-filter-btn.is-active { color: #fff; background: var(--teal); }
.events-summary-count { margin: 0; font-size: 20px; }
.events-summary-count strong { font-size: 28px; }
.events-summary .action-button { margin-top: auto; }
.events-list-pane { padding: 14px 18px; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; scrollbar-width: none; }
.events-list-pane::-webkit-scrollbar { display: none; }
.events-list { display: grid; gap: 10px; align-content: start; }
.event-card { display: grid; grid-template-columns: 78px minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 10px 16px; border-radius: 16px; background: var(--soft); text-align: left; cursor: pointer; }
.event-card:active { transform: scale(.985); }
.event-date-box { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 8px 0; border-radius: 12px; color: #fff; background: var(--teal); line-height: 1; }
.event-date-month { font-size: 13px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; }
.event-date-day { margin-top: 3px; font-size: 32px; font-weight: 700; font-variant-numeric: tabular-nums; }
.event-date-wday { margin-top: 2px; font-size: 12px; opacity: .85; }
.event-card-body { min-width: 0; display: grid; gap: 3px; }
.event-card-top { display: flex; gap: 8px; }
.event-card-top:empty { display: none; }
.event-badge-today, .event-badge-tomorrow { padding: 2px 10px; border-radius: 999px; color: #fff; font-size: 12px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; }
.event-badge-today { background: #3f8a58; }
.event-badge-tomorrow { background: #c8741f; }
.event-card-title { margin: 0; font-size: 21px; font-weight: 600; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-card-meta { display: flex; gap: 14px; font-size: 16px; color: var(--muted); }
.event-card-venue { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-card-right { display: flex; align-items: center; gap: 10px; }
.event-source-tag { padding: 4px 12px; border-radius: 999px; color: var(--muted); background: var(--soft2); font-size: 13px; font-weight: 600; }
.event-card-chevron { font-size: 24px; color: var(--muted); }
.event-modal { width: min(720px, calc(100vw - 40px)); max-height: calc(100vh - 60px); padding: 28px 32px 24px; border: 0; border-radius: 20px; color: var(--ink); background: var(--card); box-shadow: 0 24px 70px rgba(0,0,0,.45); }
.event-modal::backdrop { background: rgba(10, 14, 25, .62); }
.event-modal-header { display: grid; gap: 6px; }
.event-modal-tag { align-self: start; justify-self: start; padding: 4px 14px; border-radius: 999px; color: #fff; background: var(--teal); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.event-modal-header h2 { margin: 4px 44px 0 0; font-family: var(--display); font-size: 32px; font-weight: 500; line-height: 1.2; }
.event-modal-datetime { margin: 0; font-size: 20px; font-weight: 700; color: var(--link); }
.event-modal-venue { margin: 0; font-size: 17px; color: var(--muted); }
.event-modal-desc { margin: 16px 0 20px; max-height: 200px; overflow-y: auto; font-size: 18px; line-height: 1.5; }
.event-modal-action-row { display: flex; align-items: center; justify-content: flex-start; gap: 20px; padding-top: 14px; border-top: 1px solid var(--soft2); }
.event-modal-qr-box { display: flex; align-items: center; gap: 14px; }
.event-modal-qr { width: 140px; height: 140px; padding: 4px; border-radius: 12px; background: #fff; }
.event-modal-qr svg, .event-modal-qr img { display: block; width: 100%; height: 100%; }
.event-modal-qr-box small { max-width: 220px; font-size: 17px; line-height: 1.3; color: var(--muted); }
@media (max-width: 900px) { .view-events { grid-template-columns: 1fr; overflow-y: auto; } }
.tile-pair .tile-half .tile-sub { display: none; }

/* Avoid orphaned words: balance short blocks, tidy last lines of paragraphs */
h1, h2, h3, .tile-name, .tile-main, .tile-sub, .eyebrow, .event-modal-qr-box small, .event-modal-datetime, .event-modal-venue, .crossing-time, .leaveby-subtitle { text-wrap: balance; }
p, li, .detail-note, .event-modal-desc, .restaurant-disclaimer, .photo-dialog-text p, .wifi-step p, .wifi-step small { text-wrap: pretty; }

/* iOS-style scrolling: rubber-band edges, hidden scrollbars, no scroll chaining */
.is-rubber > * { transform: translate3d(var(--rb-x, 0px), var(--rb-y, 0px), 0); will-change: transform; }
.is-rubber-spring > * { transition: transform 480ms cubic-bezier(.22, 1, .36, 1); }
.detail-list, .ferry-schedule-pane, .restaurant-list, .settings-panes, .events-list-pane, .event-modal-desc, .cam-strip { scrollbar-width: none; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.detail-list::-webkit-scrollbar, .ferry-schedule-pane::-webkit-scrollbar, .restaurant-list::-webkit-scrollbar, .settings-panes::-webkit-scrollbar, .events-list-pane::-webkit-scrollbar, .event-modal-desc::-webkit-scrollbar, .cam-strip::-webkit-scrollbar { display: none; }

/* Phones: hide the kiosk-only features (games, Go dark, photo frame, exit) and make the clock a plain label. */
@media (max-width: 820px), (max-height: 480px) {
  .kiosk-only { display: none !important; }
  .clock-block { pointer-events: none; cursor: default; }
}

/* Phone layout (portrait phones and similar narrow windows) */
@media (max-width: 820px) {
  :root { --bar-h: calc(56px + env(safe-area-inset-top, 0px)); }
  body { font-size: 17px; }
  body:not([data-view="home"]) { --foot-h: 0px; }
  .app-footer { display: none; }
  .app-bar { padding: env(safe-area-inset-top, 0px) 14px 0; grid-template-columns: auto 1fr auto; gap: 8px; }
  .bar-left { gap: 8px; }
  .app-title { grid-column: 2; font-size: 21px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .clock { font-size: 20px; white-space: nowrap; }
  .today { display: none; }
  .clock-block { margin: 0; padding: 0; }
  .back-button { min-height: 44px; padding: 0 14px 0 8px; font-size: 17px; }
  .back-button svg { width: 22px; height: 22px; }
  .app-bar .settings-fab { width: 44px; height: 44px; }
  .settings-fab svg { width: 26px; height: 26px; }
  .views { padding: 6px 14px calc(14px + env(safe-area-inset-bottom, 0px)); }

  .view-home { grid-auto-rows: auto; gap: 10px; align-content: start; -webkit-overflow-scrolling: touch; }
  .tile { min-height: 108px; padding: 30px 16px 18px; gap: 14px; border-radius: 18px; }
  .tile-icon { width: 56px; height: 56px; border-radius: 16px; flex: none; }
  .tile-icon svg { width: 38px; height: 38px; }
  .tile-glyph { font-size: 34px; }
  .tile-name { font-size: 13px; }
  .tile-main { font-size: 30px; }
  .tile-small .tile-main { font-size: 26px; white-space: normal; }
  .tile-sub, .tile-small .tile-sub { font-size: 15px; }
  .tile-copy { min-width: 0; }
  .fresh-chip { top: 8px; right: 10px; font-size: 11px; padding: 1px 8px; }
  .tile-pair { grid-template-rows: none; grid-template-columns: 1fr 1fr; gap: 10px; }
  .tile-pair .tile-half { min-height: 84px; padding: 14px 14px; }
  .tile.is-unsure { padding-bottom: 36px; }
  .fresh-ribbon { font-size: 13px; padding: 3px 10px; }

  .view-ferry, .view-weather, .view-tides, .view-detail, .view-events { gap: 14px; }
  .view-webcams { grid-template-rows: minmax(0, 1fr) auto; }
  .view-ferry, .view-weather, .view-tides, .view-detail, .view-events, .view-webcams { grid-template-columns: minmax(0, 1fr); }
  .view-home { grid-template-columns: minmax(0, 1fr); }
  .view-ferry, .view-weather, .view-tides, .view-detail, .view-events { align-content: start; grid-auto-rows: max-content; }
  .ferry-summary { padding: 16px; gap: 8px; }
  .ferry-summary h2 { font-size: 24px; }
  .route-bar, .crossing-time, .leaveby-note, .leaveby-subtitle { display: none; }
  .ferry-schedule-pane, .events-list-pane, .detail-list { overflow: visible; }
  .ferry-schedule-pane { padding: 4px 14px 10px; }
  .sailing-row { grid-template-columns: 92px minmax(0, 1fr) auto; gap: 10px; }
  .sailing-time { font-size: 20px; }
  .sailing-vessel, .sailing-leaveby { font-size: 15px; }
  .sailing-capacity-detail { font-size: 14px; }
  .sailing-state { padding: 6px 8px; font-size: 13px; }
  .detail-card { padding: 16px 16px; }
  .detail-lead { font-size: 18px; }
  .tide-level strong { font-size: 60px; }
  .weather-now { padding: 18px; }
  .weather-hero { gap: 14px; }
  .weather-range { gap: 18px; font-size: 18px; }
  .weather-hero-temp strong { font-size: 84px; }
  .weather-hero-temp sup { font-size: 38px; }
  .weather-hero-icon { font-size: 64px; }
  .weather-condition { font-size: 28px; }
  .weather-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metric strong { font-size: 18px; }
  .events-summary h2 { font-size: 26px; }
  .event-card { grid-template-columns: 56px minmax(0, 1fr); gap: 12px; padding: 10px 12px; }
  .event-card > :nth-child(3) { grid-column: 2; }
  .event-card-title { font-size: 18px; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .event-card-meta { flex-direction: column; gap: 2px; font-size: 14px; }
  .event-card-venue { white-space: normal; }
  .event-date-day { font-size: 26px; }
  .events-list-pane { padding: 10px; }
  .events-summary { padding: 16px; }
  .events-summary h2, .events-summary .eyebrow + p { font-size: 24px; }
  .event-filter-btn { min-height: 40px; padding: 0 14px; font-size: 15px; }
  .events-summary .detail-note { display: none; }
  .settings-dialog, .event-modal { width: calc(100vw - 20px); max-height: calc(100dvh - 20px); padding: 18px 16px 12px; }
  .event-modal-header h2 { font-size: 24px; }
  .event-modal-action-row { flex-wrap: wrap; }
  .settings-row { grid-template-columns: 1fr; }
  .settings-tabs { overflow-x: auto; }
  .settings-tabs button { flex: none; min-height: 44px; font-size: 16px; padding: 0 14px; }
  .cam-refresh { min-height: 44px; font-size: 18px; padding: 0 14px; }
}

/* Webcam swipe + events tile cycling */
.cam-stage { touch-action: pan-y; user-select: none; }
.cam-img { will-change: transform; -webkit-user-drag: none; }
.tile-events .tile-copy { transition: opacity .45s ease; }
.tile-events .tile-copy.is-swapping { opacity: 0; }

@media (max-width: 820px) {
  .view-webcams { grid-template-rows: auto auto; align-content: start; overflow-y: auto; }
  .cam-stage { aspect-ratio: 4 / 3; min-height: 0; }
  .cam-label { padding: 10px 14px 18px; }
  .cam-label strong { font-size: 22px; }
  .cam-label span { font-size: 14px; }
  .cam-time { font-size: 13px; padding: 5px 11px; right: 10px; bottom: 10px; }
  .cam-bottom { flex-direction: column; align-items: stretch; gap: 10px; }
  .cam-strip { flex: none; padding: 2px 2px 8px; gap: 8px; scroll-snap-type: x proximity; }
  .cam-chip { padding: 11px 16px; font-size: 16px; min-height: 44px; scroll-snap-align: start; }
  .cam-credit { max-width: none; }
}
@media (max-width: 820px) {
  .cam-refresh { top: auto; right: auto; left: 10px; bottom: 10px; min-height: 30px; font-size: 13px; padding: 0 12px; }
}
