/* ── Reset & root ─────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg:           #080808;
  --surface:      #111111;
  --surface2:     #1a1a1a;
  --border:       #252525;
  --text:         #e2e2e2;
  --text-muted:   #6b6b6b;
  --green:        #4ade80;
  --green-dim:    #22c55e30;
  --accent:       #d4a96a;
  --header-h:     52px;
  --lb-w:         300px;
  --radius:       10px;
  --app-height:   100dvh;
}

html, body {
  height: var(--app-height);
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.ui-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: middle;
  flex: 0 0 auto;
}

img.ui-icon,
svg.ui-icon {
  display: block;
  object-fit: contain;
}

.ui-icon-14 { width: 14px; height: 14px; }
.ui-icon-16 { width: 16px; height: 16px; }
.ui-icon-18 { width: 18px; height: 18px; }
.ui-icon-20 { width: 20px; height: 20px; }
.ui-icon-22 { width: 22px; height: 22px; }
.ui-icon-24 { width: 24px; height: 24px; }
.ui-icon-26 { width: 26px; height: 26px; }

/* ── Header ───────────────────────────────────────────────────────────── */
#header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: rgba(10, 10, 10, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 20px;
  z-index: 100;
}

.menu-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
}

.menu-toggle:hover {
  background: #222;
  border-color: #333;
}

.menu-lines {
  width: 14px;
  height: 10px;
  display: inline-block;
  position: relative;
}

.menu-lines::before,
.menu-lines::after,
.menu-lines {
  border-top: 2px solid currentColor;
}

.menu-lines::before,
.menu-lines::after {
  content: '';
  position: absolute;
  left: 0;
  width: 14px;
}

.menu-lines::before { top: 3px; }
.menu-lines::after { top: 8px; }

.logo {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 5px;
  color: #fff;
  text-transform: uppercase;
  flex-shrink: 0;
}

.header-stats {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.stat-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.1;
}

.stat-chip.green .stat-num {
  color: var(--green);
}

.stat-num {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
}

.stat-label {
  font-size: 10px;
  font-weight: 400;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-divider {
  width: 1px;
  height: 26px;
  background: var(--border);
}

.lb-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.mute-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
  line-height: 1;
}

.mute-btn:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.18);
}

.mute-btn .ui-icon {
  width: 16px;
  height: 16px;
  opacity: 0.92;
}

.mute-btn .ui-icon svg {
  stroke-width: 1.85;
}

/* ── Info menu overlay ───────────────────────────────────────────────── */
#menu-panel,
#info-modal {
  background: rgba(16,16,16,0.96);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 22px 50px rgba(0,0,0,0.45);
  backdrop-filter: blur(10px);
}

#menu-panel {
  position: fixed;
  top: calc(var(--header-h) + 8px);
  left: 10px;
  height: calc(var(--app-height) - var(--header-h) - 16px);
  width: min(320px, calc(100vw - 20px));
  padding: 12px;
  z-index: 145;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(-120%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

#menu-panel.menu-open {
  transform: translateX(0);
}

.menu-head,
.info-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.menu-head strong,
.info-head h3 {
  font-size: 14px;
  color: #fff;
}

#menu-close,
#info-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
}

.menu-list {
  display: grid;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.menu-link {
  text-align: left;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.9);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.menu-link:hover,
.menu-link.active {
  background: rgba(212,169,106,0.16);
  border-color: rgba(212,169,106,0.35);
  color: #f1dcc0;
}

.menu-link-highlight {
  background: linear-gradient(135deg, rgba(212,169,106,0.24), rgba(212,169,106,0.11));
  border-color: rgba(212,169,106,0.45);
  color: #f3dfbc;
  box-shadow: inset 0 0 0 1px rgba(212,169,106,0.16), 0 8px 18px rgba(0,0,0,0.2);
}

.menu-link-highlight::before {
  content: '▶ ';
  color: rgba(255,220,165,0.95);
}

#info-modal {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  padding: 12px 14px;
}

#info-overlay {
  position: fixed;
  inset: 0;
  z-index: 225;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

#info-overlay.hidden { display: none !important; }

#info-body {
  color: rgba(255,255,255,0.82);
  font-size: 13px;
  line-height: 1.65;
  display: grid;
  gap: 10px;
}

#info-body ul {
  margin-left: 18px;
  display: grid;
  gap: 4px;
}

#info-body strong { color: #fff; }

.guide-steps {
  margin-left: 18px;
  display: grid;
  gap: 5px;
}

.guide-heading {
  margin: 4px 0 0;
  font-size: 13px;
  color: #f3dfbc;
  letter-spacing: 0.01em;
}

.guide-list {
  margin-left: 18px;
  display: grid;
  gap: 4px;
}

.guide-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.guide-shot {
  margin: 0;
  padding: 7px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(12,12,16,0.65);
}

.guide-shot-wide {
  margin-top: 2px;
}

.guide-shot img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 7px;
  border: 1px solid rgba(255,255,255,0.1);
  display: block;
}

.guide-shot figcaption {
  margin-top: 6px;
  font-size: 11px;
  color: rgba(255,255,255,0.72);
  line-height: 1.35;
}

