:root {
  --bg: rgba(12, 16, 26, 0.72);
  --bg-solid: #0d121c;
  --line: rgba(170, 195, 235, 0.14);
  --line2: rgba(170, 195, 235, 0.24);
  --text: #e8eef8;
  --muted: #93a2b8;
  --accent: #ff9f1c;
  --accent2: #ffd166;
  --ok: #6ee7a0;
  --danger: #ff4b4b;
  --radius: 16px;
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b0f17; color: var(--text); font-family: var(--font); }
body { -webkit-font-smoothing: antialiased; user-select: none; }
button, select, input { font: inherit; color: inherit; }
kbd {
  font-family: var(--mono); font-size: 10px; padding: 1px 5px; border-radius: 5px;
  border: 1px solid var(--line2); background: rgba(255, 255, 255, 0.06); color: var(--muted); vertical-align: 1px;
}

#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#view:active { cursor: grabbing; }
#vignette {
  position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 55%, rgba(0,0,0,0.45) 100%);
}
#flash { position: fixed; inset: 0; pointer-events: none; background: #fff; opacity: 0; }

/* ---------- marka ---------- */
.brand {
  position: fixed; left: 18px; top: 14px; display: flex; gap: 12px; align-items: center; pointer-events: none;
  text-shadow: 0 2px 12px rgba(0,0,0,0.6);
}
.brand h1 { margin: 0; font-size: 21px; font-weight: 800; letter-spacing: 0.2px; }
.brand h1 span { color: var(--accent); }
.brand p { margin: 1px 0 0; font-size: 12px; color: #c9d4e4; font-weight: 500; }
.logo {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; color: #1a1006;
  background: linear-gradient(135deg, var(--accent2), var(--accent)); box-shadow: 0 6px 22px rgba(255,140,30,0.35);
}
.logo svg { width: 26px; height: 26px; }
.logo.big { width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 10px; }
.logo.big svg { width: 44px; height: 44px; }

/* ---------- pasek narzędzi ---------- */
.toolbar { position: fixed; top: 14px; right: 18px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; max-width: calc(100% - 320px); }
.seg {
  display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 3px;
  backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3);
}
.seg button {
  border: 0; background: transparent; padding: 6px 10px; border-radius: 9px; font-size: 12.5px; font-weight: 600; color: #b8c4d6;
  cursor: pointer; white-space: nowrap; transition: background .15s, color .15s;
}
.seg button:hover { background: rgba(255,255,255,0.07); color: #fff; }
.seg button.on { background: rgba(255,255,255,0.14); color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12); }
.seg.full { display: flex; width: 100%; margin: 6px 0 12px; }
.seg.full button { flex: 1; padding: 7px 4px; font-size: 12px; }
.seg.full button.on { background: color-mix(in srgb, var(--accent) 26%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 55%, transparent); }

