/* Surf Buddy. Colors come from the pixel-art logo: deep ocean, sky blue, foam, sunset orange.
   Layout: one column on phones, cards in a 2-4 column grid on wider screens. */
:root {
  --abyss: #0b1d2e;
  --deep: #112a42;
  --raised: #17395a;
  --line: #24496d;
  --foam: #eaf4fb;
  --mist: #9db7cb;
  --sky: #5cc3ea;
  --sunset: #f0803c;
  --sand: #f6c56b;
  --good: #57d68d;
  --bad: #ff7a6b;
  --swell: #5cc3ea;
  --wind: #f6c56b;
  --sea: #0e2a45;
  --land: #1b2a33;
  --coast: #4d6b7d;
  --pix: "VT323", ui-monospace, Consolas, monospace;
  --body: "Rubik", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: radial-gradient(1200px 600px at 80% -10%, #16466e 0%, transparent 60%), var(--abyss);
  color: var(--foam); font: 16px/1.5 var(--body);
}
a { color: var(--sky); }
h1, h2, h3 { line-height: 1.15; text-wrap: balance; margin: 0; }
p { margin: 0; }
img { max-width: 100%; }
.sprite { position: absolute; }
.pix { font-family: var(--pix); font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.sub { color: var(--mist); }
.hint { color: var(--mist); font-size: .85rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .75rem; color: var(--sky); font-weight: 700; }
.ic { width: 18px; height: 18px; fill: currentColor; vertical-align: -3px; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; border-radius: 6px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 1000; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; background: rgba(11, 29, 46, .88); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--foam); text-decoration: none; font-family: var(--pix); font-size: 1.7rem; }
.brand img { border-radius: 10px; image-rendering: pixelated; }
.topnav { display: flex; align-items: center; gap: 6px; }
.navlink { color: var(--foam); text-decoration: none; padding: 8px 10px; border-radius: 10px; display: inline-flex; gap: 6px; align-items: center; }
.navlink:hover { background: var(--raised); }
.spot-menu { position: relative; }
.spot-menu summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 10px;
  background: var(--raised); border: 1px solid var(--line); max-width: 52vw;
}
.spot-menu summary span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spot-menu summary::-webkit-details-marker { display: none; }
.spot-menu ul {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 240px; margin: 0; padding: 6px; list-style: none;
  background: var(--deep); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 40px rgba(0, 0, 0, .45);
}
.spot-menu a { display: block; padding: 10px 12px; color: var(--foam); text-decoration: none; border-radius: 8px; }
.spot-menu a:hover, .spot-menu a[aria-current] { background: var(--raised); }
.spot-menu .sep { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }
.brand img { flex-shrink: 0; }
.btn { white-space: nowrap; }
@media (max-width: 560px) {
  .hide-sm { display: none; } .brand span { display: none; }
  .topbar { gap: 8px; padding-left: 12px; padding-right: 12px; }
  .topnav { gap: 2px; min-width: 0; }
  .spot-menu { min-width: 0; }
  .spot-menu summary { max-width: 42vw; padding: 7px 10px; }
  .navlink { padding: 8px 6px; }
  .btn-small { padding: 6px 10px; }
}

/* ---------- layout ---------- */
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 20px 16px 40px; display: flex; flex-direction: column; gap: 16px; flex: 1; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.card { background: var(--deep); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; min-width: 0; }
.card-flush { padding: 0; overflow: hidden; }
.card-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .12em; color: var(--mist); font-weight: 700; margin-bottom: 10px; }
.card-title.pad { padding: 18px 18px 0; }
.page-head { display: flex; flex-direction: column; gap: 6px; padding: 8px 0; }
.page-head h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); }

/* ---------- hero ---------- */
.hero {
  display: grid; gap: 20px; grid-template-columns: 1fr; padding: 22px; border-radius: 20px;
  background: linear-gradient(135deg, #17466d 0%, #112a42 70%); border: 1px solid var(--line);
}
@media (min-width: 860px) { .hero { grid-template-columns: 1.4fr 1fr; padding: 28px; } }
.hero-main { display: flex; flex-direction: column; gap: 12px; }
.score { display: flex; align-items: center; gap: 18px; }
.score-num { font-size: clamp(5rem, 18vw, 7.5rem); line-height: .8; color: var(--foam); }
.score-label { font-family: var(--pix); font-size: 2rem; line-height: 1; margin-top: 6px; }
.headline { font-size: 1.15rem; max-width: 46ch; }
.notes { margin: 0; padding-left: 18px; color: var(--mist); }
.rating-epic, .rating-very-good { color: var(--sunset); }
.rating-good { color: var(--good); }
.rating-fair { color: var(--sand); }
.rating-poor, .rating-flat, .rating-no-data { color: var(--mist); }
.stars { display: inline-flex; gap: 2px; }
.star { width: 20px; height: 20px; }
.stars-lg .star { width: 30px; height: 30px; }
.star-full { fill: var(--sunset); }
.star-empty { fill: none; stroke: var(--line); stroke-width: 1.6; }
.star-half { fill: var(--sunset); opacity: .55; }
.hero-side { display: flex; flex-direction: column; gap: 14px; justify-content: center; }
.meter-head { display: flex; justify-content: space-between; font-weight: 500; }
.meter-head .pix { font-size: 1.5rem; line-height: 1; }
.meter-bar { height: 10px; background: rgba(255, 255, 255, .08); border-radius: 999px; overflow: hidden; margin: 6px 0 4px; }
.meter-bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--sky), var(--sunset)); transition: width .8s ease; }
.meter-note { color: var(--mist); font-size: .85rem; }
.how { font-size: .9rem; }