.guide-tip {
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid rgba(212,169,106,0.3);
  border-radius: 10px;
  background: rgba(212,169,106,0.08);
}

.lb-toggle:hover {
  background: #222;
  border-color: #333;
}

/* ── Layout ───────────────────────────────────────────────────────────── */
#layout {
  display: flex;
  height: var(--app-height);
  padding-top: var(--header-h);
}

/* ── Map ──────────────────────────────────────────────────────────────── */
#map-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

#map {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

#hint {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  transition: opacity 0.5s;
}

.hint-inner {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.55);
  font-size: 12px;
  padding: 7px 14px;
  border-radius: 20px;
  white-space: nowrap;
}

#hint.hidden { opacity: 0; }

#coords {
  position: absolute;
  bottom: 10px;
  right: 14px;
  font-size: 11px;
  font-weight: 500;
  color: rgba(255,255,255,0.2);
  pointer-events: none;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

/* ── Leaderboard sidebar ──────────────────────────────────────────────── */
#leaderboard {
  width: var(--lb-w);
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.3s;
}

#leaderboard.lb-hidden {
  width: 0;
  opacity: 0;
  border-left: none;
}

.lb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.lb-header h2 {
  font-family: 'Playfair Display', serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #fff;
  white-space: nowrap;
}

#lb-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 4px;
  line-height: 1;
  transition: color 0.15s;
}

#lb-close:hover { color: var(--text); }

#lb-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.lb-empty {
  padding: 20px 18px;
  color: var(--text-muted);
  font-size: 13px;
}

.lb-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  transition: background 0.12s;
}

.lb-row:hover { background: var(--surface2); }

.lb-rank {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
}

.lb-rank.top { color: var(--accent); }

.lb-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-meta {
  text-align: right;
  flex-shrink: 0;
}

.lb-stones {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

.lb-pts {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}

.lb-sub {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
}

.lb-donated {
  display: block;
  font-size: 10px;
  color: var(--green);
}

/* ── Global hidden ────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Modal overlay ────────────────────────────────────────────────────── */
#overlay,
#buy-overlay,
#place-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  transition: opacity 0.2s;
}

#overlay.hidden,
#buy-overlay.hidden,
#place-overlay.hidden {
  display: none !important;
}

#modal,
#buy-modal,
#place-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px 28px 24px;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  box-shadow: 0 30px 80px rgba(0,0,0,0.7);
  animation: modal-in 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#buy-modal {
  max-width: 340px;
  padding: 18px 14px 14px;
}

#buy-modal .modal-stone-wrap,
#place-modal .modal-stone-wrap {
  align-self: center;
}

@keyframes modal-in {
  from { transform: scale(0.88) translateY(12px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-stone-wrap {
  margin-bottom: 10px;
}

#buy-close-x {
  align-self: flex-end;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.72);
  cursor: pointer;
  margin-bottom: 6px;
  line-height: 1;
}

#buy-close-x .ui-icon,
#place-close-x .ui-icon,
#admin-close .ui-icon,
.action-cancel-btn .ui-icon {
  width: 14px;
  height: 14px;
  opacity: 0.8;
}

#buy-close-x:hover {
  background: rgba(255,255,255,0.09);
  color: rgba(255,255,255,0.9);
}

  #place-close-x {
    align-self: flex-end;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.14);
    background: rgba(255,255,255,0.04);
    color: rgba(255,255,255,0.72);
    cursor: pointer;
    margin-bottom: 6px;
    line-height: 1;
  }

  #place-close-x:hover {
    background: rgba(255,255,255,0.09);
    color: rgba(255,255,255,0.9);
  }

#preview-canvas {
  display: block;
  filter: drop-shadow(0 8px 20px rgba(0,0,0,0.7));
}

.modal-title {
  font-family: 'Playfair Display', serif;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  text-align: center;
  margin-bottom: 2px;
  align-self: center;
}

.modal-coords {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 20px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
}

#name-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  margin-bottom: 14px;
}

#name-input::placeholder { color: var(--text-muted); }

#name-input:focus {
  border-color: rgba(255,255,255,0.25);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.04);
}

.btn-place {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #7c6f5a, #5a4f3c);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  letter-spacing: 0.02em;
  transition: filter 0.15s, transform 0.1s;
  margin-bottom: 12px;
}

.btn-place:hover  { filter: brightness(1.15); }
.btn-place:active { transform: scale(0.98); }

.btn-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.modal-note {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 14px;
  line-height: 1.5;
}

.modal-note strong { color: var(--green); }

.btn-cancel {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
  transition: color 0.15s;
}

.btn-cancel:hover { color: var(--text); }

/* ── Restart countdown banner ─────────────────────────────────────────── */
#restart-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 400;
  background: rgba(200, 60, 30, 0.95);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  padding: 8px 16px;
  letter-spacing: 0.03em;
  transform: translateY(-100%);
  opacity: 0;
  transition: transform 0.3s, opacity 0.3s;
  pointer-events: none;
  backdrop-filter: blur(6px);
}
#restart-banner.show {
  transform: translateY(0);
  opacity: 1;
}

/* ── Toast ────────────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(30,30,30,0.95);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 20px;
  border-radius: 30px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 300;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── War toast (top-left slide-in) ────────────────────────────────────── */