/* ---------- panele ---------- */
.panel {
  position: fixed; top: 72px; width: 300px; max-height: calc(100% - 72px - 16px);
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  backdrop-filter: blur(16px) saturate(1.3); -webkit-backdrop-filter: blur(16px) saturate(1.3);
  box-shadow: 0 18px 50px rgba(0,0,0,0.35); display: flex; flex-direction: column;
}
.panel.left { left: 18px; }
.panel.right { right: 18px; width: 296px; }
.panel-body { overflow-y: auto; padding: 14px 16px 16px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.15) transparent; }
.panel section { padding: 2px 0 12px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.panel section:last-of-type { border-bottom: 0; }
.sheet-toggle { display: none; }
.panel-foot { padding: 12px 16px 14px; border-top: 1px solid var(--line); flex-shrink: 0; }
.row2 { margin-top: 0 !important; }
.label { display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.9px; text-transform: uppercase; color: var(--muted); }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.row-between .label { display: inline; }
.val { font-family: var(--mono); font-size: 12.5px; color: #fff; }

.chip {
  font-size: 11.5px; font-weight: 800; padding: 3px 9px; border-radius: 99px; color: #120a02;
  background: var(--accent); box-shadow: 0 0 18px color-mix(in srgb, var(--accent) 50%, transparent);
}
.mag-value { display: flex; align-items: baseline; gap: 6px; margin: 2px 0 2px; }
.mag-value small { font-size: 22px; font-weight: 700; color: var(--muted); }
.mag-value b {
  font-size: 54px; font-weight: 800; line-height: 1; letter-spacing: -1.5px; color: var(--accent);
  text-shadow: 0 0 28px color-mix(in srgb, var(--accent) 45%, transparent); font-variant-numeric: tabular-nums;
}
.ticks { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 10px; color: var(--muted); padding: 0 4px; margin-top: -2px; }
.hint { font-size: 11.5px; color: var(--muted); margin: 8px 0 0; line-height: 1.45; }
.hint b { color: #dfe7f3; }

input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 26px; background: transparent; margin: 4px 0 8px; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 6px; background: var(--track, rgba(255,255,255,0.14)); }
input[type=range]::-moz-range-track { height: 6px; border-radius: 6px; background: var(--track, rgba(255,255,255,0.14)); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; margin-top: -7px; border-radius: 50%; background: #fff;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 45%, transparent), 0 2px 8px rgba(0,0,0,0.5);
}
input[type=range]::-moz-range-thumb { width: 20px; height: 20px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 45%, transparent); }
#mag { height: 30px; }
#mag::-webkit-slider-runnable-track { height: 10px; background: linear-gradient(90deg, #8fb3c9 0%, #7fd1b9 14.3%, #b9e06a 33.4%, #ffd23f 47.8%, #ff9f1c 60.2%, #ff5a36 74.5%, #e0115f 95.3%, #b43cf0 95.8%, #b43cf0 100%); }
#mag::-moz-range-track { height: 10px; background: linear-gradient(90deg, #8fb3c9 0%, #7fd1b9 14.3%, #b9e06a 33.4%, #ffd23f 47.8%, #ff9f1c 60.2%, #ff5a36 74.5%, #e0115f 95.3%, #b43cf0 95.8%, #b43cf0 100%); }
#mag::-webkit-slider-thumb { width: 24px; height: 24px; margin-top: -7px; }

.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 8px 0 8px; }
.chips button {
  border: 1px solid var(--line2); background: rgba(255,255,255,0.04); border-radius: 10px; padding: 6px 4px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 1px; transition: all .15s;
}
.chips button b { font-size: 11.5px; font-weight: 700; }
.chips button small { font-family: var(--mono); font-size: 10px; color: var(--muted); }
.chips button:hover { background: rgba(255,255,255,0.09); border-color: rgba(255,255,255,0.3); }
.chips button.on { border-color: var(--c); background: color-mix(in srgb, var(--c) 18%, transparent); }
select {
  width: 100%; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line2); background: rgba(255,255,255,0.05);
  font-size: 12.5px; font-weight: 600; cursor: pointer; outline: none;
}
select option { background: #121826; color: #e8eef8; }
.note { margin-top: 8px; font-size: 12px; line-height: 1.45; color: #cdd7e6; background: rgba(255,255,255,0.05); border-left: 3px solid var(--accent); padding: 8px 10px; border-radius: 8px; }
.note b { color: #fff; }

.go {
  position: relative; overflow: hidden; width: 100%; border: 0; cursor: pointer; padding: 14px 14px; border-radius: 14px;
  font-size: 15.5px; font-weight: 800; letter-spacing: 0.2px; color: #170b02;
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  box-shadow: 0 10px 30px color-mix(in srgb, var(--accent) 40%, transparent), inset 0 1px 0 rgba(255,255,255,0.4);
  transition: transform .12s, box-shadow .2s;
}
.go:hover { transform: translateY(-1px); box-shadow: 0 14px 36px color-mix(in srgb, var(--accent) 55%, transparent), inset 0 1px 0 rgba(255,255,255,0.4); }
.go:active { transform: translateY(1px) scale(0.99); }
.go kbd { border-color: rgba(0,0,0,0.25); background: rgba(0,0,0,0.12); color: rgba(20,10,0,0.7); margin-left: 6px; }
.go-pulse { position: absolute; inset: 0; border-radius: inherit; pointer-events: none; }
.go.shaking { animation: goShake .25s infinite; }
@keyframes goShake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-2px); } 75% { transform: translateX(2px); } }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.ghost {
  border: 1px solid var(--line2); background: rgba(255,255,255,0.04); border-radius: 11px; padding: 8px 6px;
  font-size: 12px; font-weight: 700; cursor: pointer; transition: background .15s;
}
.ghost:hover { background: rgba(255,255,255,0.1); }
.ghost.off { color: var(--muted); }

