/* Grizzly's top bar ☰ menu (grizzly-menu.js): Cute Temple's (grizzly-menu.css)
   in the page's ice, every box as Cute Temple's: everything but the balance
   (grizzly/index.html's <details class="game-menu">), the bar's frosted
   button with a snow cap, then the bet panel's blue glass with its light
   text and sky-blue switch. grizzly-menu.js closes it on Escape or a click
   outside and fades it out; without the script it still opens and closes
   (at once). */

/* ---------- ☰: the frosted square, three navy-blue bars ---------- */
body[data-character="grizzly"] .game-menu {
  position: relative;
  flex: none;
}
body[data-character="grizzly"] .game-menu-button {
  position: relative;
  z-index: 1;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  list-style: none;
  --cap-h: 14px;
  border: 1px solid #eef8ff;
  border-radius: 13px;
  background: linear-gradient(180deg, #c4e4ff, #a6d6fc);
  box-shadow: 0 0 14px #9fd7ff55, inset 0 1px 0 #ffffffb3, inset 0 -2px 0 #7fb6ea66;
  color: #1759a4;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
body[data-character="grizzly"] .game-menu-button::-webkit-details-marker {
  display: none;
}
body[data-character="grizzly"] .game-menu-button:hover {
  background: linear-gradient(180deg, #d4ecff, #b6defd);
}
body[data-character="grizzly"] .game-menu-button:focus-visible {
  outline: 3px solid #c5f6ff;
  outline-offset: 3px;
}
/* Open, it is pressed into the panel's blue and its bars turn into an
   icy ✕ (while the panel fades out it is ☰ again). */
body[data-character="grizzly"] .game-menu[open]:not(.is-closing) > .game-menu-button {
  border-color: #3f7cc6;
  background: #0b3a74;
  color: #c5f6ff;
}
body[data-character="grizzly"] .game-menu[open]:not(.is-closing) > .game-menu-button:hover {
  background: #0e4486;
}
body[data-character="grizzly"] .game-menu-bars {
  position: relative;
  display: block;
  width: 18px;
  height: 17px;
}
body[data-character="grizzly"] .game-menu-bars > i {
  position: absolute;
  left: 0;
  display: block;
  width: 100%;
  height: 3px;
  border-radius: 2px;
  background: currentColor;
  transition: transform 150ms cubic-bezier(0.4, 0, 0.6, 1), opacity 110ms linear;
}
body[data-character="grizzly"] .game-menu-bars > i:nth-child(1) {
  top: 0;
}
body[data-character="grizzly"] .game-menu-bars > i:nth-child(2) {
  top: 7px;
}
body[data-character="grizzly"] .game-menu-bars > i:nth-child(3) {
  top: 14px;
}
body[data-character="grizzly"] .game-menu[open]:not(.is-closing) .game-menu-bars > i {
  transition: transform 220ms cubic-bezier(0.3, 1.45, 0.55, 1), opacity 110ms linear;
}
body[data-character="grizzly"] .game-menu[open]:not(.is-closing) .game-menu-bars > i:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
body[data-character="grizzly"] .game-menu[open]:not(.is-closing) .game-menu-bars > i:nth-child(2) {
  opacity: 0;
  transform: scaleX(0.2);
}
body[data-character="grizzly"] .game-menu[open]:not(.is-closing) .game-menu-bars > i:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ---------- The panel: the bet panel's blue glass ---------- */
/* While the menu is open the bar draws above the betting panel (7) and the
   coins' canvas; the rest of the time the coins fly over the wallet. */
body[data-character="grizzly"] .topbar:has(> .header-actions > .game-menu[open]),
body[data-character="grizzly"] .topbar.is-menu-open {
  z-index: 8;
}
/* grizzly-menu.js's catcher, under ☰ and the panel (both z-index 1) and over
   the rest of the layout: a click outside only closes the menu, never picks
   a tooth or presses a button under it. Once the menu is closing, clicks go
   through again. */
body[data-character="grizzly"] .game-menu-catcher {
  position: fixed;
  inset: 0;
}
body[data-character="grizzly"] .game-menu.is-closing > .game-menu-catcher {
  pointer-events: none;
}
/* It drops from under ☰, its right edge on ☰'s, and pops from ☰. */
body[data-character="grizzly"] .game-menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 1;
  width: 248px;
  max-height: calc(100vh - 82px);
  max-height: calc(100dvh - 82px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px;
  border: 1px solid #3f7cc6;
  border-radius: 18px;
  background: #0d3b74eb;
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 18px 44px -14px #01081acc, inset 0 1px 0 #8fd0ff33;
  color: #cfe7fb;
  font-family: "Fredoka", sans-serif;
  transform-origin: calc(100% - 21px) -8px;
}
body[data-character="grizzly"] .game-menu.is-closing > .game-menu-panel {
  pointer-events: none;
}
/* The groups: the lobby link; the dialogs; the sounds and fullscreen; the
   wallet. */
body[data-character="grizzly"] .game-menu-group + .game-menu-group {
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px solid #22548f;
}

/* ---------- Rows: icon, label, then a chevron or a switch ---------- */
body[data-character="grizzly"] .game-menu-item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 12px;
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 0 10px 0 11px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #eaf6ff;
  font-family: "Fredoka", sans-serif;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0;
  text-align: left;
  text-transform: none;
  cursor: pointer;
  transition: background-color 0.14s, opacity 0.15s;
}
body[data-character="grizzly"] .game-menu-item > span,
body[data-character="grizzly"] .game-menu-toggle::before {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* The icons: game.js's line icons (painted into <i data-icon>, or its
   speaker straight into the sound toggle) and the page's own, in ice. */
body[data-character="grizzly"] .game-menu-item > svg,
body[data-character="grizzly"] .game-menu-item > i > svg {
  width: 21px;
  height: 21px;
}
body[data-character="grizzly"] .game-menu-item > svg {
  justify-self: center;
  color: #8fd3fb;
}
body[data-character="grizzly"] .game-menu-item > i {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  color: #8fd3fb;
}
/* A chevron: the row opens a dialog. */
body[data-character="grizzly"] .game-menu-item > i[data-icon="chevron-right"] {
  width: 18px;
  color: #cfe7fb;
  opacity: 0.55;
}
body[data-character="grizzly"] .game-menu-item > i[data-icon="chevron-right"] > svg {
  width: 18px;
  height: 18px;
}
@media (hover: hover) {
  body[data-character="grizzly"] .game-menu-item:hover:enabled,
  body[data-character="grizzly"] a.game-menu-item:hover {
    background: #164a8a;
  }
}
body[data-character="grizzly"] .game-menu-item:active:enabled,
body[data-character="grizzly"] a.game-menu-item:active {
  background: #1b5598;
}
body[data-character="grizzly"] .game-menu-item:focus-visible {
  outline: 2px solid #c5f6ff;
  outline-offset: -2px;
  background: #164a8a;
}
body[data-character="grizzly"] .game-menu-item:disabled {
  opacity: 0.45;
  cursor: default;
}
/* The toggles draw their label and switch here: game.js rewrites the sound
   toggle's content (its speaker) at every render. Fullscreen shows its state
   from the label game.js gives it. */
/* The music note and the wind wear the speaker's marks: a cross while off
   and waves while on (Cute Temple keeps these in cute.css). */
body[data-character="grizzly"] .music-toggle .music-on-icon,
body[data-character="grizzly"] .music-toggle[aria-pressed="true"] .music-off-icon,
body[data-character="grizzly"] .ambience-toggle .ambience-on-icon,
body[data-character="grizzly"] .ambience-toggle[aria-pressed="true"] .ambience-off-icon {
  display: none;
}
body[data-character="grizzly"] .music-toggle[aria-pressed="true"] .music-on-icon,
body[data-character="grizzly"] .ambience-toggle[aria-pressed="true"] .ambience-on-icon {
  display: inline;
}
@property --grizzly-menu-knob {
  syntax: "<color>";
  inherits: false;
  initial-value: #8fb0cf;
}
body[data-character="grizzly"] .game-menu-toggle::before {
  content: attr(data-label);
  grid-column: 2;
  grid-row: 1;
}
body[data-character="grizzly"] .game-menu-toggle::after {
  --grizzly-menu-knob: #8fb0cf;
  content: "";
  grid-column: 3;
  grid-row: 1;
  width: 36px;
  height: 20px;
  box-sizing: border-box;
  border: 1px solid #22548f;
  border-radius: 999px;
  background: radial-gradient(circle closest-side, var(--grizzly-menu-knob) calc(100% - 1px), #0000 100%) 2px 50% / 14px 14px no-repeat, #062a58;
  transition: background-position 220ms cubic-bezier(0.3, 1.4, 0.5, 1), background-color 0.18s, border-color 0.18s, --grizzly-menu-knob 0.18s;
}
body[data-character="grizzly"] .game-menu-toggle:is([aria-pressed="true"], [aria-label="Exit fullscreen"])::after {
  --grizzly-menu-knob: #ffffff;
  border-color: #6cc2ff;
  background-color: #37a7fd;
  background-position: calc(100% - 2px) 50%;
  box-shadow: inset 0 1px 0 #ffffff21;
}
/* ---------- The effect: ☰ pops the panel, the rows drop in ---------- */
/* The panel pops from ☰ with a little overshoot and the rows follow one
   after another (grizzly-menu.js numbers them: --i, and starts them again at
   each opening); closing is quicker. With reduced motion it only fades. */
@media (prefers-reduced-motion: no-preference) {
  body[data-character="grizzly"] .game-menu-button:active {
    scale: 0.92;
  }
  body[data-character="grizzly"] .game-menu-button {
    transition: background-color 0.15s, border-color 0.15s, color 0.15s, scale 170ms cubic-bezier(0.3, 1.5, 0.5, 1);
  }
  body[data-character="grizzly"] .game-menu[open] > .game-menu-panel {
    animation: grizzly-menu-pop 180ms cubic-bezier(0.25, 1.3, 0.45, 1) both;
  }
  body[data-character="grizzly"] .game-menu[open] .game-menu-item {
    animation: grizzly-menu-row 260ms cubic-bezier(0.2, 0.8, 0.3, 1) calc(40ms + var(--i, 0) * 22ms) backwards;
  }
  /* Every press in the bar squashes (temple-bet.js's .is-tapped: its
     temple-tap- name lets temple-bet.js end it); a row gives a little. The
     drop-in stays first in the list, so a press never replays it. */
  body[data-character="grizzly"] .game-menu[open] .game-menu-item.is-tapped {
    animation: grizzly-menu-row 260ms cubic-bezier(0.2, 0.8, 0.3, 1) calc(40ms + var(--i, 0) * 22ms) backwards, temple-tap-row 260ms cubic-bezier(0.3, 0.7, 0.4, 1);
  }
  body[data-character="grizzly"] .game-menu.is-closing > .game-menu-panel {
    animation: grizzly-menu-shut 120ms cubic-bezier(0.4, 0, 1, 1) both;
  }
}
@media (prefers-reduced-motion: reduce) {
  body[data-character="grizzly"] .game-menu[open] > .game-menu-panel {
    animation: grizzly-menu-fade-in 140ms ease-out both;
  }
  body[data-character="grizzly"] .game-menu.is-closing > .game-menu-panel {
    animation: grizzly-menu-fade-out 100ms ease-in both;
  }
  body[data-character="grizzly"] .game-menu-bars > i,
  body[data-character="grizzly"] .game-menu[open]:not(.is-closing) .game-menu-bars > i {
    transition: none;
  }
  body[data-character="grizzly"] .game-menu-toggle::after {
    transition: background-color 0.18s, border-color 0.18s, --grizzly-menu-knob 0.18s;
  }
  body[data-character="grizzly"] .game-menu .game-menu-item.is-tapped {
    animation: none;
  }
}
@keyframes temple-tap-row {
  0%, 100% { transform: none; }
  35% { transform: scale(0.97); }
  70% { transform: scale(1.01); }
}
@keyframes grizzly-menu-pop {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: none; }
}
@keyframes grizzly-menu-row {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}
@keyframes grizzly-menu-shut {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: scale(0.96); }
}
@keyframes grizzly-menu-fade-in {
  from { opacity: 0; }
}
@keyframes grizzly-menu-fade-out {
  to { opacity: 0; }
}

/* ---------- Sizes ---------- */
/* Short screens (landscape phones, low windows): a smaller ☰ beside the
   shorter wallet. */
@media (max-height: 650px) and (min-width: 601px) {
  body[data-character="grizzly"] .game-menu-button {
    width: 38px;
    height: 38px;
    border-radius: 12px;
  }
  body[data-character="grizzly"] .game-menu-panel {
    max-height: calc(100vh - 60px);
    max-height: calc(100dvh - 60px);
    transform-origin: calc(100% - 19px) -8px;
  }
}
/* Phones: a smaller ☰ (its bars in proportion) and a wider panel with
   taller rows. */
@media (max-width: 600px) {
  body[data-character="grizzly"] .game-menu-button {
    width: 36px;
    height: 36px;
    border-radius: 11px;
  }
  body[data-character="grizzly"] .game-menu-bars {
    scale: 0.88;
  }
  body[data-character="grizzly"] .game-menu-panel {
    width: min(280px, calc(100vw - 24px));
    max-height: calc(100vh - 66px);
    max-height: calc(100dvh - 66px);
    border-radius: 16px;
    transform-origin: calc(100% - 18px) -8px;
  }
  body[data-character="grizzly"] .game-menu-item {
    min-height: 46px;
  }
}
/* Too short for the list (landscape phones, low windows): two columns, the
   sounds on the right. */
@media (max-height: 480px) and (min-width: 520px) {
  body[data-character="grizzly"] .game-menu-panel {
    width: min(460px, calc(100vw - 24px));
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "games sounds" "dialogs sounds" "wallet sounds";
    grid-template-rows: auto auto 1fr;
    column-gap: 6px;
  }
  body[data-character="grizzly"] .game-menu-group:nth-child(1) {
    grid-area: games;
  }
  body[data-character="grizzly"] .game-menu-group:nth-child(2) {
    grid-area: dialogs;
  }
  body[data-character="grizzly"] .game-menu-group:nth-child(3) {
    grid-area: sounds;
    margin: 0;
    padding: 0 0 0 6px;
    border-top: 0;
    border-left: 1px solid #22548f;
  }
  body[data-character="grizzly"] .game-menu-group:nth-child(4) {
    grid-area: wallet;
  }
}

/* Reduced transparency: plain glass. */
@media (prefers-reduced-transparency: reduce) {
  body[data-character="grizzly"] .game-menu-panel {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: #0d3b74fa;
  }
}