/* ---------- stat cards ---------- */
.big { font-size: 3rem; line-height: 1; }
.big small { font-size: 1.4rem; color: var(--mist); margin-left: 3px; }
.big .sep, .big .trend { font-size: 1.4rem; color: var(--mist); }
.dir { margin-top: 10px; display: flex; align-items: center; gap: 6px; }
.dir-arrow { width: 22px; height: 22px; transform: rotate(var(--deg)); color: var(--sky); }
.card .sub { margin-top: 6px; font-size: .92rem; }
.tide-next, .tide-today { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; }
.tide-next li span, .tide-today li span { display: inline-block; width: 44px; color: var(--mist); }

/* ---------- swell chart ---------- */
.chart-card { display: flex; flex-direction: column; }
.chart-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; flex-wrap: wrap; padding: 16px 18px 12px; }
.chart-head .card-title { margin: 0 0 2px; }
.chart-time { font-family: var(--pix); font-size: 1.7rem; line-height: 1; }
.chart-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font: inherit; font-size: .82rem; font-weight: 500; color: var(--foam); background: var(--raised); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; cursor: pointer; }
.chip:hover { border-color: var(--sky); }
.chip[aria-pressed=true]#playBtn { background: var(--sunset); color: #23130a; border-color: var(--sunset); }
.swellmap-wrap { position: relative; height: clamp(340px, 58vw, 520px); border-top: 1px solid var(--line); }
.swellmap { position: absolute; inset: 0; background: var(--sea); }
.swellmap.leaflet-container { background: var(--sea); font: inherit; }
.wind-fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 450; }
.ramp { position: absolute; left: 12px; bottom: 12px; z-index: 460; display: grid; gap: 4px; padding: 8px 10px; border-radius: 10px;
  background: rgba(11, 29, 46, .82); border: 1px solid var(--line); font-size: .72rem; color: var(--mist); width: min(240px, 60%); }
.ramp-bar { display: block; height: 8px; border-radius: 4px;
  background: linear-gradient(90deg, rgb(17,52,92) 0%, rgb(29,104,160) 9%, rgb(56,170,196) 18%, rgb(87,200,141) 27%, rgb(246,197,107) 36%, rgb(240,128,60) 55%, rgb(214,61,72) 73%, rgb(176,48,150) 100%); }
.ramp-labels { display: flex; justify-content: space-between; }
.ramp-labels b { font-weight: 500; }
@media (max-width: 560px) { .ramp { width: 168px; padding: 6px 8px; font-size: .64rem; gap: 3px; } .ramp > span:first-child { display: none; } }
.chart-status { position: absolute; inset: 0; display: grid; place-items: center; z-index: 470; color: var(--mist); pointer-events: none; }
.leaflet-control-attribution { background: rgba(11, 29, 46, .75) !important; color: var(--mist) !important; font-size: .68rem !important; }
.leaflet-control-attribution a { color: var(--sky) !important; }
.leaflet-bar a { background: var(--deep) !important; color: var(--foam) !important; border-color: var(--line) !important; }
.map-pin a { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; transform: translate(-6px, -50%); padding: 2px 8px 2px 4px; border-radius: 999px;
  background: rgba(11, 29, 46, .9); border: 1px solid var(--line); color: var(--foam); text-decoration: none; font-size: .76rem; box-shadow: 0 2px 8px rgba(0,0,0,.4); }
