/* ============================================================================
   Shadowridge – UI (Hotbar: fixed button size + auto 1×10 / 2×5 + docked tooltip)
   ========================================================================== */

:root{
  --bg0:#0f0e0c;
  --bg1:#171512;

  --ink:#f2ead7;
  --muted:#b9b0a0;

  --gold:#d2a24a;
  --accent:#c84b4b;

  --line:rgba(210,162,74,.25);
  --shadow:rgba(0,0,0,.35);
  --radius:16px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

*{ box-sizing:border-box; }
html,body{ height:100%; margin:0; }

body{
  background:
    radial-gradient(1200px 700px at 50% 20%, #1f1a14 0%, var(--bg0) 60%),
    radial-gradient(900px 500px at 20% 80%, rgba(210,162,74,.06), transparent 60%),
    radial-gradient(900px 500px at 80% 80%, rgba(200,75,75,.05), transparent 60%);
  color:var(--ink);
  font-family: "MedievalSharp", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  overflow:hidden;
}

.app{
  height:100%;
  display:grid;
  grid-template-rows: auto 1fr;
  gap:10px;
  padding:
    calc(10px + var(--safe-top))
    calc(10px + var(--safe-right))
    calc(10px + var(--safe-bottom))
    calc(10px + var(--safe-left));
}

/* Header */
.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:12px 14px;
  border:1px solid var(--line);
  border-radius:var(--radius);
  background: linear-gradient(180deg, rgba(30,24,18,.90), rgba(14,12,10,.88));
  box-shadow: 0 12px 30px var(--shadow);
  position:relative;
  overflow:hidden;
}
.topbar::before{
  content:"";
  position:absolute;
  inset:-40px;
  background: repeating-linear-gradient(35deg, rgba(255,255,255,.03) 0 1px, transparent 1px 10px);
  opacity:.20;
  pointer-events:none;
}

.title__main{
  font-family:"Cinzel", serif;
  font-weight:700;
  font-size:20px;
  letter-spacing:.6px;
  text-shadow: 0 2px 0 rgba(0,0,0,.35);
}
.title__sub{
  color:var(--muted);
  font-size:12px;
  margin-top:2px;
}

.topbar__hint{
  color:var(--muted);
  font-size:12px;
  display:flex;
  gap:6px;
  align-items:center;
}
.kbd{
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size:11px;
  padding:2px 6px;
  border-radius:8px;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.25);
  color: var(--ink);
}

/* Stage / Map */
.stage{ min-height:0; }
.stage__map{
  min-height:0;
  display:grid;
  grid-template-rows: 1fr auto auto;
  gap:10px;
}

.canvasWrap{
  position:relative;
  border:1px solid var(--line);
  border-radius:var(--radius);
  background:
    linear-gradient(180deg, rgba(0,0,0,.22), rgba(0,0,0,.45)),
    radial-gradient(900px 500px at 50% 30%, rgba(210,162,74,.08), transparent 60%);
  box-shadow: 0 12px 30px var(--shadow);
  overflow:hidden;
  min-height:0;
}

#map{ width:100%; height:100%; display:block; }

.statusbar{
  border:1px solid var(--line);
  border-radius:var(--radius);
  background: rgba(0,0,0,.25);
  padding:8px 10px;
}
.statusbar__text{ color:var(--muted); font-size:12px; }

/* HUD container */
.hud{ pointer-events:none; }

/* Panels */
.hudPanel{
  pointer-events:auto;
  border-radius:18px;
  overflow:hidden;
  backdrop-filter: blur(3px);

  background: linear-gradient(180deg, rgba(32,26,20,.92), rgba(12,10,8,.80));
  border:1px solid rgba(210,162,74,.30);
  box-shadow:
    0 18px 45px rgba(0,0,0,.45),
    inset 0 1px 0 rgba(255,255,255,.06),
    inset 0 -1px 0 rgba(0,0,0,.35);

  width: var(--w, 320px);
  height: var(--h, 240px);
  position:relative;
}
.hudPanel::before{
  content:"";
  position:absolute;
  inset:0;
  pointer-events:none;
  opacity:.55;
  background:
    radial-gradient(12px 12px at 14px 14px, rgba(210,162,74,.55), transparent 70%),
    radial-gradient(12px 12px at calc(100% - 14px) 14px, rgba(210,162,74,.55), transparent 70%),
    radial-gradient(12px 12px at 14px calc(100% - 14px), rgba(210,162,74,.35), transparent 70%),
    radial-gradient(12px 12px at calc(100% - 14px) calc(100% - 14px), rgba(210,162,74,.35), transparent 70%),
    repeating-linear-gradient(35deg, rgba(255,255,255,.03) 0 1px, transparent 1px 10px);
}