#war-toast {
  position: fixed;
  top: calc(var(--header-h) + 10px);
  left: 10px;
  z-index: 320;
  max-width: min(360px, calc(100vw - 20px));
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 120, 90, 0.45);
  background: linear-gradient(135deg, rgba(36, 14, 12, 0.96), rgba(22, 10, 10, 0.96));
  color: rgba(255, 235, 225, 0.96);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: 0.01em;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(9px);
  opacity: 0;
  transform: translateX(-120%) translateY(-2px);
  transition: opacity 0.2s ease, transform 0.26s ease;
  pointer-events: none;
  white-space: normal;
}

#war-toast.show {
  opacity: 1;
  transform: translateX(0) translateY(0);
  pointer-events: auto;
  cursor: pointer;
}

#war-toast.war-laser {
  border-color: rgba(255, 165, 90, 0.5);
  background: linear-gradient(135deg, rgba(38, 18, 8, 0.96), rgba(26, 14, 10, 0.96));
}

#war-toast.war-armed {
  border-color: rgba(255, 190, 90, 0.52);
  background: linear-gradient(135deg, rgba(40, 24, 8, 0.96), rgba(26, 18, 10, 0.96));
  color: rgba(255, 244, 220, 0.97);
}

@media (max-width: 720px) {
  #war-toast {
    left: 8px;
    top: calc(var(--header-h) + 8px);
    max-width: calc(100vw - 16px);
    font-size: 11px;
    padding: 9px 10px;
    border-radius: 10px;
  }
}

/* ── Scrollbar ────────────────────────────────────────────────────────── */
::-webkit-scrollbar        { width: 4px; }
::-webkit-scrollbar-track  { background: transparent; }
::-webkit-scrollbar-thumb  { background: var(--border); border-radius: 4px; }

/* ── Quantity selector ────────────────────────────────────────────────── */
.modal-sub {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.6;
  margin-bottom: 12px;
  align-self: center;
}

.qty-selector {
  --qty-h: 52px;
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: var(--qty-h);
}

.qty-btn {
  background: var(--surface2);
  border: none;
  color: var(--text);
  font-size: 20px;
  width: calc(var(--qty-h) * 0.92);
  min-width: 44px;
  height: var(--qty-h);
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}
.qty-btn:hover { background: #2a2a2a; }
.qty-btn:active { background: #333; }

.qty-display {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  height: var(--qty-h);
  min-height: var(--qty-h);
}

#qty-num {
  display: block;
  font-size: calc(var(--qty-h) * 0.62);
  font-weight: 700;
  color: #fff;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  transform: translateY(-0.02em);
}

.qty-label {
  display: none;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1;
}

.price-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

#price-total {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
}

.price-donation {
  font-size: 12px;
  color: var(--text-muted);
}

.price-donation strong { color: var(--green); }

/* ── Note textarea ────────────────────────────────────────────────────── */
#note-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  padding: 10px 14px;
  outline: none;
  resize: none;
  line-height: 1.5;
  transition: border-color 0.2s, box-shadow 0.2s;
  margin-bottom: 14px;
}
#note-input::placeholder { color: var(--text-muted); }
#note-input:focus {
  border-color: rgba(255,255,255,0.2);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.04);
}

/* ── Remaining badge ──────────────────────────────────────────────────── */
.remaining-badge {
  background: var(--green-dim);
  border: 1px solid rgba(74, 222, 128, 0.25);
  color: var(--green);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  text-align: center;
  margin-bottom: 12px;
  letter-spacing: 0.04em;
}

/* ── Session banner ───────────────────────────────────────────────────── */
#session-banner {
  position: fixed;
  top: calc(var(--header-h) + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #1c2b1c, #111e11);
  border: 1px solid rgba(74, 222, 128, 0.3);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 120;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  width: min(320px, calc(100vw - 24px));
  animation: slide-down 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slide-down {
  from { transform: translateX(-50%) translateY(-20px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0); opacity: 1; }
}

#session-banner.hidden { display: none; }

#session-dismiss {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 4px;
  line-height: 1;
  transition: color 0.15s;
}
#session-dismiss:hover { color: var(--text); }

.session-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 20px;
}

.session-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

#session-text {
  font-size: 13px;
  color: rgba(255,255,255,0.85);
  line-height: 1.4;
}

#session-text strong { color: var(--green); }

.session-stash-btn {
  background: rgba(74, 222, 128, 0.12);
  border: 1px solid rgba(74, 222, 128, 0.35);
  color: var(--green);
  border-radius: 8px;
  font-size: 12px;
  padding: 7px 10px;
  cursor: pointer;
  width: 100%;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s, border-color 0.15s;
}
.session-stash-btn:hover {
  background: rgba(74, 222, 128, 0.22);
  border-color: rgba(74, 222, 128, 0.6);
}

/* ── Stone info popup ─────────────────────────────────────────────────── */
#stone-popup {
  position: fixed;
  background: rgba(18, 18, 18, 0.97);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  pointer-events: none;
  z-index: 250;
  max-width: 220px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  transition: opacity 0.15s;
}
#stone-popup.hidden { opacity: 0; pointer-events: none; }

