/* Shared splash header: back arrow (left), optional title (center, empty by
   default), options gear (right) opening a single consolidated panel.
   Used by every in-repo game so the header looks and behaves the same
   everywhere. Games keep their own visual skin by overriding these rules in
   their own stylesheet, loaded after this one. */

.game-nav {
  position: sticky;
  top: 0;
  z-index: 1000;
  height: 60px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 max(16px, env(safe-area-inset-right)) 0
    max(16px, env(safe-area-inset-left));
  background: #ffffff;
  border-bottom: 2px solid #ffffff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  box-sizing: border-box;
}

.nav-side {
  width: auto;
  min-width: 40px;
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}
.nav-left {
  justify-content: flex-start;
}
.nav-right {
  justify-content: flex-end;
  gap: 8px;
}
.nav-center {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.nav-banner {
  max-width: 100%;
  max-height: 45px;
  object-fit: contain;
}

.nav-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: #333;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Empty by default: an unset title takes no visual space in the header. */
.nav-title:empty {
  display: none;
}

/* Matches Coinchapp's `HomeTopBar.tsx` floating back/settings buttons
   exactly (h-9 w-9, bg-black/45, shadow-md, backdrop-blur-sm) so the same
   two controls look identical everywhere. A game can still re-skin the
   background/color in its own stylesheet (see `cafards`, `blackstories`,
   `pyramide`) for a themed look — only the base default changes here. */
.back-button,
.options-button {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: rgba(0, 0, 0, 0.45);
  color: #ffffff;
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -2px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  text-decoration: none;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  box-sizing: border-box;
}

.back-button:active,
.options-button:active {
  transform: scale(0.94);
}

/* --- Options panel: single gear-triggered sheet that groups whatever a
   game already offers there (language, rules, game-specific settings) --- */
.options-panel {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.options-panel[hidden] {
  display: none;
}

.options-panel-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
}

.options-panel-sheet {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: 80dvh;
  overflow-y: auto;
  background: #ffffff;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -12px 30px rgba(15, 23, 42, 0.25);
  padding: 16px 20px max(20px, env(safe-area-inset-bottom));
  box-sizing: border-box;
}

@media (min-width: 640px) {
  .options-panel {
    align-items: center;
  }
  .options-panel-sheet {
    border-radius: 20px;
  }
}

.options-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.options-panel-title {
  font-weight: 700;
  font-size: 1.1rem;
}

.options-panel-close {
  border: none;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
}

.options-panel-section + .options-panel-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.options-panel-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
  margin: 0 0 8px;
}

/* Collapsed rules: <details class="options-panel-section"> with a
   <summary class="options-panel-section-title">, closed by default. */
summary.options-panel-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 32px;
  margin: 0;
  cursor: pointer;
  list-style: none;
}

summary.options-panel-section-title::-webkit-details-marker {
  display: none;
}

summary.options-panel-section-title::after {
  content: "";
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.15s;
}

details[open] > summary.options-panel-section-title {
  margin-bottom: 8px;
}

details[open] > summary.options-panel-section-title::after {
  transform: rotate(-135deg);
}

.options-feedback-button {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 12px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.options-feedback-button:hover {
  background: rgba(0, 0, 0, 0.04);
}

.rules-modal-content {
  font-size: 0.95rem;
  line-height: 1.5;
}

/* --- Language switch, reused inside options panels --- */
.lang-selector {
  display: flex;
  gap: 2px;
  align-items: center;
}

.lang-btn {
  background: none;
  border: 2px solid transparent;
  border-radius: 6px;
  font-size: 1.4rem;
  line-height: 1;
  padding: 2px 3px;
  cursor: pointer;
  opacity: 0.4;
  transition:
    opacity 0.15s,
    border-color 0.15s;
}

.lang-btn:hover {
  opacity: 0.75;
}

.lang-btn.active {
  opacity: 1;
  border-color: #007bff;
}