/* ---------- prognoza ---------- */
.mmi-big { display: flex; align-items: center; gap: 12px; margin: 8px 0 6px; }
.mmi-big > b {
  min-width: 64px; height: 56px; padding: 0 8px; border-radius: 12px; display: grid; place-items: center;
  font-size: 30px; font-weight: 800; color: #160c04; background: var(--mmi, #ff9330); box-shadow: 0 0 24px color-mix(in srgb, var(--mmi, #ff9330) 45%, transparent);
  font-family: var(--font);
}
.mmi-big .mmi-name { display: block; font-size: 17px; font-weight: 800; }
.mmi-big small { color: var(--muted); font-size: 11px; }
.mmi-text { font-size: 12.5px; line-height: 1.5; color: #cfd8e6; margin: 4px 0 10px; }
.stats { margin: 0; display: grid; gap: 0; }
.stats > div { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px dashed var(--line); font-size: 12px; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; text-align: right; font-weight: 700; color: #f1f5fb; font-variant-numeric: tabular-nums; }
.stats dd small { display: block; font-weight: 500; color: var(--muted); font-size: 10.5px; }
#fcTsuRow.warn dd { color: #6fd3ff; }

/* ---------- na żywo ---------- */
.live { animation: fadeIn .3s; }
.timer { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.phase { margin: 8px 0 10px; font-size: 14px; font-weight: 800; color: var(--accent2); min-height: 20px; }
.live-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.live-grid > div { background: rgba(255,255,255,0.05); border-radius: 10px; padding: 7px 8px; }
.live-grid small { display: block; font-size: 10px; color: var(--muted); }
.live-grid b { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- raport ---------- */
.report { animation: fadeIn .4s; }
.report h3 { margin: 6px 0 8px; font-size: 16px; }
.x { border: 0; background: rgba(255,255,255,0.08); width: 26px; height: 26px; border-radius: 8px; cursor: pointer; font-size: 17px; line-height: 1; }
.x:hover { background: rgba(255,255,255,0.18); }
.bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: rgba(255,255,255,0.06); }
.bar i { display: block; height: 100%; transition: width .6s; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 6px 0 8px; font-size: 10.5px; color: var(--muted); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; }
.rep-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.rep-table td { padding: 4px 0; border-top: 1px dashed var(--line); }
.rep-table td:first-child { color: #d8e0ec; }
.rep-table td:last-child { width: 46%; }
.mini { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: rgba(255,255,255,0.06); }
.mini i { display: block; height: 100%; }
.rep-extra { list-style: none; padding: 0; margin: 10px 0 6px; font-size: 12px; display: grid; gap: 4px; }
.rep-extra li { display: flex; justify-content: space-between; color: var(--muted); }
.rep-extra li b { color: #fff; }
.rep-comment { font-size: 12.5px; line-height: 1.5; color: #dce4ef; background: rgba(255,255,255,0.05); padding: 9px 10px; border-radius: 10px; margin: 8px 0 0; }

/* ---------- dół ---------- */
.hud {
  position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); width: min(720px, calc(100% - 660px));
  min-width: 380px; display: flex; flex-direction: column; gap: 8px;
}
.mmi-bar { position: relative; display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; }
.mmi-bar .cell {
  height: 24px; border-radius: 6px; display: grid; place-items: center; font-size: 10.5px; font-weight: 800; color: rgba(0,0,0,0.75);
  opacity: 0.38; transition: opacity .15s, transform .15s; position: relative;
}
.mmi-bar .cell.lit { opacity: 1; transform: translateY(-2px); box-shadow: 0 0 16px var(--c); }
.mmi-bar .cell.fc::after { content: ''; position: absolute; left: 50%; bottom: -6px; transform: translateX(-50%); border: 4px solid transparent; border-bottom-color: #fff; border-top: 0; }
.mmi-now, .mmi-peak { display: none; }
.seismo {
  height: 104px; background: rgba(8, 12, 20, 0.78); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; position: relative;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.seismo canvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
.seismo-label {
  position: absolute; left: 10px; right: 10px; bottom: 6px; display: flex; justify-content: space-between; pointer-events: none;
  font-family: var(--mono); font-size: 10px; color: rgba(190,205,230,0.6); letter-spacing: 0.6px;
}

/* ---------- komunikaty ---------- */
.tooltip {
  position: fixed; z-index: 30; pointer-events: none; min-width: 200px; max-width: 270px; padding: 10px 12px; border-radius: 12px;
  background: rgba(10, 14, 22, 0.9); border: 1px solid var(--line2); font-size: 12px; line-height: 1.45; box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}
.tooltip b { font-size: 13.5px; }
.tooltip .st { display: inline-block; margin: 4px 0; font-weight: 800; font-size: 11.5px; }
.tooltip small { color: var(--muted); display: block; }
.toasts { position: fixed; left: 50%; top: 70px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; z-index: 25; pointer-events: none; }
.toast {
  background: rgba(10, 14, 22, 0.88); border: 1px solid var(--line2); padding: 8px 14px; border-radius: 99px; font-size: 13px; font-weight: 700;
  box-shadow: 0 8px 26px rgba(0,0,0,0.35); animation: toastIn .3s; transition: opacity .5s, transform .5s;
}
.toast.alert { border-color: #ff5a36; background: rgba(60, 10, 6, 0.9); }
.toast.info { border-color: #4fb5ff; }
.toast.out { opacity: 0; transform: translateY(-8px); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.phase-banner {
  position: fixed; left: 50%; top: 22%; transform: translateX(-50%); pointer-events: none; text-align: center; z-index: 20;
  font-size: 30px; font-weight: 800; letter-spacing: 0.5px; text-shadow: 0 4px 30px rgba(0,0,0,0.7); animation: banner 2.6s forwards;
}
.phase-banner small { display: block; font-size: 14px; font-weight: 600; color: #d3dceb; margin-top: 4px; }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, 10px) scale(0.96); } 12% { opacity: 1; transform: translate(-50%, 0) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- nakładki ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(ellipse at center, rgba(8,10,18,0.55), rgba(5,7,12,0.85));
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); transition: opacity .5s;
}
.overlay.hide { opacity: 0; pointer-events: none; }
.card {
  width: min(540px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: rgba(14, 19, 30, 0.94); border: 1px solid var(--line2);
  border-radius: 22px; padding: 28px 30px; box-shadow: 0 30px 80px rgba(0,0,0,0.5); text-align: left; position: relative;
}
.card h2 { text-align: center; margin: 0 0 4px; font-size: 30px; font-weight: 800; }
.card .lead { text-align: center; color: #cbd5e3; margin: 0 0 16px; line-height: 1.5; }
.card ol { padding-left: 20px; margin: 0 0 14px; line-height: 1.55; font-size: 14px; color: #d8e0ec; }
.card ol li { margin-bottom: 8px; }
.card .tip { font-size: 13px; color: #cfe6ff; background: rgba(79,181,255,0.1); border: 1px solid rgba(79,181,255,0.3); border-radius: 12px; padding: 9px 12px; margin: 0 0 18px; }
.card .loading { text-align: center; color: var(--muted); font-size: 12px; margin: 10px 0 0; }
.card.help { width: min(600px, 100%); }
.card.help h2 { text-align: left; }
.card.help h3 { margin: 18px 0 6px; }
.card.help p { font-size: 13.5px; line-height: 1.55; color: #d4dce8; }
.card.help .small { font-size: 12px; color: var(--muted); }
.card.help table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.card.help td { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.card.help td:first-child { width: 36%; }
.card .x { position: absolute; right: 16px; top: 16px; }
#start:disabled { opacity: 0.5; cursor: wait; }

/* ---------- responsywność ---------- */
@media (max-width: 1280px) {
  .toggles button span { display: none; }
  .hud { width: calc(100% - 660px); }
}
@media (max-width: 1100px) {
  .toolbar { max-width: calc(100% - 260px); }
  #viewSeg { display: none; }
  .hud { left: 50%; width: calc(100% - 36px); max-width: 640px; min-width: 0; }
  .panel.right { top: auto; bottom: 160px; max-height: 40vh; }
}
@media (max-width: 760px) {
  .brand p { display: none; }
  .brand h1 { font-size: 17px; }
  .logo { width: 32px; height: 32px; }
  .toolbar { top: 12px; right: 10px; max-width: calc(100% - 160px); }
  #todSeg button { padding: 6px 7px; font-size: 0; }
  #todSeg button::first-letter { font-size: 14px; }
  .panel { left: 10px !important; right: 10px !important; width: auto !important; top: auto; max-height: 62vh; }
  .panel.left { bottom: 132px; }
  .panel.right { bottom: 132px; }
  .panel .panel-body { display: none; }
  .panel.open .panel-body { display: block; }
  .panel.right:not(.open) { right: 10px; left: auto !important; width: calc(50% - 15px) !important; }
  .panel.left:not(.open) { width: calc(50% - 15px) !important; }
  .panel.open { z-index: 15; }
  .sheet-toggle { display: block; width: 100%; border: 0; background: transparent; padding: 11px 12px; font-weight: 800; font-size: 13px; cursor: pointer; text-align: left; }
  .hud { bottom: 8px; width: calc(100% - 20px); }
  .seismo { height: 72px; }
  .mmi-bar .cell { height: 20px; font-size: 9px; }
  .phase-banner { font-size: 21px; }
}
