/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent:       #7cb342;
  --accent-glow:  rgba(124,179,66,0.55);
  --glass:        rgba(10,20,10,0.70);
  --glass-border: rgba(255,255,255,0.14);
  --text:         #e8f5e9;
  --muted:        #81c784;
  --radius:       16px;
  --font:         "Segoe UI", system-ui, sans-serif;
  --sky-top:      #5eb0d8;
  --sky-mid:      #9fd4ea;
  --sky-warm:     #d8ecc0;
  --meadow:       #2f6b3a;
  --meadow-deep:  #1a4024;
  --sun:          #ffe08a;

  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --hud-bottom-h: 120px;
  --chip: 48px;
  --chip-gap: 6px;
  --ui-pad: 12px;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  position: fixed;
  inset: 0;
  overflow: hidden;
  overscroll-behavior: none;
  overscroll-behavior-y: none;
  touch-action: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  font-family: var(--font);
  color: var(--text);
  background: var(--meadow-deep);
  cursor: crosshair;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

body.app-loading #scene,
body.app-loading .hud-top,
body.app-loading .overlay {
  visibility: hidden;
  pointer-events: none;
}

body, canvas, .hud-top, .hud-bottom, .hint-pill {
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ── Painted garden backdrop illustration ───────────────── */
.game-backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: #1a4024;
}

.game-backdrop__art {
  position: absolute;
  inset: -3%;
  background:
    url("../img/game_backdrop.webp") center / cover no-repeat;
  filter: saturate(1.05) contrast(1.02);
  animation: backdropDrift 28s ease-in-out infinite alternate;
  will-change: transform;
}

.game-backdrop__shade {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 78% 72% at 50% 45%, transparent 42%, rgba(8, 24, 12, 0.42) 100%),
    linear-gradient(180deg, rgba(10, 30, 40, 0.12) 0%, transparent 28%, transparent 72%, rgba(8, 22, 12, 0.28) 100%);
}

@keyframes backdropDrift {
  from { transform: scale(1.02) translate3d(-0.6%, 0, 0); }
  to   { transform: scale(1.06) translate3d(0.6%, -0.4%, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .game-backdrop__art { animation: none; }
}

/* ── Fullscreen canvas ──────────────────────────────────── */
#scene {
  position: fixed;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  background: transparent;
  touch-action: none;
  outline: none;
}

/* ── Top HUD (positioned over the playfield by JS) ──────── */
.hud-top {
  position: fixed;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: nowrap;
  box-sizing: border-box;
  padding: 6px 10px 8px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.72) 0%, rgba(0,0,0,0.28) 75%, transparent 100%);
  border-radius: 0 0 10px 10px;
  pointer-events: none;
  user-select: none;
  /* left / top / width set in JS to match the scene */
}

.hud-level {
  font-size: clamp(0.78rem, 2.4vw, 0.95rem);
  font-weight: 700;
  letter-spacing: 0.03em;
  text-shadow: 0 2px 8px rgba(0,0,0,0.9);
  flex: 0 1 clamp(110px, 20vw, 230px);
  max-width: 24%;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 8px;
  pointer-events: auto;
  flex-shrink: 0;
  max-width: 24%;
}

/* ── Center menu panel ──────────────────────────────────── */
.menu-scrim {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
body.menu-open .menu-scrim {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.menu-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 60;
  width: min(380px, calc(100vw - 24px - var(--sal) - var(--sar)));
  max-height: min(86dvh, calc(100dvh - 24px - var(--sat) - var(--sab)));
  padding: 18px 16px calc(20px + var(--sab));
  background: linear-gradient(165deg, rgba(18, 36, 20, 0.98) 0%, rgba(10, 22, 12, 0.98) 100%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.04);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  transform: translate(-50%, -46%) scale(0.94);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: transform 0.22s ease, opacity 0.2s ease, visibility 0.2s ease;
}
body.menu-open .menu-panel {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
body.menu-opening .menu-panel,
body.menu-opening .menu-panel * {
  pointer-events: none !important;
}

.menu-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 18px;
}
.menu-panel__title {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.menu-panel__close {
  min-width: 40px;
  padding: 8px 10px;
}

.menu-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.menu-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}
.menu-section__label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(200, 230, 180, 0.7);
  margin-bottom: 2px;
}