.hudPanel__titlebar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:10px 12px;
  border-bottom:1px solid rgba(210,162,74,.18);
  cursor: grab;
  user-select:none;
  background: linear-gradient(180deg, rgba(0,0,0,.18), rgba(0,0,0,0));
}

.hudPanel__title{
  font-family:"Cinzel", serif;
  font-weight:700;
  letter-spacing:.3px;
  text-shadow: 0 2px 0 rgba(0,0,0,.35);
}
.logTitle{
  font-family:"Uncial Antiqua", serif;
  font-weight:400;
  letter-spacing:.5px;
}

.hudPanel__actions{
  display:flex;
  align-items:center;
  gap:8px;
}

.hudBtn{
  width:30px;
  height:26px;
  display:grid;
  place-items:center;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.25);
  color: var(--ink);
  border-radius:10px;
  cursor:pointer;
  font-family: inherit;
  line-height:1;
}
.hudBtn:hover{
  border-color: rgba(210,162,74,.40);
  background: rgba(210,162,74,.12);
}

/* Tiny button for hotbar grip */
.hudBtn--tiny{
  width:26px;
  height:20px;
  border-radius:9px;
  font-size:12px;
}

.hudPanel__body{
  padding:10px 12px;
  height: calc(100% - 44px);
  overflow:auto;
  color: var(--muted);
  font-size:12px;
}

.logBody{ font-size:12px; }
.logLine{ padding:2px 0; border-bottom:1px dashed rgba(255,255,255,.08); }

.hudPanel__resize{
  position:absolute;
  right:6px;
  bottom:6px;
  width:18px;
  height:18px;
  border-right:2px solid rgba(242,234,215,.55);
  border-bottom:2px solid rgba(242,234,215,.55);
  border-radius:3px;
  cursor:nwse-resize;
  opacity:.75;
}
.hudPanel__resize:hover{ opacity:1; }

.hudPanel.is-active{
  border-color: rgba(210,162,74,.55);
  box-shadow:
    0 22px 60px rgba(0,0,0,.55),
    inset 0 1px 0 rgba(255,255,255,.08),
    inset 0 -1px 0 rgba(0,0,0,.45);
}

/* Collapse as mini-bar */
@media (min-width: 981px){
  .hudPanel.is-collapsed{
    height: 46px !important;
    min-height: 46px;
  }
  .hudPanel.is-collapsed .hudPanel__body{ display:none; }
  .hudPanel.is-collapsed .hudPanel__resize{ display:none; }
  .hudPanel.is-collapsed .hudPanel__titlebar{ border-bottom:none; }
}

/* Docking Guides (used by panels) */
.dockGuides{
  position:absolute;
  inset:0;
  pointer-events:none;
  z-index: 8000;
}
.dockGuideLine{
  position:absolute;
  opacity:0;
  transition: opacity .06s linear;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.35));
}
.dockGuideLine.is-on{ opacity:1; }
.dockGuideLine--v{
  top:0; bottom:0;
  width:2px;
  background: linear-gradient(180deg, transparent, rgba(210,162,74,.85), transparent);
}
.dockGuideLine--h{
  left:0; right:0;
  height:2px;
  background: linear-gradient(90deg, transparent, rgba(210,162,74,.85), transparent);
}

/* =========================
   HOTBAR (NO TITLE)
   ========================= */
.hudPanel--hotbar .hudPanel__titlebar--gripOnly{
  padding:0;
  height:14px;
  border-bottom:none;
  background: transparent;
}
.hudPanel--hotbar .hudPanel__actions--gripOnly{
  position:absolute;
  top:6px;
  right:8px;
}

/* Hotbar body height is full (no header) */
.hudPanel--hotbar .hudPanel__body{
  height: calc(100% - 14px);
  padding:10px 10px 12px 10px;
  overflow: visible;
}

.hotbarWrap{
  position:relative;
  border:1px solid rgba(210,162,74,.18);
  border-radius:14px;
  background: rgba(0,0,0,.18);
  padding:10px;
  overflow:auto;
}

/* Slot size: good desktop + mobile */
.hotbarSlots{
  --slot: 52px;
  --gap: 10px;

  display:grid;
  gap: var(--gap);
  justify-content:center;
  align-content:center;
}

/* Mode A: 1 row × 10 */
.hotbarSlots.is-row10{
  grid-template-columns: repeat(10, var(--slot));
}

/* Mode B: 2 rows × 5 */
.hotbarSlots.is-grid2x5{
  grid-template-columns: repeat(5, var(--slot));
  grid-auto-rows: var(--slot);
}

/* Slots fixed size */
.hotbarSlot{
  width: var(--slot);
  height: var(--slot);
  position:relative;
  border-radius:14px;
  border:1px solid rgba(210,162,74,.28);
  background:
    radial-gradient(55px 40px at 35% 30%, rgba(255,255,255,.06), transparent 60%),
    linear-gradient(180deg, rgba(0,0,0,.18), rgba(0,0,0,.45));
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.06),
    inset 0 -1px 0 rgba(0,0,0,.45);
  cursor:pointer;
  user-select:none;
  outline:none;
  touch-action: manipulation;
}

