:root {
    color-scheme: dark;
    --ink: #f3e6c9;
    --muted: #b9aa8f;
    --gold: #d3a84a;
    --gold-bright: #f3d77b;
    --panel: rgba(24, 17, 11, 0.96);
    --panel-soft: rgba(35, 25, 16, 0.9);
    --border: #654b2d;
    --shadow: rgba(0, 0, 0, 0.72);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: #080705;
    color: var(--ink);
    font-family: Verdana, Geneva, sans-serif;
}

button, input { font: inherit; }
button { color: inherit; }

.atlas-shell {
    display: grid;
    grid-template-columns: 310px minmax(0, 1fr);
    grid-template-rows: 70px minmax(0, 1fr);
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 70% 30%, #251a10 0, #090806 58%);
}

.topbar {
    z-index: 30;
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 310px 1fr auto;
    align-items: center;
    min-height: 70px;
    padding: 0 16px 0 22px;
    border-bottom: 1px solid #70512e;
    background:
        linear-gradient(180deg, rgba(72, 48, 26, .98), rgba(24, 16, 10, .99)),
        repeating-linear-gradient(90deg, transparent 0 42px, rgba(255,255,255,.025) 43px 44px);
    box-shadow: 0 6px 22px var(--shadow);
}

.brand { display: flex; flex-direction: column; line-height: 1.05; }
.brand-kicker { color: var(--gold); font-size: 10px; font-weight: 700; letter-spacing: 2px; }
.brand strong { margin-top: 5px; font-family: Georgia, serif; font-size: 23px; color: #fff2cd; text-shadow: 0 2px 2px #000; }

.floor-switcher {
    justify-self: center;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px;
    border: 1px solid #6f5332;
    border-radius: 6px;
    background: rgba(10, 8, 6, .52);
}

.floor-switcher span { display: flex; min-width: 58px; flex-direction: column; text-align: center; line-height: 1; }
.floor-switcher small { color: #a99473; font-size: 8px; letter-spacing: 1.4px; }
.floor-switcher strong { margin-top: 4px; color: var(--gold-bright); font-size: 19px; }

.topbar button, .floor-grid button, .hunt-navigation button, .map-error button {
    border: 1px solid #725536;
    border-radius: 4px;
    background: linear-gradient(#44311f, #20160e);
    box-shadow: inset 0 1px rgba(255,255,255,.08), 0 2px 4px rgba(0,0,0,.4);
    cursor: pointer;
}

.topbar button:hover, .floor-grid button:hover, .hunt-navigation button:hover, .map-error button:hover {
    border-color: #c2954b;
    background: linear-gradient(#5a4126, #291b10);
    color: #fff0b2;
}

.floor-switcher button, .top-actions button { width: 36px; height: 36px; font-size: 18px; }
.top-actions { display: flex; gap: 7px; }

.sidebar {
    z-index: 20;
    grid-column: 1;
    grid-row: 2;
    display: flex;
    min-height: 0;
    flex-direction: column;
    border-right: 1px solid var(--border);
    background:
        linear-gradient(rgba(25,17,11,.97), rgba(13,10,7,.98)),
        radial-gradient(circle at 20% 10%, #65431e, transparent 45%);
    box-shadow: 8px 0 24px var(--shadow);
}

.sidebar-heading { display: flex; align-items: center; justify-content: space-between; padding: 20px 20px 12px; }
.sidebar .icon-button { border: 1px solid #725536; border-radius: 4px; background: linear-gradient(#44311f, #20160e); cursor: pointer; }
.sidebar .icon-button:hover { border-color: #c2954b; color: #fff0b2; }
.eyebrow { color: var(--gold); font-size: 9px; font-weight: 700; letter-spacing: 1.8px; }
.sidebar h1 { margin: 5px 0 0; color: #f6e7c5; font-family: Georgia, serif; font-size: 22px; font-weight: 400; }

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 16px;
    padding: 0 12px;
    border: 1px solid #5d472d;
    border-radius: 5px;
    background: rgba(0,0,0,.38);
    color: #bc9556;
}

.search-box:focus-within { border-color: #c69b50; box-shadow: 0 0 0 2px rgba(198,155,80,.13); }
.search-box input { width: 100%; height: 42px; border: 0; outline: 0; background: transparent; color: #fff4d7; font-size: 12px; }
.search-box input::placeholder { color: #8f826e; }
.result-count { margin: 8px 19px 12px; color: #8e7f69; font-size: 10px; }

.selected-card {
    display: grid;
    grid-template-columns: 52px 1fr;
    align-items: center;
    gap: 10px;
    margin: 0 14px 12px;
    padding: 10px;
    border: 1px solid #725329;
    background: linear-gradient(135deg, rgba(110,73,28,.35), rgba(21,14,8,.65));
    box-shadow: inset 0 0 18px rgba(0,0,0,.42);
}

.selected-card img { width: 48px; height: 48px; object-fit: contain; image-rendering: pixelated; filter: drop-shadow(0 3px 3px #000); }
.selected-card div { min-width: 0; display: flex; flex-direction: column; }
.selected-card span { color: #aa8a54; font-size: 8px; letter-spacing: 1px; }
.selected-card strong { overflow: hidden; margin: 3px 0; color: #ffe39a; font-family: Georgia, serif; font-size: 17px; text-overflow: ellipsis; white-space: nowrap; }
.selected-card small { color: #ac9c82; font-size: 9px; }

.creature-list { min-height: 0; flex: 1; overflow-y: auto; scrollbar-color: #71522e #17100a; scrollbar-width: thin; }
.creature-row {
    display: grid;
    grid-template-columns: 42px 1fr auto;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 7px 16px;
    border: 0;
    border-top: 1px solid rgba(116,86,50,.18);
    background: transparent;
    text-align: left;
    cursor: pointer;
}
.creature-row:hover, .creature-row.active { background: linear-gradient(90deg, rgba(156,104,38,.32), rgba(89,58,25,.05)); }
.creature-row.active { box-shadow: inset 3px 0 #d0a552; }
.creature-row img { width: 38px; height: 38px; object-fit: contain; image-rendering: pixelated; filter: drop-shadow(0 2px 2px #000); }
.creature-row strong { display: block; color: #e8dcc2; font-size: 11px; font-weight: 400; }
.creature-row small { display: block; margin-top: 3px; color: #8e806b; font-size: 8px; }
.creature-row .count { color: #ad8d57; font-size: 9px; }
.empty-list { padding: 35px 22px; color: #9a8a72; font-size: 11px; line-height: 1.6; text-align: center; }

.hunt-navigation {
    display: grid;
    grid-template-columns: 38px 1fr 38px;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #5b4328;
    background: #130d08;
}
.hunt-navigation button { height: 36px; font-size: 24px; }
.hunt-navigation div { min-width: 0; display: flex; flex-direction: column; text-align: center; }
.hunt-navigation span { color: #f0d18c; font-size: 10px; }
.hunt-navigation small { margin-top: 4px; color: #8f816a; font-size: 8px; }

.map-stage { position: relative; grid-column: 2; grid-row: 2; min-width: 0; min-height: 0; overflow: hidden; background: #090806; }
#mapCanvas { display: block; width: 100%; height: 100%; cursor: grab; image-rendering: pixelated; touch-action: none; }
#mapCanvas.dragging { cursor: grabbing; }

.loading-card, .map-error {
    position: absolute;
    top: 50%; left: 50%;
    display: flex;
    min-width: 240px;
    transform: translate(-50%, -50%);
    flex-direction: column;
    align-items: center;
    gap: 9px;
    padding: 22px;
    border: 1px solid #6c4f2e;
    border-radius: 7px;
    background: rgba(20,14,9,.94);
    box-shadow: 0 14px 42px #000;
    text-align: center;
}
.loading-card strong, .map-error strong { font-family: Georgia, serif; font-size: 16px; }
.loading-card small { color: #9d8d74; font-size: 9px; }
.loader { width: 28px; height: 28px; border: 3px solid #40301f; border-top-color: #d2a64f; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.map-error button { margin-top: 5px; padding: 8px 14px; }

.floor-grid {
    position: absolute;
    top: 14px;
    left: 14px;
    display: grid;
    grid-template-columns: repeat(4, 31px);
    gap: 4px;
    padding: 7px;
    border: 1px solid #5e452a;
    border-radius: 5px;
    background: rgba(18,12,8,.86);
    box-shadow: 0 5px 15px rgba(0,0,0,.5);
}
.floor-grid button { position: relative; height: 27px; padding: 0; color: #bba989; font-size: 9px; }
.floor-grid button.active { border-color: #e0b85f; color: #ffe39c; box-shadow: inset 0 0 8px rgba(233,180,73,.28); }
.floor-grid button.has-hunt::after { content: ''; position: absolute; top: 3px; right: 3px; width: 4px; height: 4px; border-radius: 50%; background: #e0aa3b; }

.coordinate-panel {
    position: absolute;
    right: 14px;
    bottom: 14px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    padding: 8px 11px;
    border: 1px solid #594128;
    border-radius: 4px;
    background: rgba(14,10,7,.83);
    box-shadow: 0 4px 12px rgba(0,0,0,.45);
}
.coordinate-panel span { color: #ead9b7; font-size: 10px; }
.coordinate-panel small { color: #887b67; font-size: 8px; }
.map-badge { position: absolute; left: 14px; bottom: 14px; padding: 7px 10px; border: 1px solid #6a4f2f; border-radius: 4px; background: rgba(18,12,8,.86); color: #d6ab59; font-size: 9px; font-weight: 700; letter-spacing: 1.5px; }

.marker-tooltip { position: absolute; z-index: 12; max-width: 210px; padding: 7px 9px; border: 1px solid #806039; border-radius: 4px; background: rgba(18,12,8,.96); box-shadow: 0 5px 14px #000; color: #f6e4bd; font-size: 10px; line-height: 1.45; pointer-events: none; }
.marker-tooltip strong { color: #f3cd72; }

.sidebar-backdrop { display: none; }
.mobile-only { display: none; }

@media (max-width: 800px) {
    .atlas-shell { grid-template-columns: 1fr; grid-template-rows: 60px 1fr; }
    .topbar { grid-template-columns: auto 1fr auto; min-height: 60px; padding: 0 9px; gap: 8px; }
    .brand-kicker { display: none; }
    .brand strong { margin: 0; font-size: 16px; }
    .floor-switcher { justify-self: end; gap: 3px; }
    .floor-switcher button { width: 29px; height: 31px; }
    .floor-switcher span { min-width: 39px; }
    .top-actions { position: absolute; top: 72px; right: 10px; flex-direction: column; }
    .top-actions button { background: rgba(32,22,14,.9); }
    .mobile-only { display: inline-grid; place-items: center; }
    .icon-button { width: 36px; height: 36px; }
    .sidebar { position: fixed; top: 60px; bottom: 0; left: 0; width: min(88vw, 330px); transform: translateX(-105%); transition: transform .22s ease; }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop { position: fixed; z-index: 15; inset: 60px 0 0; background: rgba(0,0,0,.65); }
    .sidebar.open + .map-stage + .sidebar-backdrop { display: block; }
    .map-stage { grid-column: 1; grid-row: 2; }
    .floor-grid { top: 10px; left: 10px; grid-template-columns: repeat(4, 27px); }
    .coordinate-panel { right: 9px; bottom: 9px; }
    .coordinate-panel small { display: none; }
    .map-badge { display: none; }
}