.menu-row {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  padding: 12px 14px;
  font-size: 0.95rem;
}

.menu-lang {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.menu-lang .lang-btn {
  font-size: 0.82rem;
  padding: 8px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lang-btn.active {
  background: rgba(124, 179, 66, 0.9);
  border-color: #aed581;
  color: #0f2010;
}

.hud-btn {
  pointer-events: auto;
  border: 1px solid rgba(255,255,255,0.28);
  background: rgba(0,0,0,0.55);
  color: #e8f5e9;
  font: 700 0.85rem var(--font);
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.hud-btn:hover { background: rgba(30,50,20,0.85); border-color: #aed581; }
.hud-btn:active { transform: scale(0.97); }
.hud-btn.primary {
  background: rgba(124,179,66,0.85);
  border-color: #aed581;
  color: #fff;
}
.hud-btn.active {
  background: rgba(255,193,7,0.9);
  border-color: #ffe082;
  color: #1a1a00;
}
.hud-btn.hint-btn {
  border-color: rgba(255, 213, 79, 0.55);
  background: rgba(40, 35, 10, 0.65);
}
.hud-btn.hint-btn:hover {
  border-color: #ffd54f;
  background: rgba(60, 50, 10, 0.85);
}
.hud-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.item-chip.hint-pulse .item-chip-icon {
  border-color: #ffd54f;
  box-shadow: 0 0 0 3px rgba(255, 213, 79, 0.7), 0 0 18px rgba(255, 213, 79, 0.55);
  animation: hintChipPulse 0.7s ease-in-out infinite alternate;
}
@keyframes hintChipPulse {
  from { transform: scale(1); }
  to   { transform: scale(1.08); }
}

.outline-bar {
  position: fixed;
  top: calc(58px + var(--sat));
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(0,0,0,0.78);
  border: 1px solid rgba(255,213,79,0.45);
  border-radius: 14px;
  backdrop-filter: blur(8px);
  max-width: calc(100vw - 24px - var(--sal) - var(--sar));
  touch-action: none;
}
.outline-bar.hide { display: none; }
.outline-bar.dragging {
  opacity: 0.92;
  box-shadow: 0 10px 28px rgba(0,0,0,0.45);
  cursor: grabbing;
}
.outline-bar-handle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 4px;
  padding: 4px 8px;
  border-radius: 10px;
  background: rgba(255, 213, 79, 0.12);
  border: 1px solid rgba(255, 213, 79, 0.28);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.outline-bar-handle:active { cursor: grabbing; }
.outline-bar-grip {
  color: #ffe082;
  font-size: 1rem;
  letter-spacing: -2px;
  line-height: 1;
}
.outline-bar-title {
  font-weight: 800;
  color: #ffe082;
  white-space: nowrap;
  margin: 0;
  pointer-events: none;
}
.outline-bar-drag-hint {
  font-size: 0.68rem;
  font-weight: 700;
  color: rgba(255, 224, 130, 0.65);
  text-transform: lowercase;
  pointer-events: none;
}
.outline-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
  justify-content: center;
  margin-top: 4px;
}
.outline-chip {
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.08);
  color: #e8f5e9;
  font: 700 0.75rem var(--font);
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.outline-chip.sel {
  background: rgba(255,213,79,0.95);
  color: #1a1a00;
  border-color: #ffe082;
}
.outline-chip.done {
  border-color: #81c784;
}
.outline-chip.sel.done {
  box-shadow: inset 0 0 0 2px #558b2f;
}

.hud-timer {
  font-size: clamp(1.05rem, 3.5vw, 1.35rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #fff9c4;
  text-shadow: 0 2px 8px rgba(0,0,0,0.9);
}

.hud-count {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 30px;
  padding: 6px 15px;
  font-size: clamp(0.78rem, 2.2vw, 0.9rem);
  font-weight: 700;
}

/* ── Hint pill ──────────────────────────────────────────── */
.hint-pill {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 30px;
  padding: 9px clamp(12px, 3vw, 22px);
  font-size: clamp(0.75rem, 2.4vw, 0.88rem);
  font-weight: 600;
  white-space: nowrap;
  max-width: calc(100vw - 24px - var(--sal) - var(--sar));
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: none;
  color: #e8f5e9;
  pointer-events: none;
  transition: opacity 0.45s ease, transform 0.45s ease, top 0.15s ease;
  /* top set in JS above the chip bar */
}

.hint-pill.hide {
  opacity: 0;
  transform: translateX(-50%) translateY(8px);
}

/* ── Item cards overlay the top of the fullscreen scene ─── */
.hud-bottom {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  box-sizing: border-box;
  padding: 0 3px;
  background: transparent;
  pointer-events: none;
  max-height: none;
  overflow: visible;
}

.hud-bottom-row {
  display: grid;
  grid-template-columns: repeat(var(--card-cols, 8), minmax(0, 1fr));
  align-items: flex-start;
  gap: 4px 6px;
  width: 100%;
  max-width: 100%;
  /* JS sizes cards so every target fits in at most two rows. */
  overflow: visible;
  pointer-events: none;
}

/* Items + Hint/Menu wrap together in the parent (same 2 rows) */
.hud-items,
.hud-actions {
  display: contents;
}

body.outline-on .item-chip {
  display: none !important;
}
body.outline-on .hud-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px 8px;
  justify-content: center;
  width: 100%;
  pointer-events: none;
}
body.outline-on .hud-bottom-row {
  max-height: none;
  overflow: visible;
}
body.outline-on .hud-bottom {
  position: fixed;
  z-index: 20;
  max-height: none;
  padding: 12px;
  left: 0 !important;
  right: 0;
  width: 100% !important;
  top: auto !important;
  bottom: 0;
  background: linear-gradient(
    to top,
    rgba(6, 14, 8, 0.55) 0%,
    transparent 100%
  );
}
body.outline-on #btnHint {
  display: none;
}

/* Action chips — same look as item cards */
.action-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  position: relative;
  cursor: pointer;
  pointer-events: auto;
  width: calc(var(--chip) + 4px);
  max-width: calc(var(--chip) + 8px);
  min-width: 0;
  border: none;
  background: transparent;
  padding: 0;
  color: inherit;
  font: inherit;
  justify-self: center;
}
.action-chip:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.35);
}
.action-chip-icon {
  width: var(--chip);
  height: var(--chip);
  min-width: 0;
  min-height: 0;
  border-radius: 12px;
  border: 2px solid rgba(255,255,255,0.22);
  background-color: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--chip) * 0.45);
  line-height: 1;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.12s;
}
.action-chip-icon--hint {
  border-color: rgba(255, 213, 79, 0.45);
  background: rgba(40, 35, 10, 0.65);
}
.action-chip-icon--menu {
  border-color: rgba(129, 199, 132, 0.45);
  background: rgba(20, 40, 22, 0.7);
  font-size: 1.25rem;
  font-weight: 800;
}
.action-chip:hover:not(:disabled) .action-chip-icon {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.55), 0 0 0 2px rgba(174, 213, 129, 0.35);
}
.action-chip:active:not(:disabled) .action-chip-icon {
  transform: translateY(0) scale(0.96);
}
.action-chip-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-shadow: 0 1px 5px rgba(0,0,0,0.95);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  color: rgba(255,255,255,0.92);
  letter-spacing: 0.02em;
}

