:root {
  --bg: #07100e;
  --bg-soft: #0d1916;
  --panel: rgba(10, 23, 20, .95);
  --panel-2: rgba(16, 34, 29, .96);
  --ink: #eef5ec;
  --muted: #9eb1a8;
  --line: rgba(188, 220, 204, .16);
  --moss: #8ec9a3;
  --glow: #b8f2ce;
  --amber: #ddb978;
  --danger: #d97878;
  --shadow: 0 18px 60px rgba(0, 0, 0, .45);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
body { overflow-x: hidden; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.offline-banner {
  position: fixed; z-index: 3000; top: 0; left: 0; right: 0;
  padding: 10px 16px; text-align: center; background: #8a5c24; color: white; font-weight: 700;
}
.auth-view {
  min-height: 100dvh; display: grid; place-items: center; position: relative; overflow: hidden;
  padding: 28px 18px;
  background:
    radial-gradient(circle at 70% 10%, rgba(72, 134, 105, .22), transparent 30%),
    linear-gradient(155deg, #050a09 0%, #0a1713 48%, #07100e 100%);
}
.auth-view::before {
  content: ""; position: absolute; inset: 0; opacity: .18;
  background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,255,255,.02) 1px, transparent 1px);
  background-size: 34px 34px; transform: perspective(500px) rotateX(58deg) scale(1.4) translateY(20%);
}
.aurora {
  position: absolute; width: 540px; height: 540px; border-radius: 50%;
  background: conic-gradient(from 140deg, transparent, rgba(93,174,137,.22), transparent, rgba(185,146,80,.13), transparent);
  filter: blur(55px); animation: drift 16s linear infinite;
}
@keyframes drift { to { transform: rotate(360deg) scale(1.08); } }
.auth-card {
  width: min(100%, 430px); position: relative; z-index: 2; padding: 34px 26px 26px;
  background: linear-gradient(180deg, rgba(14,29,25,.94), rgba(6,14,12,.96));
  border: 1px solid var(--line); border-radius: 28px; box-shadow: var(--shadow); backdrop-filter: blur(18px);
}
.brand-rune, .profile-rune {
  width: 72px; height: 72px; display: grid; place-items: center; margin: 0 auto 18px;
  border: 1px solid rgba(184,242,206,.45); border-radius: 24px 8px 24px 8px;
  color: var(--glow); font-size: 42px; box-shadow: inset 0 0 22px rgba(142,201,163,.15), 0 0 30px rgba(142,201,163,.12);
}
.eyebrow { color: var(--moss); letter-spacing: .18em; font-size: 11px; font-weight: 800; margin: 0 0 8px; }
.auth-card h1 { margin: 0; text-align: center; letter-spacing: .12em; font-size: clamp(38px, 11vw, 56px); }
.auth-card h1 span { color: var(--moss); }
.lead { color: var(--muted); line-height: 1.55; text-align: center; margin: 12px 0 24px; }
.auth-tabs, .content-tabs, .admin-tabs {
  display: flex; gap: 6px; padding: 5px; border: 1px solid var(--line); background: rgba(0,0,0,.2); border-radius: 14px;
}
.auth-tabs button, .content-tabs button, .admin-tabs button {
  flex: 1; border: 0; border-radius: 10px; padding: 10px; color: var(--muted); background: transparent; font-weight: 700;
}
.auth-tabs button.active, .content-tabs button.active, .admin-tabs button.active { color: var(--ink); background: rgba(142,201,163,.16); }
.auth-form, .admin-form { display: grid; gap: 14px; margin-top: 18px; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 700; }
input, textarea, select {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; background: rgba(0,0,0,.24); color: var(--ink);
  padding: 12px 13px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--moss); box-shadow: 0 0 0 3px rgba(142,201,163,.1); }