.popup-name {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 4px;
}
.popup-note {
  font-size: 12px;
  color: rgba(255,255,255,0.65);
  line-height: 1.5;
  margin-bottom: 6px;
  font-style: italic;
}
.popup-note:empty { display: none; }
.popup-meta {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

/* ── History ticker ───────────────────────────────────────────────────── */
#history-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 38px;
  background: linear-gradient(to top, rgba(6,6,6,0.97) 0%, rgba(12,12,12,0.90) 100%);
  border-top: 1px solid rgba(255,255,255,0.07);
  overflow: hidden;
  z-index: 90;
  backdrop-filter: blur(12px);
  /* fade edges */
  mask-image: linear-gradient(to right, transparent 0px, black 60px, black calc(100% - 60px), transparent 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0px, black 60px, black calc(100% - 60px), transparent 100%);
}

#history-track {
  display: flex;
  align-items: center;
  height: 100%;
  gap: 0;
  white-space: nowrap;
  will-change: transform;
}


.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 22px;
  font-size: 11.5px;
  color: rgba(255,255,255,0.38);
  flex-shrink: 0;
  position: relative;
}

/* dot separator */
.ticker-item::after {
  content: '·';
  position: absolute;
  right: 0;
  color: rgba(255,255,255,0.14);
  font-size: 16px;
  line-height: 1;
  top: 50%;
  transform: translateY(-50%);
}

.ticker-item .ti-name  {
  color: rgba(255,255,255,0.82);
  font-weight: 600;
  letter-spacing: 0.01em;
}
.ticker-item .ti-coords {
  color: rgba(255,255,255,0.28);
  font-size: 10px;
  letter-spacing: 0.02em;
}

/* per-type accent on icon */
.ticker-item .ui-icon { opacity: 0.75; filter: drop-shadow(0 0 3px currentColor); }

@keyframes ticker-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

/* ── Full history viewer (menu modal) ─────────────────────────────────── */
.history-note {
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: 12px;
}

.history-controls {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 10px;
}

.history-controls label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: rgba(255,255,255,0.74);
}

.history-controls select {
  background: rgba(18,18,24,0.9);
  color: rgba(255,255,255,0.9);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 8px;
  font-size: 12px;
}

.history-refresh-btn {
  white-space: nowrap;
  height: 34px;
}

.history-browser-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 44vh;
  overflow: auto;
  padding-right: 2px;
}

.history-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 9px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  background: rgba(12,12,16,0.72);
  font-size: 12px;
  color: rgba(255,255,255,0.85);
}

.history-row .ti-coords {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
}

.history-empty {
  color: var(--text-muted);
  font-size: 12px;
  padding: 8px 2px;
}

@media (max-width: 720px) {
  .history-controls {
    grid-template-columns: 1fr;
  }

  .history-refresh-btn {
    width: 100%;
  }
}

/* ── Responsive: mobile ───────────────────────────────────────────────── */
/* ── Shop section (inside buy modal) ─────────────────────────────────── */
.shop-divider {
  display: flex;
  align-items: center;
  margin: 10px 0 6px;
  gap: 10px;
  color: var(--text-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}
.shop-divider::before, .shop-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.shop-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,0.035);
  margin-bottom: 8px;
}
.shop-item-mystery {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}
.shop-item-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 2px;
  opacity: 0.86;
}
.shop-item-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}
.shop-item-name {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.92);
}
.shop-item-desc {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.4;
}
.shop-lock-info {
  font-size: 10px;
  color: rgba(255,180,60,0.7);
  margin-top: 1px;
}
.shop-item-btn {
  flex-shrink: 0;
  min-width: 66px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  transition: opacity 0.15s;
}
.shop-item-btn:hover:not(:disabled) { opacity: 0.85; }
.shop-item-btn.shop-locked {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.35);
  cursor: not-allowed;
}

/* ── Admin tools ─────────────────────────────────────────────────────── */
#admin-toggle {
  position: fixed;
  left: 14px;
  bottom: 50px;
  z-index: 130;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(14,14,14,0.9);
  color: rgba(255,255,255,0.82);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

#fullscreen-toggle {
  position: fixed;
  right: 14px;
  bottom: 50px;
  z-index: 131;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(14,14,14,0.9);
  color: rgba(255,255,255,0.86);
  border-radius: 999px;
  width: 44px;
  height: 44px;
  padding: 0;
  cursor: pointer;
  backdrop-filter: blur(8px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#fullscreen-toggle svg {
  width: 22px;
  height: 22px;
}

#fullscreen-toggle .icon-exit { display: none; }

#fullscreen-toggle.active {
  border-color: rgba(212,169,106,0.45);
  color: #f1dcc0;
}

#fullscreen-toggle.active .icon-enter { display: none; }
#fullscreen-toggle.active .icon-exit { display: block; }

#admin-panel {
  position: fixed;
  left: 14px;
  bottom: 86px;
  width: min(320px, calc(100vw - 28px));
  z-index: 135;
  background: rgba(16,16,16,0.96);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(0,0,0,0.48);
  padding: 14px 12px 12px;
  backdrop-filter: blur(10px);
}