@media (max-height: 700px), (max-width: 700px) {
  :root { --chip: 42px; }
  .action-chip-icon {
    border-radius: 10px;
  }
  .action-chip-label {
    font-size: 0.62rem;
  }
}

/* ── Item chip ──────────────────────────────────────────── */
.item-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  position: relative;
  cursor: pointer;
  pointer-events: auto;
  width: calc(var(--chip) + 4px);
  max-width: calc(var(--chip) + 8px);
  min-width: 0;
  justify-self: center;
}

.item-chip.outline-sel .item-chip-icon {
  border-color: #ffd54f;
  box-shadow: 0 0 0 3px rgba(255, 213, 79, 0.55), 0 4px 16px rgba(0,0,0,0.6);
}

.item-chip.outline-done .item-chip-icon {
  border-color: #81c784;
}

.item-chip-icon {
  width: var(--chip);
  height: var(--chip);
  min-width: 0;
  min-height: 0;
  border-radius: 12px;
  border: 2px solid rgba(255,255,255,0.22);
  background-color: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  box-shadow: 0 4px 12px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.1);
  transition: border-color 0.3s, box-shadow 0.3s;
  will-change: transform;
  position: relative;
}

@media (max-height: 700px), (max-width: 700px) {
  :root { --chip: 42px; --ui-pad: 8px; }
  .item-chip-icon {
    border-radius: 10px;
  }
  .item-chip-label {
    font-size: 0.62rem !important;
  }
  .hud-bottom {
    max-height: min(36dvh, 180px);
    padding-top: 0;
  }
}