.hotbarSlot:hover{ border-color: rgba(210,162,74,.48); }

.hotbarSlot.is-selected{
  border-color: rgba(210,162,74,.70);
  box-shadow:
    0 8px 22px rgba(0,0,0,.35),
    inset 0 1px 0 rgba(255,255,255,.08),
    inset 0 -1px 0 rgba(0,0,0,.55);
}

.hotbarSlot.is-disabled{ opacity:.65; filter:saturate(.85); }
.hotbarSlot.is-disabled:hover{ border-color: rgba(210,162,74,.28); cursor:not-allowed; }

.hotbarKey{
  position:absolute;
  left:7px;
  top:6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size:10px;
  color: rgba(242,234,215,.80);
  background: rgba(0,0,0,.28);
  border:1px solid rgba(255,255,255,.12);
  border-radius:999px;
  padding:1px 6px;
}

.hotbarIcon{
  position:absolute;
  inset:0;
  display:grid;
  place-items:center;
}
.hotbarIcon::before{
  content:"";
  width:24px;
  height:24px;
  border-radius:10px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(210,162,74,.14);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}

/* Icon variants */
.hotbarSlot[data-icon="sword"] .hotbarIcon::before{
  background:
    linear-gradient(45deg, rgba(255,255,255,.10), rgba(0,0,0,.35)),
    linear-gradient(180deg, rgba(210,162,74,.35), rgba(210,162,74,.08));
  border-color: rgba(210,162,74,.35);
}
.hotbarSlot[data-icon="shield"] .hotbarIcon::before{
  background:
    radial-gradient(14px 14px at 50% 35%, rgba(255,255,255,.10), transparent 65%),
    linear-gradient(180deg, rgba(140,170,190,.22), rgba(0,0,0,.45));
  border-color: rgba(140,170,190,.35);
}
.hotbarSlot[data-icon="potion"] .hotbarIcon::before{
  background:
    radial-gradient(12px 12px at 50% 35%, rgba(255,255,255,.14), transparent 65%),
    linear-gradient(180deg, rgba(200,75,75,.26), rgba(0,0,0,.45));
  border-color: rgba(200,75,75,.35);
}
.hotbarSlot[data-icon="spell"] .hotbarIcon::before{
  background:
    radial-gradient(18px 18px at 50% 45%, rgba(120,160,255,.18), transparent 70%),
    linear-gradient(180deg, rgba(90,120,255,.16), rgba(0,0,0,.45));
  border-color: rgba(90,120,255,.35);
}
.hotbarSlot[data-icon="boot"] .hotbarIcon::before{
  background:
    radial-gradient(18px 18px at 50% 45%, rgba(210,162,74,.14), transparent 70%),
    linear-gradient(180deg, rgba(210,162,74,.10), rgba(0,0,0,.45));
  border-color: rgba(210,162,74,.28);
}
.hotbarSlot[data-icon="lantern"] .hotbarIcon::before{
  background:
    radial-gradient(12px 12px at 50% 40%, rgba(255,210,120,.22), transparent 70%),
    linear-gradient(180deg, rgba(255,210,120,.12), rgba(0,0,0,.45));
  border-color: rgba(255,210,120,.32);
}

/* Cooldown overlay (kept) */
.hotbarOverlay{
  position:absolute;
  inset:0;
  border-radius:14px;
  pointer-events:none;
  display:none;
}
.hotbarCooldownShade{
  position:absolute;
  inset:0;
  border-radius:14px;
  background: rgba(0,0,0,.42);
}
.hotbarCooldownRing{
  position:absolute;
  inset:6px;
  border-radius:12px;
  background:
    conic-gradient(
      rgba(210,162,74,.88) 0deg var(--cdAngle, 0deg),
      rgba(0,0,0,0) var(--cdAngle, 0deg) 360deg
    );
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.55));
}
.hotbarCooldownInner{
  position:absolute;
  inset:9px;
  border-radius:10px;
  background: rgba(0,0,0,.38);
}
.hotbarCooldownText{
  position:absolute;
  inset:0;
  display:grid;
  place-items:center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight:700;
  font-size:14px;
  color: rgba(242,234,215,.92);
  text-shadow: 0 2px 0 rgba(0,0,0,.55);
}
.hotbarSlot.is-cooldown .hotbarOverlay{ display:block; }

/* Charges badge */
.hotbarCharges{
  position:absolute;
  right:7px;
  bottom:7px;
  min-width: 22px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  display:none;
  align-items:center;
  justify-content:center;

  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size:10px;
  color: rgba(242,234,215,.90);

  background: rgba(0,0,0,.35);
  border:1px solid rgba(255,255,255,.12);
}
.hotbarSlot.has-charges .hotbarCharges{ display:flex; }