textarea { resize: vertical; }
button, .admin-header a {
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; color: var(--ink); background: rgba(255,255,255,.05);
}
button:hover, .admin-header a:hover { background: rgba(255,255,255,.09); }
button.primary {
  border-color: rgba(142,201,163,.45); color: #04110b;
  background: linear-gradient(135deg, #b8f2ce, #7cbf96); font-weight: 900;
}
button.danger { color: #ffdede; border-color: rgba(217,120,120,.4); background: rgba(217,120,120,.12); }
.form-message { min-height: 20px; margin: 2px 0 0; color: var(--amber); font-size: 13px; }
.form-message.success { color: var(--glow); }
.beta-note { color: #6f8279; font-size: 11px; line-height: 1.5; text-align: center; margin: 18px 0 0; }

.game-view { position: fixed; inset: 0; overflow: hidden; background: #07100e; }
#map { position: absolute; inset: 0; background: #09120f; }
.leaflet-tile-pane {
  filter: invert(92%) hue-rotate(145deg) brightness(55%) saturate(80%) contrast(115%);
}
.leaflet-control-attribution { background: rgba(4,10,8,.75) !important; color: #8ca097 !important; }
.leaflet-control-attribution a { color: #b8d5c6 !important; }
.leaflet-control-zoom { display: none; }
.vignette { position: absolute; inset: 0; pointer-events: none; z-index: 500; box-shadow: inset 0 0 110px 30px rgba(0,0,0,.68); }
.fog-overlay {
  position: absolute; inset: -20%; z-index: 510; pointer-events: none; opacity: .34;
  background:
    radial-gradient(ellipse at 20% 30%, rgba(210,231,219,.14), transparent 26%),
    radial-gradient(ellipse at 78% 60%, rgba(196,223,209,.12), transparent 22%),
    radial-gradient(ellipse at 55% 10%, rgba(190,215,203,.08), transparent 30%);
  filter: blur(26px); animation: fogMove 24s ease-in-out infinite alternate;
}
@keyframes fogMove { to { transform: translate3d(6%, -3%, 0) scale(1.08); } }
.shadow-on .fog-overlay { opacity: .62; }
.shadow-on .leaflet-tile-pane { filter: invert(95%) hue-rotate(130deg) brightness(40%) saturate(115%) contrast(130%); }

.hud {
  position: absolute; z-index: 800; top: calc(10px + var(--safe-top)); left: 10px; right: 10px;
  display: flex; align-items: center; gap: 8px; pointer-events: none;
}
.hunter-chip, .level-chip, .icon-button {
  pointer-events: auto; background: rgba(6,16,13,.88); border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0,0,0,.28); backdrop-filter: blur(12px);
}
.hunter-chip { display: flex; align-items: center; gap: 9px; border-radius: 18px; padding: 7px 10px 7px 7px; min-width: 0; }
.hunter-chip strong { display: block; font-size: 13px; max-width: 120px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hunter-chip small, .level-chip small { display: block; color: var(--muted); font-size: 10px; }
.mini-avatar {
  width: 34px; height: 34px; display: grid; place-items: center; border-radius: 12px 5px 12px 5px;
  color: var(--glow); background: rgba(142,201,163,.12); border: 1px solid rgba(142,201,163,.25);
}
.level-chip { margin-left: auto; padding: 8px 10px; border-radius: 16px; min-width: 104px; }
.level-chip span { font-size: 10px; font-weight: 900; letter-spacing: .1em; }
.xp-track { height: 5px; background: rgba(255,255,255,.08); border-radius: 8px; overflow: hidden; margin: 5px 0; }
.xp-track i { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--moss), var(--glow)); transition: width .45s ease; }
.icon-button { width: 42px; height: 42px; padding: 0; border-radius: 15px; font-size: 22px; }

.gps-status {
  position: absolute; z-index: 750; top: calc(76px + var(--safe-top)); left: 50%; transform: translateX(-50%);
  padding: 7px 10px; border-radius: 999px; background: rgba(6,16,13,.82); border: 1px solid var(--line);
  color: var(--muted); font-size: 11px; white-space: nowrap; backdrop-filter: blur(8px);
}
.map-action {
  position: absolute; z-index: 760; right: 14px; width: 48px; height: 48px; border-radius: 18px;
  background: rgba(6,16,13,.9); box-shadow: 0 8px 24px rgba(0,0,0,.32);
}
.center-button { bottom: calc(94px + var(--safe-bottom)); font-size: 25px; }
.manual-button { bottom: calc(150px + var(--safe-bottom)); font-size: 10px; font-weight: 900; }
.manual-panel {
  position: absolute; z-index: 900; right: 14px; bottom: calc(205px + var(--safe-bottom)); width: min(330px, calc(100vw - 28px));
  padding: 14px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.manual-panel p { color: var(--muted); font-size: 12px; }
.field-row { display: flex; gap: 8px; }
.field-row input { min-width: 0; }

.hunter-marker { background: transparent; border: 0; }
.hunter-marker .hunter-body {
  width: 42px; height: 52px; position: relative; display: grid; place-items: center;
  color: var(--glow); font-size: 24px;
  background: linear-gradient(180deg, #1a352c, #07120f);
  clip-path: polygon(50% 0, 86% 25%, 78% 78%, 50% 100%, 22% 78%, 14% 25%);
  border: 1px solid var(--glow); filter: drop-shadow(0 0 10px rgba(184,242,206,.65));
}
.hunter-marker .accuracy-ring {
  position: absolute; width: 68px; height: 68px; left: -13px; top: -8px;
  border: 1px solid rgba(184,242,206,.22); border-radius: 50%; animation: pulse 2s ease-out infinite;
}
@keyframes pulse { 50% { transform: scale(1.18); opacity: .35; } }
.place-marker { background: transparent; border: 0; }
.place-marker span {
  width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50% 50% 50% 12%;
  transform: rotate(-45deg); border: 1px solid rgba(255,255,255,.35); box-shadow: 0 8px 20px rgba(0,0,0,.42);
  background: #22372f; color: white;
}
.place-marker b { transform: rotate(45deg); font-size: 16px; }
.place-marker.historical span { background: #6b5630; }
.place-marker.folklore span { background: #315e49; }
.place-marker.mystery span { background: #49395e; }
.place-marker.silhouette span { opacity: .55; filter: grayscale(1); }

.bottom-nav {
  position: absolute; z-index: 850; left: 10px; right: 10px; bottom: calc(8px + var(--safe-bottom));
  height: 68px; display: flex; justify-content: space-around; align-items: stretch;
  padding: 5px; border-radius: 22px; background: rgba(5,14,11,.92); border: 1px solid var(--line);
  box-shadow: 0 14px 38px rgba(0,0,0,.4); backdrop-filter: blur(16px);
}
.bottom-nav button, .bottom-nav a {
  flex: 1; border: 0; color: var(--muted); background: transparent; text-decoration: none;
  display: grid; place-items: center; align-content: center; gap: 2px; border-radius: 16px; font-size: 10px; font-weight: 800;
}
.bottom-nav span { font-size: 20px; }
.bottom-nav .active { color: var(--glow); background: rgba(142,201,163,.12); }

.bottom-sheet {
  position: absolute; z-index: 1100; left: 0; right: 0; bottom: 0; max-height: min(82dvh, 760px);
  overflow-y: auto; padding: 26px 18px calc(96px + var(--safe-bottom));
  border-radius: 28px 28px 0 0; background: linear-gradient(180deg, rgba(17,35,30,.98), rgba(5,13,11,.995));
  border-top: 1px solid rgba(184,242,206,.24); box-shadow: 0 -20px 60px rgba(0,0,0,.56);
  animation: sheetUp .25s ease-out;
}
@keyframes sheetUp { from { transform: translateY(60%); opacity: 0; } }
.sheet-close, .panel-close, .dialog-close {
  position: absolute; right: 14px; top: 12px; width: 38px; height: 38px; padding: 0; border-radius: 50%; font-size: 22px;
}
.location-hero { padding-right: 44px; }
.location-hero h2 { font-size: 28px; margin: 8px 0 4px; }
.location-hero p { color: var(--muted); margin: 0 0 18px; }
.classification { display: inline-block; color: var(--amber); font-size: 10px; letter-spacing: .12em; font-weight: 900; }
.sheet-actions { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 7px; margin-bottom: 14px; }
.sheet-actions button { padding: 10px 7px; font-size: 11px; }
.content-tabs { overflow-x: auto; }
.content-tabs button { min-width: 104px; font-size: 11px; }
.location-content { min-height: 170px; padding: 18px 4px; line-height: 1.65; color: #d6e1dc; white-space: pre-wrap; }
.location-content .layer-label {
  display: block; margin-bottom: 12px; padding: 8px 10px; border-left: 3px solid var(--moss);
  background: rgba(142,201,163,.08); color: var(--moss); font-size: 10px; letter-spacing: .1em; font-weight: 900;
}
.story-card { border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin-bottom: 10px; background: rgba(255,255,255,.035); }
.story-card h3 { margin: 0 0 6px; font-size: 16px; }
.story-card small { color: var(--muted); }

.panel-page {
  position: absolute; z-index: 1050; inset: 0; overflow-y: auto; padding: calc(78px + var(--safe-top)) 20px calc(100px + var(--safe-bottom));
  background: radial-gradient(circle at 50% 0, #163329, #06100d 58%);
}
.panel-page h2 { font-size: 34px; margin: 0 0 22px; }
.profile-rune { margin: 18px 0 28px; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 28px; }
.stat-card { border: 1px solid var(--line); border-radius: 18px; padding: 16px; background: rgba(255,255,255,.035); }
.stat-card strong { display: block; font-size: 24px; }
.stat-card span { color: var(--muted); font-size: 12px; }
.journal-card { border: 1px solid var(--line); border-radius: 18px; padding: 18px; background: rgba(255,255,255,.035); margin: 12px 0; }
.journal-card p { color: var(--muted); line-height: 1.55; }

dialog { width: min(92vw, 520px); max-height: 90dvh; padding: 0; border: 1px solid var(--line); border-radius: 24px; background: var(--panel-2); color: var(--ink); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(5px); }
.dialog-card { position: relative; display: grid; gap: 13px; padding: 28px 20px 22px; overflow-y: auto; max-height: 90dvh; }
.dialog-card h2 { margin: 0; }
.check-label { display: flex; align-items: center; gap: 8px; }
.check-label input { width: auto; }
.community-label { margin: 3px 0; }

.toast {
  position: fixed; z-index: 5000; left: 50%; bottom: calc(92px + var(--safe-bottom)); transform: translateX(-50%);
  max-width: min(90vw, 440px); padding: 12px 16px; border-radius: 14px; background: #e1f2e8; color: #07100e;
  box-shadow: var(--shadow); font-weight: 800; text-align: center; animation: toastIn .2s ease-out;
}
@keyframes toastIn { from { transform: translate(-50%, 20px); opacity: 0; } }

/* Admin */
.admin-body { min-height: 100vh; background: linear-gradient(145deg, #07100e, #0d1c18); }
.admin-header {
  position: sticky; top: 0; z-index: 100; display: flex; justify-content: space-between; align-items: center;
  padding: 18px clamp(16px, 4vw, 50px); background: rgba(5,13,11,.9); border-bottom: 1px solid var(--line); backdrop-filter: blur(16px);
}
.admin-header h1 { margin: 0; font-size: 25px; }
.admin-header a { text-decoration: none; font-size: 13px; }
.admin-main { width: min(1280px, 94vw); margin: 24px auto 80px; }
.dashboard-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.dashboard-card { padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.035); }
.dashboard-card strong { display: block; font-size: 30px; }
.dashboard-card span { color: var(--muted); font-size: 12px; }
.admin-tabs { margin: 22px 0; overflow-x: auto; }
.admin-tabs button { min-width: 120px; white-space: nowrap; }
.admin-section { border: 1px solid var(--line); border-radius: 22px; padding: clamp(16px, 3vw, 28px); background: rgba(5,15,12,.72); }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.section-head h2 { margin: 0 0 18px; }
.admin-form { padding: 18px; margin: 0 0 20px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.025); }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.admin-list { display: grid; gap: 10px; }
.admin-row {
  display: grid; grid-template-columns: minmax(180px, 1.2fr) minmax(180px, 2fr) auto;
  align-items: center; gap: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255,255,255,.025);
}
.admin-row h3 { margin: 0 0 3px; font-size: 15px; }
.admin-row p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.admin-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.admin-actions button { padding: 8px 10px; font-size: 11px; }
.status-pill { display: inline-block; padding: 3px 7px; border-radius: 999px; background: rgba(142,201,163,.12); color: var(--moss); font-size: 10px; }
.status-pill.pending { color: var(--amber); background: rgba(221,185,120,.12); }
.status-pill.rejected, .status-pill.hidden { color: #e99a9a; background: rgba(217,120,120,.12); }
.switch-row { display: flex; align-items: center; gap: 10px; }
.switch-row input { width: 20px; height: 20px; }
.codeish { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }

@media (max-width: 760px) {
  .sheet-actions { grid-template-columns: 1fr 1fr; }
  .sheet-actions .primary { grid-column: 1 / -1; }
  .dashboard-cards { grid-template-columns: repeat(2, 1fr); }
  .admin-row { grid-template-columns: 1fr; }
  .admin-actions { justify-content: flex-start; }
  .form-grid { grid-template-columns: 1fr; }
}
@media (min-width: 900px) {
  .bottom-sheet { left: 20px; right: auto; width: 460px; bottom: 88px; border-radius: 26px; padding-bottom: 24px; }
  .bottom-nav { left: 50%; right: auto; width: 500px; transform: translateX(-50%); }
  .panel-page { left: auto; width: 430px; border-left: 1px solid var(--line); }
}