.item-chip-count {
  position: absolute;
  right: -6px;
  bottom: -6px;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 999px;
  background: #2e7d32;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 22px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.45);
  pointer-events: none;
}

.item-chip.found .item-chip-count {
  background: #558b2f;
  opacity: 0.85;
}

.item-chip-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-shadow: 0 1px 5px rgba(0,0,0,0.95);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  color: rgba(255,255,255,0.92);
  letter-spacing: 0.02em;
  transition: opacity 0.4s;
}

/* Checkmark overlay — fills the icon exactly */
.item-chip-check {
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
  border-radius: inherit;
  background: rgba(76,175,80,0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  text-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

@media (max-height: 700px), (max-width: 700px) {
  .item-chip-check {
    font-size: 1.05rem;
  }
}

/* ── Found animation ────────────────────────────────────── */
@keyframes chipBounce {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.45) rotate(-8deg); }
  70%  { transform: scale(0.92) rotate(3deg); }
  100% { transform: scale(1); }
}

@keyframes chipGlow {
  0%, 100% { box-shadow: 0 4px 16px rgba(0,0,0,0.6), 0 0 0 0 var(--accent-glow); }
  40%       { box-shadow: 0 4px 24px rgba(0,0,0,0.4), 0 0 28px 10px var(--accent-glow); }
}

@keyframes checkIn {
  0%   { opacity: 0; transform: scale(0.4) rotate(-20deg); }
  60%  { opacity: 1; transform: scale(1.15) rotate(5deg); }
  100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

@keyframes chipDim {
  to { opacity: 0.35; filter: grayscale(60%) brightness(0.75); }
}

.item-chip.found .item-chip-icon {
  animation:
    chipBounce 0.42s cubic-bezier(0.34,1.56,0.64,1) forwards,
    chipGlow   0.45s ease forwards,
    chipDim    0.25s 0.4s ease forwards;
  border-color: var(--accent);
  pointer-events: none;
}

.item-chip.found .item-chip-check {
  animation: checkIn 0.32s 0.05s cubic-bezier(0.34,1.56,0.64,1) forwards;
}

.item-chip.found .item-chip-label {
  opacity: 0.35;
  text-decoration: line-through;
  transition: opacity 0.4s 0.4s, text-decoration 0s 0.4s;
}

/* ── Overlay / Modal ────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(16px + var(--sat)) calc(16px + var(--sar)) calc(16px + var(--sab)) calc(16px + var(--sal));
  z-index: 100;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.overlay[hidden] { display: none; }

.modal {
  background: rgba(14,28,14,0.96);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  max-width: min(440px, 100%);
  width: 100%;
  padding: clamp(20px, 4vw, 36px) clamp(16px, 4vw, 32px);
  text-align: center;
  box-shadow: 0 24px 72px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.05);
  margin: auto;
}

.modal-hero {
  font-size: clamp(2.8rem, 10vw, 4.5rem);
  line-height: 1;
  margin-bottom: 14px;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.5));
}

.modal h2 {
  font-size: clamp(1.2rem, 4.2vw, 1.55rem);
  font-weight: 800;
  margin-bottom: 10px;
  letter-spacing: 0.01em;
}

.modal p {
  color: var(--muted);
  line-height: 1.7;
  font-size: clamp(0.85rem, 2.8vw, 0.95rem);
  margin-bottom: 26px;
}

.modal p strong { color: #ffcc80; }

.modal-hint .modal-hero {
  font-size: clamp(2.4rem, 8vw, 3.6rem);
}
.modal-hint h2 {
  color: #ffe082;
}

.modal-lb .lb-sub {
  margin-top: -8px;
  margin-bottom: 14px;
  font-size: 0.85rem;
  color: rgba(200, 230, 180, 0.75);
}

.lb-list {
  text-align: left;
  max-height: min(42vh, 320px);
  overflow-y: auto;
  margin-bottom: 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
  -webkit-overflow-scrolling: touch;
}

.lb-row {
  display: grid;
  grid-template-columns: 2.2rem 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.88rem;
}
.lb-row:last-child { border-bottom: none; }
.lb-row.is-you {
  background: rgba(124, 179, 66, 0.22);
  color: #e8f5e9;
}
.lb-rank {
  font-weight: 800;
  color: #ffe082;
  font-variant-numeric: tabular-nums;
}
.lb-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-score {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #c8e6c9;
}
.lb-msg {
  padding: 18px 14px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.modal-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  flex: 1 1 140px;
  font: 600 1rem var(--font);
  padding: 13px 20px;
  min-height: 48px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.07);
  color: var(--text);
  cursor: pointer;
  transition: background 0.18s, transform 0.12s;
  touch-action: manipulation;
}

.btn:hover  { background: rgba(255,255,255,0.14); transform: translateY(-2px); }
.btn:active { transform: translateY(0); }

.btn.primary {
  background: var(--accent);
  border-color: #558b2f;
  color: #0f2010;
}

.btn.primary:hover { filter: brightness(1.1); background: var(--accent); }

.btn.full { width: 100%; flex-basis: 100%; }

/* ── Device breakpoints ─────────────────────────────────── */
@media (max-width: 900px), (max-height: 520px) {
  .hud-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    align-items: center;
    gap: 2px 8px;
    padding: 4px 8px 6px;
  }
  .hud-level {
    grid-column: 1;
    grid-row: 1;
    max-width: 100%;
  }
  .hud-right {
    grid-column: 2;
    grid-row: 1;
    max-width: none;
  }
  .hud-bottom {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    max-height: none;
    padding: 0;
    overflow: visible;
  }
}