#admin-panel.hidden { display: none !important; }

.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.admin-head strong {
  font-size: 14px;
  line-height: 1.15;
  color: #fff;
}

#admin-close {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.admin-note {
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.admin-btn {
  background: rgba(255,255,255,0.045);
  color: rgba(255,255,255,0.9);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 11px 9px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  line-height: 1.25;
}

.admin-btn:hover {
  background: rgba(255,255,255,0.09);
}

.admin-btn.active {
  border-color: rgba(255,120,90,0.55);
  background: rgba(255,80,40,0.14);
  color: #ffb199;
}

.admin-btn.danger {
  background: rgba(120,20,20,0.25);
  border-color: rgba(200,60,60,0.25);
}

.shop-item.shop-admin-preview {
  opacity: 0.9;
  pointer-events: auto;
  border-style: dashed;
}

/* ── Inventory Tray ───────────────────────────────────────────────────── */
#inventory-tray {
  position: fixed;
  bottom: 96px; /* above fullscreen-toggle (bottom: 42px + 44px height) */
  right: 14px;
  z-index: 135;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none; /* children opt-in */
}
#inventory-tray.tray-empty #tray-toggle { display: flex; }
#inventory-tray.tray-empty #tray-shelf  { display: flex; }

#tray-toggle {
  pointer-events: auto;
  width: 50px; height: 50px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(18,18,30,0.88);
  backdrop-filter: blur(14px);
  cursor: pointer;
  font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  box-shadow: 0 4px 16px rgba(0,0,0,0.45);
  transition: background 0.15s, transform 0.15s;
}
#tray-toggle:hover { background: rgba(40,40,60,0.95); transform: scale(1.07); }

#tray-badge {
  position: absolute;
  top: -3px; right: -3px;
  background: #e04020;
  color: #fff;
  font-size: 10px; font-weight: 700;
  border-radius: 50%;
  min-width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 2px;
  border: 2px solid rgba(10,10,20,0.9);
  line-height: 1;
}
#tray-badge.tray-badge-hidden { display: none; }

#tray-shelf {
  pointer-events: auto;
  display: flex;
  flex-direction: row;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(12,12,22,0.94);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 20px;
  backdrop-filter: blur(18px);
  box-shadow: 0 6px 28px rgba(0,0,0,0.55);
  transform-origin: bottom right;
  transition: opacity 0.18s, transform 0.18s;
}
#tray-shelf.tray-shelf-closed {
  opacity: 0;
  transform: scale(0.85) translateY(8px);
  pointer-events: none;
}

#tray-guest-hint {
  pointer-events: none;
  max-width: 280px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 185, 70, 0.35);
  background: rgba(255, 185, 70, 0.12);
  color: rgba(255, 232, 192, 0.95);
  font-size: 11px;
  line-height: 1.35;
  text-align: right;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
}

#tray-guest-hint.hidden {
  display: none !important;
}

#tray-shelf.tray-shelf-closed ~ #tray-guest-hint {
  display: none !important;
}

.tray-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 14px 8px;
  border-radius: 14px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  cursor: grab;
  user-select: none;
  transition: background 0.15s, transform 0.12s, border-color 0.15s;
  min-width: 62px;
}
.tray-card:hover  { background: rgba(255,255,255,0.13); transform: translateY(-3px); }
.tray-card:active { cursor: grabbing; transform: scale(0.94); }

.tray-card.tray-card-active {
  background: rgba(100,180,255,0.18);
  border-color: rgba(100,180,255,0.5);
  box-shadow: 0 0 14px rgba(100,180,255,0.25);
}
.tray-card.tray-card-active.type-bomb   { background: rgba(255,120,60,0.22); border-color: rgba(255,120,60,0.55); box-shadow: 0 0 14px rgba(255,100,40,0.3); }
.tray-card.tray-card-active.type-laser  { background: rgba(80,160,255,0.22); border-color: rgba(80,160,255,0.55); box-shadow: 0 0 14px rgba(80,160,255,0.3); }
.tray-card.tray-card-active.type-shield { background: rgba(60,200,120,0.22); border-color: rgba(60,200,120,0.55); box-shadow: 0 0 14px rgba(60,200,120,0.3); }

/* Shop-chip: item not owned */
.tray-card.tray-card-shop {
  cursor: pointer;
  border-style: dashed;
  border-color: rgba(255,255,255,0.22);
}
.tray-card.tray-card-shop:hover {
  transform: translateY(-3px);
  border-color: rgba(255,255,255,0.35);
}
.tray-card-empty-icon { opacity: 0.95; }
.tray-card-plus {
  font-size: 15px;
  font-weight: 700;
  color: #ffd37a;
  text-shadow: 0 0 8px rgba(255,185,70,0.7), 0 0 16px rgba(255,165,50,0.35);
  animation: trayPlusPulse 1.15s ease-in-out infinite;
  line-height: 1;
}

@keyframes trayPlusPulse {
  0%, 100% { transform: scale(1); opacity: 0.95; }
  50% { transform: scale(1.18); opacity: 1; }
}