.map-pin a i { width: 9px; height: 9px; border-radius: 50%; background: var(--foam); border: 2px solid var(--abyss); flex: none; }
.map-pin a b { font-family: var(--pix); font-size: 1.1rem; font-weight: 400; }
.map-pin.current a { border-color: var(--sunset); }
.map-pin.current a i { background: var(--sunset); }
.buoy-tip { font-size: .82rem; }
.readout { display: flex; flex-wrap: wrap; gap: 4px 18px; padding: 10px 18px; border-top: 1px solid var(--line); font-size: .92rem; align-items: baseline; }
.readout b { font-family: var(--pix); font-size: 1.4rem; font-weight: 400; }
.readout .where { color: var(--mist); }

/* ---------- forecast table ---------- */
.forecast { display: flex; flex-direction: column; gap: 10px; }
.forecast-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.forecast-head .card-title { margin: 0; }
.fc-scroll { overflow-x: auto; margin: 0 -18px; padding: 0 18px; scrollbar-width: thin; }
.fc { border-collapse: separate; border-spacing: 0; font-size: .82rem; }
.fc th[scope=row] { position: sticky; left: -18px; z-index: 2; background: var(--deep); text-align: left; padding: 6px 12px 6px 0; color: var(--mist); font-weight: 500; white-space: nowrap; min-width: 64px; }
.fc th[scope=row] small { font-size: .7rem; }
.fc td, .fc thead th[scope=col] { width: 46px; min-width: 46px; text-align: center; padding: 5px 2px; }
.fc-days th[scope=colgroup] { text-align: left; padding: 0 8px 6px; border-left: 1px solid var(--line); vertical-align: bottom; }
.fc-day { display: block; font-weight: 700; color: var(--foam); }
.fc-best { display: block; color: var(--mist); font-weight: 400; white-space: nowrap; }
.fc-best b { font-weight: 500; }
.fc-pick { font: inherit; font-size: .78rem; color: var(--mist); background: none; border: 0; padding: 4px 6px; border-radius: 6px; cursor: pointer; }
.fc-pick[aria-pressed=true] { background: var(--foam); color: var(--abyss); font-weight: 700; }
.fc td { cursor: pointer; }
.fc td.night { background: rgba(0, 0, 0, .18); }
.fc td.sel { background: rgba(92, 195, 234, .14); }
.fc-rating td { height: 76px; vertical-align: bottom; position: relative; }
.fc-bar { display: block; width: 26px; margin: 0 auto 4px; border-radius: 4px 4px 1px 1px; background: #5b7891; }
.fc-bar.rating-fair { background: var(--sand); } .fc-bar.rating-good { background: var(--good); }
.fc-bar.rating-very-good, .fc-bar.rating-epic { background: var(--sunset); }
.fc-rating .pix { font-size: 1.15rem; line-height: 1; }
.fc-surf b, .fc-wind b { display: block; font-weight: 500; font-size: .95rem; }
.fc-surf small, .fc-wind small { color: var(--mist); font-size: .7rem; }
.fc-wind td { color: var(--foam); }
.fc-wind .fc-arrow { width: 16px; height: 16px; transform: rotate(var(--deg)); display: block; margin: 0 auto 2px; }
.fc-wind .w-good .fc-arrow, .fc-wind td.w-good .fc-arrow { color: var(--good); }
.fc-wind td.w-ok .fc-arrow { color: var(--sand); }
.fc-wind td.w-bad .fc-arrow { color: var(--bad); }
.fc-tide-cell { padding: 4px 0 0 !important; cursor: default !important; }
.fc-tide-cell svg { display: block; width: 100%; height: 28px; }

/* ---------- charts ---------- */
.chart-box { position: relative; height: 230px; }
.chart-tall { height: 320px; }

/* ---------- forum ---------- */
.forum { display: flex; flex-direction: column; gap: 14px; }
.composer, .reply-form { display: flex; flex-direction: column; gap: 10px; }
.composer-row { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
textarea, input[type=text], input[type=email], input[type=password], select {
  width: 100%; font: inherit; color: var(--foam); background: var(--abyss); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
textarea:focus, input:focus, select:focus { border-color: var(--sky); outline: none; }
.file { position: relative; display: inline-flex; align-items: center; padding: 8px 12px; border: 1px dashed var(--line); border-radius: 10px; cursor: pointer; color: var(--mist); font-size: .9rem; }
.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file.has-file { border-style: solid; color: var(--sky); }
.file-small { padding: 6px 10px; }
.post { border-top: 1px solid var(--line); padding-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.post header { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.post time, .reply time { color: var(--mist); font-size: .85rem; }
.post img, .reply img { border-radius: 12px; max-height: 480px; object-fit: cover; }
.reply { margin-left: 14px; padding-left: 12px; border-left: 2px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.reply-form { flex-direction: row; flex-wrap: wrap; }
.reply-form input[type=text] { flex: 1 1 200px; width: auto; }
.inline { display: inline; margin-left: auto; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none;
  background: var(--sunset); color: #23130a; border: 0; border-radius: 10px; padding: 10px 18px; min-height: 42px;
}
.btn:hover { filter: brightness(1.08); }
.btn-small { padding: 6px 14px; min-height: 36px; }
.btn-ghost { background: transparent; color: var(--foam); border: 1px solid var(--line); }
.link-btn { background: none; border: 0; padding: 0; color: var(--sky); font: inherit; cursor: pointer; text-decoration: underline; }
.row-end { display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- flashes ---------- */
.flashes { max-width: 1180px; margin: 12px auto 0; padding: 0 16px; width: 100%; display: grid; gap: 8px; }
.flash { padding: 10px 14px; border-radius: 10px; background: var(--raised); border-left: 4px solid var(--sky); }
.flash-error { border-left-color: var(--bad); }
.flash-success { border-left-color: var(--good); }

/* ---------- auth dialog ---------- */
.dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--deep); color: var(--foam); padding: 0; width: min(420px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(3, 10, 18, .7); }
.auth-form { display: flex; flex-direction: column; gap: 12px; padding: 20px; }
.auth-form label, .settings label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--abyss); border-radius: 10px; padding: 4px; }
.tabs button { font: inherit; font-weight: 700; padding: 8px; border: 0; border-radius: 8px; background: none; color: var(--mist); cursor: pointer; }
.tabs button[aria-selected=true] { background: var(--raised); color: var(--foam); }

/* ---------- account ---------- */
.settings { display: flex; flex-direction: column; gap: 16px; max-width: 560px; }
.settings .check { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 400; }
.settings .check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--sunset); }
.logout-form { max-width: 560px; }

/* ---------- spots ---------- */
.spot-list { display: grid; gap: 12px; }
.spot-card { display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; color: inherit; text-decoration: none; transition: transform .15s, border-color .15s; }
.spot-card:hover { transform: translateY(-2px); border-color: var(--sky); }
.spot-rank { font-size: 2.4rem; color: var(--mist); width: 1.2em; text-align: center; }
.spot-body h2 { font-size: 1.15rem; }
.spot-score { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.score-num-sm { font-size: 2.6rem; line-height: .9; }
.score-label-sm { font-family: var(--pix); font-size: 1.2rem; }
@media (max-width: 560px) { .spot-card { grid-template-columns: auto 1fr; } .spot-score { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 10px; } }

/* ---------- history ---------- */
.filters { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 6px; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--mist); min-width: 180px; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th { color: var(--mist); font-weight: 500; font-size: .8rem; }
.table .pix { font-size: 1.3rem; }
.table-scroll, .card:has(> .table) { overflow-x: auto; }
.table-scroll { max-height: 420px; overflow-y: auto; }

/* ---------- how ---------- */
.how-card { display: flex; flex-direction: column; gap: 12px; }
.how-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.how-grid h3 { font-size: 1rem; margin-bottom: 4px; color: var(--sky); }
.how-grid p { color: var(--mist); }

/* ---------- display mode (TV / kiosk) ---------- */
.display-mode { background: var(--abyss); }
.display { padding: 3vw; display: flex; flex-direction: column; gap: 3vw; min-height: 100vh; }
.display-head { display: flex; align-items: center; gap: 20px; }
.display-head img { border-radius: 14px; image-rendering: pixelated; }
.display-head h1 { font-size: clamp(2rem, 4vw, 3.5rem); }
.display-score { display: flex; align-items: center; gap: 3vw; }
.display-score > .pix { font-size: clamp(6rem, 16vw, 14rem); line-height: .8; }
.display-grid { display: grid; gap: 2vw; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.display-grid > div { background: var(--deep); border: 1px solid var(--line); border-radius: 16px; padding: 2vw; }
.display-grid h2 { font-size: 1rem; text-transform: uppercase; letter-spacing: .12em; color: var(--mist); }
.display-grid .pix { font-size: clamp(2.2rem, 4vw, 3.6rem); line-height: 1.05; }
.display-grid .small-pix { font-size: clamp(1.4rem, 2.4vw, 2rem); }

/* ---------- error ---------- */
.error-page { align-items: center; text-align: center; padding: 60px 0; gap: 12px; }
.error-page img { border-radius: 20px; image-rendering: pixelated; }

/* ---------- footer ---------- */
.footer { border-top: 1px solid var(--line); padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0px)); text-align: center; color: var(--mist); font-size: .85rem; display: grid; gap: 4px; }

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

/* ---------- compare page: best time per day ---------- */
.spot-days { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; font-size: .85rem; color: var(--mist); }
.spot-days b { color: var(--foam); font-weight: 500; }