@media (max-width: 480px) {
  .hud-level { max-width: 55%; }
  .hud-right { max-width: 45%; gap: 6px; }
  .hud-count { padding: 5px 10px; }
  .modal-btns { flex-direction: column; }
  .btn { flex: 1 1 auto; width: 100%; }
  .action-chip-label,
  .item-chip-label { font-size: 0.58rem; }
}

/* Short landscape phones / foldable */
@media (orientation: landscape) and (max-height: 500px) {
  :root { --chip: 36px; --ui-pad: 6px; --hud-bottom-h: 72px; }

  .hud-top {
    padding: 4px 8px 6px;
  }
  .hud-timer { font-size: 1rem; }
  .hud-count { padding: 4px 10px; font-size: 0.75rem; }
  .hud-bottom {
    max-height: min(42dvh, 120px);
    padding-top: 8px;
  }
  .action-chip-label,
  .item-chip-label { display: none; }
  .action-chip-icon,
  .item-chip-icon {
    min-width: 36px;
    min-height: 36px;
    border-radius: 9px;
  }
  .item-chip-count {
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    font-size: 0.6rem;
    right: -4px;
    bottom: -4px;
  }
  .hint-pill {
    padding: 6px 14px;
    font-size: 0.72rem;
  }
  .modal {
    padding: 16px 14px;
    max-height: calc(100dvh - 20px - var(--sat) - var(--sab));
    overflow-y: auto;
  }
  .modal-hero { font-size: 2.2rem; margin-bottom: 8px; }
  .modal h2 { font-size: 1.15rem; margin-bottom: 6px; }
  .modal p { font-size: 0.82rem; margin-bottom: 14px; line-height: 1.45; }
  .btn { min-height: 42px; padding: 10px 14px; font-size: 0.92rem; }
  .menu-panel { max-height: calc(100dvh - 16px - var(--sat) - var(--sab)); }
}

/* Large tablets / desktop */
@media (min-width: 900px) and (min-height: 700px) {
  :root { --chip: 52px; }
  .hud-bottom { max-height: min(26dvh, 210px); }
}

/* Prefer less motion on request */
@media (prefers-reduced-motion: reduce) {
  .btn:hover { transform: none; }
  .action-chip:hover:not(:disabled) .action-chip-icon { transform: none; }
}
