:root { --gap: 14px; }

* { box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  margin: 0;
  background: #fafafa;
  color: #111;
}

main {
  max-width: 900px;
  margin: 32px auto;
  padding: 0 16px;
}

header {
  display: grid;
  gap: var(--gap);
  margin-bottom: 12px;
}

/* Header alignment */
.header-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
}

/* --- Header controls: balanced dropdown + button --- */
.header-left select,
.header-left button {
  font-size: 1rem;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid #ddd;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
  height: 42px;          /* consistent height (desktop) */
  width: 200px;          /* consistent width (desktop) */
  line-height: 1;
  text-align: center;
}

/* Mobile sizes so they don’t look oversized */
@media (max-width: 768px) {
  .header-left select,
  .header-left button {
    height: 40px;
    width: 160px;
  }
}

/* --- Unified Button Design --- */
button,
.tip-btn,
select {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid #ddd;
  background: #fff;
  font-size: .95rem;
  color: #111;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

button:hover,
.tip-btn:hover,
select:hover {
  background: #f2f2f2;
  box-shadow: 0 4px 8px rgba(0,0,0,0.08);
}

button:active,
.tip-btn:active {
  background: #eaeaea;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.08);
}

/* Filters panel */
.filters-panel { display: none; }
.filters-panel.open { display: block; }

.filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  align-items: center;
  margin-top: 8px;
}
#topRange { display: none; }

/* Card content */
.card {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 2px 10px rgba(0,0,0,.03);
}

h2 { font-size: 1.25rem; margin-top: 0; }
.body { white-space: pre-wrap; line-height: 1.55; }
.meta { color: #666; font-size: .9rem; margin-top: 10px; min-height: 1.2em; }

/* Votes */
.vote {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  align-items: center;
  margin-top: 12px;
  justify-content: center;
}
#tally { display: none !important; }

/* Footer */
.below-row {
  display: flex;
  align-items: center;
  gap: var(--gap);
  margin-top: 10px;
}
.below-left {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: var(--gap);
}
.below-center {
  flex: 0 1 auto;
  text-align: center;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.below-right {
  flex: 1 1 auto;
  display: flex;
  justify-content: flex-end;
}

/* Share dropdown */
.share-wrap { position: relative; display: inline-block; }

.share-menu {
  position: absolute;
  top: 105%;
  left: 0;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 10px;
  box-shadow: 0 6px 16px rgba(0,0,0,.08);
  padding: 8px;
  display: none;
  min-width: 180px;
  z-index: 50;
  animation: fadeIn 0.2s ease-in-out;
}

.share-menu button {
  display: block;
  width: 100%;
  text-align: left;
  margin: 2px 0;
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
}

.share-menu button:hover {
  background: #f2f2f2;
}

/* Fade-in animation */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------------- Floating dice (final) ----------------
   Pinned to the safe bottom-right corner on all devices. */
.fab-random {
  position: fixed !important;
  right: max(16px, env(safe-area-inset-right)) !important;
  bottom: calc(max(16px, env(safe-area-inset-bottom))) !important;
  bottom: calc(max(16px, constant(safe-area-inset-bottom))) !important; /* iOS fallback */
  z-index: 2147483647 !important;

  /* visual styles (kept from your original) */
  display: none;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid #ddd;
  background: #fff;
  box-shadow: 0 6px 16px rgba(0,0,0,.12);
  cursor: pointer;
}

/* Show the floating dice on mobile; hide inline desktop button there */
@media (max-width: 768px) {
  .fab-random { display: inline-flex; }
  .desktop-random { display: none; }
}

/* Keep dice visible on larger screens too (if you want it there) */
@media (min-width: 769px) {
  .fab-random { display: inline-flex !important; }
}

/* Optionally hide the legacy share dropdown UI completely */
#shareMenu,
[data-share-menu],
.share-menu,
.shareDropdown,
.share-menu-panel {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* General safety */
body, html { overflow-x: hidden; }