.tray-card-emoji {
  width: 26px;
  height: 26px;
  line-height: 1;
}
.tray-card-count {
  font-size: 11px; font-weight: 700;
  color: rgba(255,255,255,0.75);
  background: rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 1px 6px;
}
.tray-card-label {
  font-size: 9px;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* drag ghost */
.drag-ghost {
  position: fixed;
  z-index: 9999;
  width: 36px;
  height: 36px;
  line-height: 1;
  pointer-events: none;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.6));
}
.drag-ghost .ui-icon { width: 100%; height: 100%; }
.drag-ghost.hidden { display: none; }

/* ── Item context menu ────────────────────────────────────────────────── */
#item-ctx {
  position: fixed;
  z-index: 200;
  min-width: 190px;
  background: rgba(10,10,22,0.97);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 16px;
  padding: 14px 16px 12px;
  backdrop-filter: blur(18px);
  box-shadow: 0 10px 36px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#item-ctx.hidden { display: none !important; }
.ctx-header {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ctx-emoji {
  width: 26px;
  height: 26px;
  line-height: 1;
}
.ctx-title {
  font-size: 14px;
  font-weight: 700;
  color: rgba(255,255,255,0.9);
}
.ctx-desc {
  margin: 0;
  font-size: 12px;
  color: rgba(255,255,255,0.45);
  line-height: 1.45;
}
.ctx-use-btn {
  padding: 9px 0;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.9);
  cursor: pointer;
  transition: background 0.15s;
  width: 100%;
}
.ctx-use-btn:hover { background: rgba(255,255,255,0.18); }
.ctx-close-btn {
  padding: 7px 0;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid rgba(255,255,255,0.08);
  background: transparent;
  color: rgba(255,255,255,0.3);
  cursor: pointer;
  width: 100%;
  transition: color 0.15s;
}
.ctx-close-btn:hover { color: rgba(255,255,255,0.6); }

/* ── Item action bar ──────────────────────────────────────────────────── */
#item-action-bar {
  position: fixed;
  bottom: 96px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 210;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 10px 18px;
  background: rgba(8,8,18,0.96);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 50px;
  backdrop-filter: blur(18px);
  box-shadow: 0 6px 28px rgba(0,0,0,0.55);
  white-space: nowrap;
}
#item-action-bar.hidden { display: none !important; }

.action-bar-label {
  font-size: 13px;
  color: rgba(255,255,255,0.75);
  margin-right: 2px;
}
.action-confirm-btn {
  padding: 8px 20px;
  border-radius: 50px;
  font-size: 13px;
  font-weight: 700;
  border: 1.5px solid rgba(255,80,20,0.75);
  background: linear-gradient(135deg, rgba(200,35,8,0.88), rgba(255,110,25,0.88));
  color: #fff;
  cursor: pointer;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
  box-shadow: 0 0 14px rgba(255,60,10,0.45);
  animation: action-pulse 1.4s ease-in-out infinite;
  transition: transform 0.1s;
}
.action-confirm-btn:hover  { transform: scale(1.05); }
.action-confirm-btn:active { transform: scale(0.96); animation: none; }
.action-confirm-btn:disabled { opacity: 0.55; animation: none; cursor: not-allowed; }
.action-confirm-btn.type-shield {
  border-color: rgba(60,200,120,0.7);
  background: linear-gradient(135deg, rgba(30,160,80,0.88), rgba(70,220,140,0.88));
  box-shadow: 0 0 14px rgba(50,200,100,0.4);
}
.action-confirm-btn.type-bomb {
  border-color: rgba(255,120,40,0.7);
  background: linear-gradient(135deg, rgba(200,80,10,0.88), rgba(255,140,40,0.88));
  box-shadow: 0 0 14px rgba(255,100,30,0.45);
}
@keyframes action-pulse {
  0%, 100% { box-shadow: 0 0 14px rgba(255,60,10,0.45); }
  50%       { box-shadow: 0 0 26px rgba(255,60,10,0.8); }
}
.action-cancel-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.45);
  cursor: pointer;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.action-cancel-btn:hover { background: rgba(255,255,255,0.14); color: rgba(255,255,255,0.8); }

