:root {
  color-scheme: dark;
  --cream: #f4ead8;
  --paper: #d8c7aa;
  --muted: #ae9c80;
  --amber: #eead50;
  --orange: #d97032;
  --panel: rgba(24, 16, 10, .91);
  --line: rgba(244, 234, 216, .16);
  --green: #77d19b;
}

* { box-sizing: border-box; }
html, body, #app { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { font-family: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: #160f0a; color: var(--cream); }
button, input { font: inherit; color: inherit; }
#map { position: absolute; inset: 0; background: #21180f; }
#map::after { content: ""; position: absolute; inset: 0; z-index: 400; pointer-events: none; background: radial-gradient(circle at 50% 45%, transparent 18%, rgba(24,14,7,.16) 65%, rgba(19,11,6,.58)); }
.leaflet-tile-pane { filter: sepia(.45) saturate(.65) brightness(.72) contrast(1.12); }
.leaflet-control-attribution { opacity: .65; font-size: 9px; }
.leaflet-control-zoom { display: none; }
.glass { background: var(--panel); border: 1px solid var(--line); box-shadow: 0 12px 40px rgba(0,0,0,.34); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
.topbar { position: fixed; z-index: 600; top: calc(12px + env(safe-area-inset-top)); left: 12px; right: 12px; min-height: 68px; padding: 10px 15px; border-radius: 19px; display: flex; justify-content: space-between; align-items: center; }
.eyebrow { margin: 0 0 2px; color: var(--amber); font-size: 10px; font-weight: 850; letter-spacing: .19em; }
h1, h2, h3 { margin: 0; font-family: Georgia, "Times New Roman", serif; }
h1 { font-size: 27px; letter-spacing: -.03em; }
h2 { font-size: 29px; line-height: 1.08; }
h3 { margin: 24px 0 10px; font-size: 18px; }
.subtitle { margin: 6px 0 14px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.player-stats { display: flex; gap: 7px; }
.player-stats span { padding: 7px 9px; border: 1px solid var(--line); border-radius: 11px; color: var(--paper); font-size: 11px; }
.player-stats .credits { color: #ffd176; }
.map-message { position: fixed; z-index: 600; top: calc(92px + env(safe-area-inset-top)); left: 12px; right: 12px; padding: 11px 13px; border-radius: 16px; display: flex; justify-content: space-between; align-items: center; }
.map-message div { display: flex; flex-direction: column; gap: 3px; }
.map-message strong { font-size: 14px; }
.map-message span { color: var(--muted); font-size: 11px; }
.map-message button { border: 0; border-radius: 12px; padding: 10px 12px; background: linear-gradient(135deg, #d57835, #ae4729); font-weight: 800; font-size: 12px; }
.bottom-nav { position: fixed; z-index: 600; bottom: calc(12px + env(safe-area-inset-bottom)); left: 12px; right: 12px; height: 70px; border-radius: 22px; display: grid; grid-template-columns: repeat(4,1fr); padding: 7px; }
.nav-button { position: relative; border: 0; background: transparent; color: var(--muted); border-radius: 16px; font-size: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.nav-button > span { font-size: 22px; line-height: 1; }
.nav-button.active { color: var(--cream); background: rgba(255,255,255,.075); }
.nav-button b { position: absolute; top: 3px; right: 17%; min-width: 18px; padding: 2px 5px; border-radius: 10px; background: var(--orange); color: #fff; font-size: 9px; }
.nav-button .online-badge { background: #26764a; }
.user-marker { width: 18px; height: 18px; background: var(--cream); border: 4px solid var(--orange); border-radius: 50%; box-shadow: 0 0 0 8px rgba(216,112,50,.22), 0 0 26px var(--orange); }
.radio-marker { position: relative; width: 49px; height: 40px; border: 2px solid #f0bf68; border-radius: 8px; background: linear-gradient(145deg,#4b2c17,#1e130c); box-shadow: 0 0 0 5px rgba(238,173,80,.13), 0 0 24px rgba(238,173,80,.85); animation: pulse 2.4s ease-in-out infinite; }
.radio-marker::before { content: ""; position: absolute; left: 7px; top: 8px; width: 20px; height: 20px; border: 2px dotted #e9c98e; border-radius: 50%; }
.radio-marker::after { content: ""; position: absolute; right: 6px; top: 10px; width: 8px; height: 8px; border: 2px solid #e9c98e; border-radius: 50%; box-shadow: 0 13px 0 -2px #e9c98e; }
@keyframes pulse { 50% { transform: translateY(-5px) scale(1.04); filter: brightness(1.25); } }
.sheet { position: fixed; z-index: 1000; inset: 0; display: flex; align-items: flex-end; background: rgba(9,5,2,.7); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
#details-sheet { z-index: 1200; }
.hidden { display: none !important; }
.sheet-card { position: relative; width: 100%; max-height: 93vh; overflow: auto; padding: 24px 20px calc(22px + env(safe-area-inset-bottom)); border-radius: 30px 30px 0 0; background: linear-gradient(155deg,#2c1e13,#120c08 68%); border: 1px solid var(--line); box-shadow: 0 -20px 65px rgba(0,0,0,.55); }
.close { position: absolute; top: 15px; right: 16px; width: 37px; height: 37px; border: 1px solid var(--line); border-radius: 50%; background: rgba(255,255,255,.06); font-size: 25px; line-height: 1; }
.encounter-card { text-align: center; }
.rarity-row { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 13px; color: var(--amber); font-size: 12px; }
.text-button { border: 0; padding: 5px; background: transparent; color: var(--paper); text-decoration: underline; }
.tuner { padding: 15px; border: 1px solid rgba(238,173,80,.25); border-radius: 19px; background: linear-gradient(145deg,rgba(0,0,0,.38),rgba(90,51,19,.2)); }
.frequency { display: flex; justify-content: space-between; align-items: baseline; }
.frequency small { color: var(--muted); letter-spacing: .14em; }
.frequency strong { font: 27px ui-monospace, SFMono-Regular, Menlo, monospace; color: #ffd27b; text-shadow: 0 0 12px rgba(255,180,70,.65); }
.signal-bars { height: 24px; display: flex; justify-content: center; align-items: flex-end; gap: 4px; margin: 8px 0 4px; }
.signal-bars i { display: block; width: 7px; height: 20%; border-radius: 4px; background: #5b3e27; transition: .15s; }
.signal-bars i:nth-child(2) { height: 35%; }.signal-bars i:nth-child(3) { height: 52%; }.signal-bars i:nth-child(4) { height: 72%; }.signal-bars i:nth-child(5) { height: 100%; }
.signal-bars[data-strength="1"] i:nth-child(-n+1), .signal-bars[data-strength="2"] i:nth-child(-n+2), .signal-bars[data-strength="3"] i:nth-child(-n+3), .signal-bars[data-strength="4"] i:nth-child(-n+4), .signal-bars[data-strength="5"] i { background: var(--green); box-shadow: 0 0 8px rgba(119,209,155,.7); }
#tuning-slider { width: 100%; accent-color: var(--amber); }
.dial-scale { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }
.primary { width: 100%; margin-top: 12px; padding: 14px; border: 0; border-radius: 14px; background: linear-gradient(135deg,#d87735,#a63e27); font-weight: 850; }
.primary:disabled { background: rgba(255,255,255,.08); color: #807263; }
.radio-art { position: relative; width: 230px; max-width: 78%; height: 145px; margin: 15px auto 12px; filter: drop-shadow(0 16px 14px rgba(0,0,0,.45)); }
.radio-art::before, .radio-art::after { content: ""; position: absolute; }
.radio-art.cathedral { width: 145px; border: 8px solid #6d3b1d; border-radius: 72px 72px 10px 10px; background: repeating-radial-gradient(circle at 50% 46%,#2d1a0e 0 8px,#9a6934 9px 11px); }
.radio-art.cathedral::after { left: 22px; right: 22px; bottom: 16px; height: 23px; border-radius: 5px; background: #1e130d; box-shadow: inset 0 0 0 3px #8c5a2c; }
.radio-art.bakelite { width: 175px; height: 150px; border: 8px solid #191715; border-radius: 16px 16px 8px 8px; background: repeating-radial-gradient(circle at 50% 43%,#1d1b18 0 6px,#5b4e3c 7px 9px); }
.radio-art.bakelite::after { left: 23px; right: 23px; bottom: 15px; height: 22px; border-radius: 3px; background: #bca36f; box-shadow: inset 0 0 0 5px #201a13; }
.radio-art.phono { width: 260px; height: 118px; margin-top: 27px; border: 7px solid #d8d0b9; border-radius: 5px; background: linear-gradient(90deg,#e4dcc4 0 34%,#262521 34% 37%,#e4dcc4 37%); }
.radio-art.phono::before { left: 15px; top: 18px; width: 65px; height: 65px; border-radius: 50%; background: #2a2925; box-shadow: inset 0 0 0 9px #4f4c43; }
.radio-art.phono::after { right: 20px; top: 20px; width: 120px; height: 50px; border-bottom: 4px solid #4c493f; background: repeating-linear-gradient(0deg,transparent 0 7px,#8a816c 8px 9px); }
.radio-art.cube { width: 230px; height: 120px; margin-top: 26px; border-radius: 13px; background: linear-gradient(90deg,#dd4c20 0 49%,#1d1c1a 49% 51%,#dd4c20 51%); box-shadow: inset 0 0 0 7px #ed6838; }
.radio-art.cube::before { left: 20px; top: 21px; width: 73px; height: 73px; border-radius: 50%; background: repeating-radial-gradient(circle,#28231f 0 3px,#b9a888 4px 5px); }
.radio-art.cube::after { right: 24px; top: 24px; width: 75px; height: 65px; border-radius: 5px; background: repeating-linear-gradient(0deg,#29241f 0 5px,#d5be91 6px 7px); }
.radio-art.portable { width: 225px; height: 135px; border: 7px solid #1c1813; border-radius: 8px; background: linear-gradient(90deg,#272019 0 55%,#bca372 55%); box-shadow: inset 0 0 0 4px #4e4131; }
.radio-art.portable::before { left: 66px; top: -25px; width: 88px; height: 25px; border: 8px solid #252019; border-bottom: 0; border-radius: 12px 12px 0 0; }
.radio-art.portable::after { right: 18px; top: 20px; width: 72px; height: 75px; border-radius: 4px; background: repeating-linear-gradient(0deg,#5e523d 0 8px,#d6c69b 9px 10px); }
.details-card .radio-art { transform: scale(.82); margin-top: 2px; margin-bottom: -8px; }
dl { display: grid; grid-template-columns: 42% 58%; margin: 8px 0; border-top: 1px solid var(--line); }
dt, dd { margin: 0; padding: 9px 4px; border-bottom: 1px solid var(--line); font-size: 12px; }
dt { color: var(--muted); } dd { color: var(--cream); }
.historical-note { padding: 12px; border-left: 3px solid var(--amber); background: rgba(238,173,80,.07); color: var(--paper); font-size: 12px; line-height: 1.45; }
.sources { display: flex; flex-wrap: wrap; gap: 7px; }
.sources a { color: #efc983; font-size: 11px; }
.bench-tip { position: relative; display: grid; grid-template-columns: 34px 1fr; gap: 10px; margin: 16px 0 4px; padding: 13px 12px 42px; border: 1px solid rgba(238,173,80,.32); border-radius: 17px; background: linear-gradient(135deg,rgba(238,173,80,.12),rgba(255,255,255,.025)); }
.bench-tip-icon { font-size: 23px; }
.bench-tip span { display: block; margin-bottom: 3px; color: var(--amber); font-size: 9px; font-weight: 900; letter-spacing: .14em; }
.bench-tip strong { display: block; font-family: Georgia,serif; font-size: 15px; }
.bench-tip p { margin: 5px 0 0; color: var(--paper); font-size: 11px; line-height: 1.45; }
.bench-tip button { position: absolute; right: 10px; bottom: 9px; padding: 6px 9px; border: 1px solid rgba(238,173,80,.3); border-radius: 9px; background: rgba(0,0,0,.18); color: #efc983; font-size: 10px; }
.tool-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 9px; }
.tool-card { min-height: 154px; padding: 12px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.035); }
.tool-icon { font-size: 28px; }.tool-card strong { display: block; margin-top: 5px; font-size: 13px; }.tool-card small { display: block; min-height: 30px; margin: 4px 0 8px; color: var(--muted); font-size: 10px; }.tool-card button { width: 100%; padding: 7px; border: 0; border-radius: 9px; background: #84452c; font-size: 10px; }.tool-card.owned { border-color: rgba(119,209,155,.4); }.tool-card.owned .tool-action { background: rgba(119,209,155,.12); color: var(--green); }.tool-card .tool-tip-button { margin-top: 6px; border: 1px solid var(--line); background: transparent; color: var(--paper); }
.radio-list { display: grid; gap: 10px; }
.radio-card { display: grid; grid-template-columns: 76px 1fr; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 17px; background: rgba(255,255,255,.035); }
.mini-radio { position: relative; height: 60px; align-self: center; border-radius: 8px; background: linear-gradient(145deg,#7a4524,#25160e); box-shadow: inset 0 0 0 4px rgba(255,255,255,.1); }
.mini-radio::after { content: ""; position: absolute; left: 10px; top: 12px; width: 35px; height: 35px; border: 2px dotted #e6c58e; border-radius: 50%; }
.radio-card h4 { margin: 0 0 2px; font-family: Georgia,serif; font-size: 15px; }.radio-card p { margin: 2px 0; color: var(--muted); font-size: 10px; }.radio-card .card-actions { display: flex; gap: 6px; margin-top: 8px; }.radio-card button { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.05); font-size: 10px; }.radio-card button.restore { border: 0; background: #84452c; }
.empty { padding: 30px 12px; color: var(--muted); text-align: center; font-size: 12px; }
.community-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.community-title > span { display: flex; align-items: center; gap: 5px; color: var(--green); font-size: 11px; }
.community-title i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 9px rgba(119,209,155,.8); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin: 18px 0 14px; padding: 4px; border: 1px solid var(--line); border-radius: 13px; background: rgba(0,0,0,.2); }
.auth-tabs button { padding: 9px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 12px; }
.auth-tabs button.active { background: rgba(238,173,80,.15); color: var(--cream); }
.auth-form { display: grid; gap: 11px; }
.auth-form label { display: grid; gap: 5px; color: var(--paper); font-size: 11px; }
.auth-form input, .chat-form input { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 12px; outline: none; background: rgba(255,255,255,.055); color: var(--cream); font-size: 13px; }
.auth-form input:focus, .chat-form input:focus { border-color: rgba(238,173,80,.6); }
.auth-form .primary { margin-top: 2px; }
.auth-feedback { margin-top: 12px; padding: 12px; border: 1px solid rgba(238,173,80,.3); border-radius: 13px; background: rgba(238,173,80,.08); color: var(--paper); font-size: 12px; line-height: 1.45; }
.auth-feedback button { display: block; width: 100%; margin-top: 9px; padding: 9px; border: 0; border-radius: 9px; background: #84452c; }
.member-row { display: flex; align-items: center; justify-content: space-between; margin: 16px 0 12px; padding: 11px 12px; border: 1px solid rgba(119,209,155,.25); border-radius: 14px; background: rgba(119,209,155,.07); }
.member-row small { display: block; color: var(--muted); font-size: 8px; letter-spacing: .12em; }.member-row strong { font-size: 14px; }.member-row button { padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px; background: transparent; color: var(--paper); font-size: 10px; }
.chat-list { display: grid; align-content: start; gap: 8px; min-height: 230px; max-height: 47vh; overflow: auto; padding: 11px; border: 1px solid var(--line); border-radius: 16px; background: rgba(0,0,0,.22); }
.chat-empty { align-self: center; color: var(--muted); text-align: center; font-size: 11px; }
.chat-message { padding: 9px 10px; border-radius: 12px; background: rgba(255,255,255,.055); }
.chat-message header { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; }.chat-message strong { color: #efc983; font-size: 11px; }.chat-message time { color: var(--muted); font-size: 8px; }.chat-message p { margin: 0; color: var(--paper); font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
.chat-form { display: grid; grid-template-columns: 1fr 45px; gap: 7px; margin-top: 9px; }.chat-form button { border: 0; border-radius: 12px; background: linear-gradient(135deg,#d87735,#a63e27); font-size: 18px; }.chat-note { margin: 8px 2px 0; color: var(--muted); font-size: 9px; text-align: center; }
.toast { position: fixed; z-index: 1400; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translate(-50%,20px); width: max-content; max-width: calc(100% - 40px); padding: 11px 15px; border-radius: 13px; background: var(--cream); color: #1c110a; font-size: 12px; font-weight: 800; opacity: 0; pointer-events: none; transition: .25s; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.toast.show { opacity: 1; transform: translate(-50%,0); }

@media (min-width:700px) {
  .topbar,.map-message,.bottom-nav { left:50%; width:480px; right:auto; transform:translateX(-50%); }
  .sheet { align-items:center; justify-content:center; }.sheet-card { width:460px; border-radius:30px; padding-bottom:24px; }
}