/* Tooltip (fixed in body; never clipped) */
.hotbarTooltip{
  position:fixed;
  min-width: 220px;
  max-width: 340px;
  padding:10px 12px;
  border-radius:14px;
  border:1px solid rgba(210,162,74,.35);
  background: linear-gradient(180deg, rgba(20,16,12,.95), rgba(10,8,6,.92));
  box-shadow: 0 18px 45px rgba(0,0,0,.55);
  pointer-events:none;
  opacity:0;
  transform: translate3d(0, 6px, 0);
  transition: opacity .08s linear, transform .08s ease;
  z-index: 9999;
}
.hotbarTooltip.is-on{
  opacity:1;
  transform: translate3d(0, 0, 0);
}

.hotbarTooltip__title{
  font-family:"Cinzel", serif;
  font-weight:700;
  color: var(--ink);
  margin-bottom:4px;
}
.hotbarTooltip__desc{
  color: var(--muted);
  font-size:12px;
  margin-bottom:8px;
}
.hotbarTooltip__meta{
  display:flex;
  flex-wrap:wrap;
  gap:6px;
}
.hotbarPill{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:4px 8px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.22);
  color: rgba(242,234,215,.82);
  font-size:11px;
}
.hotbarPill strong{ color: rgba(242,234,215,.92); font-weight:700; }
.hotbarPill--bad{ border-color: rgba(200,75,75,.35); background: rgba(200,75,75,.10); }
.hotbarPill--cd{ border-color: rgba(210,162,74,.30); background: rgba(210,162,74,.10); }
.hotbarPill--charges{ border-color: rgba(140,170,190,.30); background: rgba(140,170,190,.10); }

/* Desktop overlay positioning */
@media (min-width: 981px){
  .canvasWrap{ height: 100%; min-height: 540px; }
  .hud{
    position:absolute;
    left:0; top:0; right:0; bottom:0;
    pointer-events:none;
  }
  .hudPanel{
    position:absolute;
    transform: translate3d(var(--x, 18px), var(--y, 18px), 0);
  }
  .mobileTabs{ display:none; }
  .mobileOverlay{ display:none; }
}

/* Mobile */
@media (max-width: 980px){
  body{ overflow:auto; }
  .app{ overflow:auto; height:auto; }

  .canvasWrap{ height: 58vh; }

  .hud{
    position:absolute;
    left:0; top:0; right:0; bottom:0;
    pointer-events:auto;
    z-index: 9050;
  }

  .hudPanel{ display:none; }

  .mobileTabs{
    display:flex;
    gap:10px;
    justify-content:space-between;

    border:1px solid var(--line);
    border-radius:var(--radius);
    background: rgba(0,0,0,.25);
    padding:10px;
    padding-bottom: calc(10px + var(--safe-bottom));
  }

  .mobileTabBtn{
    flex:1;
    border:1px solid rgba(255,255,255,.14);
    background: rgba(0,0,0,.25);
    color: var(--ink);
    border-radius:14px;
    padding:10px 10px;
    cursor:pointer;
    font-family:"Cinzel", serif;
    font-weight:700;
    letter-spacing:.2px;
    font-size:12px;
  }
  .mobileTabBtn:hover{
    border-color: rgba(210,162,74,.35);
    background: rgba(210,162,74,.12);
  }

  .mobileOverlay{
    position:fixed;
    inset:0;
    display:none;
    background: rgba(0,0,0,.55);
    z-index: 9000;
  }
  .mobileOverlay.is-open{ display:block; }

  .mobileClose{
    position:absolute;
    top: calc(12px + var(--safe-top));
    right: calc(12px + var(--safe-right));
    border:1px solid rgba(255,255,255,.18);
    background: rgba(0,0,0,.35);
    color: var(--ink);
    border-radius:12px;
    padding:10px 12px;
    font-size:14px;
    cursor:pointer;
  }

  .hudPanel.is-mobile-open{
    display:block;
    position:fixed;
    left: calc(12px + var(--safe-left));
    right: calc(12px + var(--safe-right));
    top: calc(56px + var(--safe-top));
    bottom: calc(12px + var(--safe-bottom));
    width:auto !important;
    height:auto !important;
    transform:none !important;
    z-index: 9100;
    pointer-events:auto;
    touch-action: manipulation;
  }

  .hudPanel.is-mobile-open .hudPanel__resize{ display:none; }
  .hudPanel.is-mobile-open .hudPanel__titlebar{ cursor: default; }

  .dockGuides{ display:none; }

  /* Mobile: Buttons leicht größer */
  .hotbarSlots{ --slot: 56px; --gap: 12px; }
}

.muted{ color: var(--muted); }