@media (max-width: 640px) {
  :root { --header-h: 76px; }
  #header { padding: 4px 6px 6px; gap: 6px; }
  .logo { font-size: 13px; letter-spacing: 1px; }
  .header-stats { gap: 5px; }
  .stat-num  { font-size: 12px; }
  .stat-label {
    display: block;
    font-size: 8px;
    letter-spacing: 0;
    text-transform: none;
    white-space: nowrap;
  }
  .stat-divider { height: 16px; }
  .lb-toggle span { display: none; }
  .lb-toggle { padding: 6px 8px; }
  .menu-toggle span:last-child { display: none; }
  .menu-toggle { padding: 6px 8px; }

  #menu-panel {
    top: calc(var(--header-h) + 6px);
    left: 8px;
    height: calc(var(--app-height) - var(--header-h) - 12px);
    width: min(300px, calc(100vw - 16px));
  }

  #info-modal {
    width: calc(100vw - 16px);
    max-height: 70vh;
  }

  #leaderboard {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    z-index: 150;
    box-shadow: -10px 0 40px rgba(0,0,0,0.6);
  }

  #leaderboard.lb-hidden {
    transform: translateX(100%);
    width: var(--lb-w);
    opacity: 1;
  }

  #leaderboard {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s;
  }

  #buy-modal, #place-modal {
    padding: 14px 12px 12px;
    max-height: calc(100dvh - 22px);
    border-radius: 14px;
  }

  #buy-overlay,
  #place-overlay {
    align-items: flex-start;
    padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom));
    overflow-y: auto;
  }

  #buy-modal {
    max-width: 100%;
  }

  #buy-close-x {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
  }

  #buy-close-x .ui-icon,
  #place-close-x .ui-icon {
    width: 11px;
    height: 11px;
    opacity: 0.78;
  }

  .qty-selector {
    --qty-h: 50px;
    margin-bottom: 12px;
  }

  .qty-btn {
    width: calc(var(--qty-h) * 0.92);
    height: var(--qty-h);
    font-size: 18px;
  }

  .qty-display {
    height: var(--qty-h);
    min-height: var(--qty-h);
    padding: 0 4px;
  }

  #qty-num {
    font-size: calc(var(--qty-h) * 0.64);
    line-height: 1;
    transform: translateY(-0.01em);
  }

  .qty-label {
    display: none;
  }

  .shop-item {
    gap: 8px;
    padding: 7px;
  }

  .shop-item-icon {
    width: 16px;
    height: 16px;
  }

  .shop-item-name {
    font-size: 12px;
  }

  .shop-item-desc {
    font-size: 10px;
  }

  #admin-toggle {
    left: 10px;
    bottom: calc(env(safe-area-inset-bottom) + 48px);
  }

  #fullscreen-toggle {
    right: 10px;
    bottom: calc(env(safe-area-inset-bottom) + 48px);
    width: 40px;
    height: 40px;
  }

  #hint {
    bottom: calc(env(safe-area-inset-bottom) + 64px);
  }

  .hint-inner {
    font-size: 11px;
    padding: 6px 12px;
    max-width: calc(100vw - 22px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #coords {
    bottom: calc(env(safe-area-inset-bottom) + 50px);
  }

  #admin-panel {
    left: 10px;
    bottom: 78px;
    width: min(330px, calc(100vw - 20px));
    max-height: 56vh;
    overflow-y: auto;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  :root { --header-h: 40px; }

  #header {
    padding: 0 6px;
    gap: 6px;
  }

  .logo {
    font-size: 12px;
    letter-spacing: 1px;
  }

  .header-stats { gap: 4px; }

  .stat-num { font-size: 11px; }

  .stat-label {
    font-size: 7px;
    letter-spacing: 0;
    text-transform: none;
  }

  .stat-divider { height: 14px; }

  .lb-toggle,
  .menu-toggle {
    padding: 5px 7px;
  }

  .lb-toggle span,
  .menu-toggle span:last-child {
    display: none;
  }

  #session-banner {
    top: calc(var(--header-h) + 6px);
    padding: 7px 10px;
  }

  #menu-panel {
    top: calc(var(--header-h) + 4px);
    height: calc(var(--app-height) - var(--header-h) - 8px);
  }
}

/* ── Auth button in header ────────────────────────────────────────────── */
.auth-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.85);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s;
  white-space: nowrap;
  min-width: 88px;
  max-width: 132px;
  overflow: hidden;
  text-overflow: ellipsis;
  justify-content: center;
}
.auth-btn:hover { background: rgba(255,255,255,0.13); border-color: rgba(255,255,255,0.3); }
.auth-btn--logged-in { color: #7fe0b0; border-color: rgba(127,224,176,0.3); background: rgba(127,224,176,0.07); }
.auth-btn--logged-in:hover { background: rgba(127,224,176,0.12); }

.guest-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 185, 70, 0.42);
  background: rgba(255, 185, 70, 0.14);
  color: rgba(255, 220, 160, 0.95);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.guest-badge.hidden {
  display: none !important;
}

/* ── Auth overlay ─────────────────────────────────────────────────────── */
.auth-overlay {
  position: fixed; inset: 0; z-index: 700;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
}

/* ── Auth modal ───────────────────────────────────────────────────────── */
.auth-modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 710;
  width: min(420px, calc(100vw - 32px));
  background: #111;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  padding: 28px 28px 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.7);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.auth-modal.hidden { display: none; }

.auth-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
}
.auth-modal-header h2 {
  font-size: 20px; font-weight: 700; color: #fff; margin: 0;
}
.auth-modal-close {
  background: none; border: none; color: rgba(255,255,255,0.5);
  font-size: 22px; cursor: pointer; padding: 0 4px; line-height: 1;
  transition: color 0.15s;
}
.auth-modal-close:hover { color: #fff; }

.auth-modal-subtitle {
  margin: 0; font-size: 13px; color: rgba(255,255,255,0.5); line-height: 1.5;
}

.auth-field-row.hidden { display: none; }

.auth-check-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  color: rgba(255,255,255,0.72);
  line-height: 1.4;
}

.auth-check-label input[type="checkbox"] {
  margin-top: 2px;
  accent-color: #3dc98a;
}

.auth-label {
  font-size: 12px; font-weight: 600; color: rgba(255,255,255,0.7);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: -6px;
}
.auth-input {
  width: 100%; box-sizing: border-box;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 9px;
  color: #fff; font-size: 15px;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.15s;
}
.auth-input:focus { border-color: rgba(127,224,176,0.5); }
.auth-input::placeholder { color: rgba(255,255,255,0.3); }

.auth-error {
  font-size: 13px; color: #ff7070; background: rgba(255,80,80,0.1);
  border: 1px solid rgba(255,80,80,0.2); border-radius: 8px;
  padding: 8px 12px; margin: 0;
}
.auth-success {
  font-size: 13px; color: #7fe0b0; background: rgba(127,224,176,0.08);
  border: 1px solid rgba(127,224,176,0.2); border-radius: 8px;
  padding: 8px 12px; margin: 0;
}

.auth-submit {
  width: 100%; padding: 12px;
  background: linear-gradient(135deg, #7fe0b0 0%, #3dc98a 100%);
  color: #0a1f15; font-size: 15px; font-weight: 700;
  border: none; border-radius: 10px; cursor: pointer;
  transition: opacity 0.15s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.auth-submit:hover:not(:disabled) { opacity: 0.88; }
.auth-submit:disabled { opacity: 0.45; cursor: default; }

.auth-spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(10,31,21,0.4);
  border-top-color: #0a1f15;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.auth-switch { font-size: 13px; color: rgba(255,255,255,0.5); text-align: center; }
.auth-link {
  background: none; border: none; color: #7fe0b0;
  cursor: pointer; font-size: inherit; padding: 0; text-decoration: underline;
}
.auth-link:hover { color: #a8f0cc; }

.auth-divider {
  display: flex; align-items: center; gap: 10px;
  font-size: 11px; color: rgba(255,255,255,0.3);
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: rgba(255,255,255,0.1);
}

.auth-guest-btn {
  width: 100%; padding: 10px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.14);
  color: rgba(255,255,255,0.75);
  font-size: 14px; border-radius: 10px; cursor: pointer;
  transition: background 0.15s;
}
.auth-guest-btn:hover { background: rgba(255,255,255,0.1); }

.auth-guest-risks {
  font-size: 11px; color: rgba(255,255,255,0.38);
  line-height: 1.6; border-top: 1px solid rgba(255,255,255,0.07);
  padding-top: 10px; margin-top: -4px;
}
.auth-guest-risks strong { color: rgba(255,185,70,0.8); }

.auth-logout-btn {
  width: 100%; padding: 9px;
  background: rgba(255,70,70,0.08);
  border: 1px solid rgba(255,70,70,0.2);
  color: #ff9090; font-size: 13px;
  border-radius: 10px; cursor: pointer;
  transition: background 0.15s;
}
.auth-logout-btn:hover { background: rgba(255,70,70,0.14); }

/* ── Popup placed-by ──────────────────────────────────────────────────── */
.popup-placed-by {
  font-size: 11px;
  color: #7fe0b0;
  margin-bottom: 4px;
  font-style: normal;
}

.buy-guest-warning {
  margin: 8px 0 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 185, 70, 0.34);
  background: rgba(255, 185, 70, 0.08);
  color: rgba(255, 230, 190, 0.92);
  font-size: 12px;
  line-height: 1.45;
}

.buy-guest-warning strong {
  color: rgba(255, 200, 110, 0.98);
}

.buy-guest-warning.hidden {
  display: none !important;
}

@media (max-width: 640px) {
  #header {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr) auto auto;
    grid-template-rows: auto auto;
    align-items: center;
    row-gap: 4px;
  }

  .menu-toggle {
    grid-column: 1;
    grid-row: 1;
  }

  .logo {
    grid-column: 2;
    grid-row: 1;
  }

  .guest-badge {
    grid-column: 4;
    grid-row: 1;
    justify-self: end;
  }

  .auth-btn {
    grid-column: 5;
    grid-row: 1;
    justify-self: end;
  }

  .header-stats {
    grid-column: 1 / 4;
    grid-row: 2;
  }

  .header-stats {
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 1px;
  }

  .header-stats::-webkit-scrollbar {
    display: none;
  }

  .lb-toggle {
    grid-column: 4;
    grid-row: 2;
  }

  .mute-btn {
    grid-column: 5;
    grid-row: 2;
  }

  .auth-btn {
    min-width: 0;
    max-width: 92px;
    padding: 6px 10px;
    font-size: 12px;
  }

  .guest-badge {
    height: 28px;
    padding: 0 8px;
    font-size: 10px;
  }

  .auth-modal {
    width: calc(100vw - 18px);
    max-height: min(82vh, 720px);
    padding: 20px 16px 18px;
    overflow-y: auto;
    border-radius: 14px;
  }

  .auth-modal-header h2 {
    font-size: 18px;
  }

  .auth-modal-subtitle,
  .auth-guest-risks {
    font-size: 12px;
  }

  .auth-input,
  .auth-submit,
  .auth-guest-btn,
  .auth-logout-btn {
    font-size: 14px;
  }

  .buy-guest-warning {
    font-size: 11px;
    padding: 9px 10px;
  }

  #admin-toggle {
    bottom: 138px;
  }
}
