/* Puddlehold game menu and HUD system buttons (menu.js). HerpDerp skin, same tokens as the lobby.
   Jersey 10 is sharp only at 56/3 px and twice that, so only those two sizes are used;
   key caps use the body face. Font family comes from the page. A game may override --phm-* tokens and --phm-z.
   The size rules are !important and doubled (.phm-menu.phm-menu) so a game's own "every font-size is X
   !important" rule (Siege, Schlammschlacht) cannot resize the menu: it looks the same in every game. */
.phm-menu, .phm-sys {
  --phm-wood: #6e3f1c; --phm-wood-dark: #3a2210; --phm-parch: #ead6a4; --phm-parch-hi: #fff5d0; --phm-parch-lo: #efd48f;
  --phm-gold: #ffd43a; --phm-ink: #2b1a0e; --phm-text: #fff6dc; --phm-muted: #eed9a8; --phm-leaf: #9be07a; --phm-brown: #6b4a22;
  --phm-btn-hi: #ffb64a; --phm-btn-lo: #ec8c22; --phm-red-hi: #e06a3c; --phm-red-lo: #b3361a;
  --phm-px: 18.667px; --phm-px2: 37.333px; --phm-rx: 16px; --phm-rx2: 22px;
  --phm-read: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; --phm-title: "Jersey 10", var(--phm-read);
  --phm-outline: 1px 0 0 var(--phm-ink), -1px 0 0 var(--phm-ink), 0 1px 0 var(--phm-ink), 0 -1px 0 var(--phm-ink), 1px 1px 0 var(--phm-ink), -1px 1px 0 var(--phm-ink), 1px -1px 0 var(--phm-ink), -1px -1px 0 var(--phm-ink);
}
.phm-menu { position: fixed; inset: 0; z-index: var(--phm-z, 900); display: grid; place-items: center; padding: 12px; color: var(--phm-text); line-height: 1.15; }
.phm-menu[hidden] { display: none !important; }
.phm-menu *, .phm-sys * { box-sizing: border-box; }
.phm-menu.phm-menu, .phm-menu.phm-menu *, .phm-menu.phm-menu *::before, .phm-menu.phm-menu *::after, .phm-sys.phm-sys, .phm-sys.phm-sys * {
  font-size: var(--phm-px) !important; font-weight: 400 !important; font-style: normal !important; letter-spacing: 0 !important;
}
.phm-menu.phm-menu .phm-head h2, .phm-menu.phm-menu .phm-btn.phm-big, .phm-menu.phm-menu .phm-stat b { font-size: var(--phm-px2) !important; }
.phm-menu button, .phm-sys button { font-family: inherit; }
/* Readable text everywhere (15.11.2026): a plain sans face for all text, the pixel face only for
   the gold title. Same font in every game, whatever the page uses. */
.phm-menu.phm-menu, .phm-menu.phm-menu *, .phm-menu.phm-menu *::before, .phm-menu.phm-menu *::after, .phm-sys.phm-sys, .phm-sys.phm-sys * {
  font-family: var(--phm-read) !important; font-size: var(--phm-rx) !important; font-weight: 600 !important; -webkit-font-smoothing: antialiased;
}
.phm-menu.phm-menu .phm-btn.phm-big, .phm-menu.phm-menu .phm-stat b { font-size: var(--phm-rx2) !important; font-weight: 700 !important; }
.phm-menu.phm-menu .phm-head h2 { font-family: var(--phm-title) !important; font-size: var(--phm-px2) !important; font-weight: 400 !important; -webkit-font-smoothing: none; }
.phm-menu p, .phm-menu h2, .phm-menu kbd { margin: 0; }
.phm-menu p { padding: 0; }
.phm-menu :focus-visible, .phm-sys :focus-visible { outline: 3px solid var(--phm-gold); outline-offset: 2px; }
.phm-dim { position: absolute; inset: 0; background: rgba(20, 12, 4, .5); }

/* Fixed size so switching tabs never makes the window jump; fits 390 x 700. The height is capped to the
   visible window (dvh, vh as fallback) so a phone in landscape never cuts it off: the body scrolls. */
.phm-panel {
  position: relative; width: min(560px, 100%); height: min(440px, calc(100vh - 24px)); height: min(440px, calc(100dvh - 24px)); display: flex; flex-direction: column; gap: 10px;
  background: var(--phm-wood); border: 12px solid var(--phm-ink); border-radius: 14px;
  border-image-source: url(panel.png); border-image-slice: 36 fill; border-image-width: 36px; border-image-repeat: round;
  box-shadow: 0 6px 0 rgba(0, 0, 0, .28); padding: 14px 18px;
}
.phm-head { display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.phm-head h2 { margin: 0; font-family: inherit; line-height: 1; color: var(--phm-gold); text-shadow: var(--phm-outline); }
.phm-head span { color: var(--phm-muted); line-height: 1.05; }
.phm-head em { font-style: normal; background: var(--phm-ink); color: var(--phm-leaf); border-radius: 10px; padding: 1px 10px; margin-top: 2px; }

.phm-tabs { display: flex; gap: 4px; border-bottom: 3px solid var(--phm-ink); }
.phm-tab { flex: 1; background: var(--phm-wood-dark); color: var(--phm-muted); border: 3px solid var(--phm-ink); border-bottom: 0; border-radius: 10px 10px 0 0; padding: 3px 6px; cursor: pointer; }
.phm-tab[aria-selected="true"] { background: var(--phm-parch); color: var(--phm-ink); }
.phm-body { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 10px; scrollbar-width: thin; scrollbar-color: var(--phm-gold) var(--phm-wood-dark); }
/* Children keep their height so a short screen (phone in landscape) scrolls instead of squeezing them. */
.phm-body > * { flex-shrink: 0; }

.phm-btn {
  cursor: pointer; padding: 4px 16px; margin: 0; white-space: nowrap; color: var(--phm-ink);
  background: linear-gradient(var(--phm-btn-hi), var(--phm-btn-lo)); border: 3px solid var(--phm-ink); border-radius: 12px;
  box-shadow: 0 4px 0 var(--phm-ink), inset 0 2px 0 rgba(255, 255, 255, .45);
}
.phm-btn:hover { filter: brightness(1.08); }
.phm-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--phm-ink); }
.phm-btn.phm-big { padding: 6px 22px; line-height: 1; }
.phm-btn.phm-quiet { background: linear-gradient(var(--phm-parch-hi), var(--phm-parch-lo)); }
.phm-btn.phm-danger { background: linear-gradient(var(--phm-red-hi), var(--phm-red-lo)); color: var(--phm-parch-hi); text-shadow: var(--phm-outline); }
.phm-btn.phm-danger.armed { background: linear-gradient(#ff8a5c, #d0401a); box-shadow: 0 0 0 3px var(--phm-gold), 0 4px 0 var(--phm-ink); }
.phm-actions { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.phm-legal { align-self: center; background: none; border: 0; padding: 0 4px; cursor: pointer; color: var(--phm-muted); text-decoration: underline; font-family: inherit; }
.phm-legal:hover { color: var(--phm-gold); }
.phm-legal-row { flex: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 14px; }
.phm-legal-row .phm-legal { align-self: auto; }
.phm-hint { margin: 0; color: var(--phm-muted); text-align: center; line-height: 1.25; }
/* Offline copy (20.11.2026): one quiet button and a line under the actions of the Spiel tab. */
.phm-offline { display: flex; flex-direction: column; gap: 6px; padding-top: 8px; border-top: 3px solid var(--phm-wood-dark); }
.phm-offline .phm-btn { white-space: normal; }
.phm-offline .phm-btn[aria-pressed="true"] { background: linear-gradient(#d9f5c4, #9be07a); }
.phm-offline .phm-btn.armed { box-shadow: 0 0 0 3px var(--phm-gold), 0 4px 0 var(--phm-ink); }
.phm-offline .phm-btn[disabled] { cursor: progress; filter: saturate(.6); }

.phm-stats { display: grid; grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr)); gap: 6px; }
.phm-stat { min-width: 0; background: linear-gradient(var(--phm-parch-hi), var(--phm-parch-lo)); color: var(--phm-ink); border: 3px solid var(--phm-ink); border-radius: 10px; padding: 3px 8px; display: flex; flex-direction: column; line-height: 1; }
.phm-stat small { color: var(--phm-brown); }
.phm-stat b { line-height: 1; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.phm-sliders { display: grid; grid-template-columns: auto 1fr auto; gap: 6px 10px; align-items: center; }
.phm-sliders label { color: var(--phm-muted); }
.phm-sliders input { width: 100%; accent-color: var(--phm-gold); margin: 0; }
.phm-sliders output { color: var(--phm-gold); min-width: 2.2em; text-align: right; font-variant-numeric: tabular-nums; }
.phm-optrow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.phm-lang { display: flex; gap: 4px; align-items: center; color: var(--phm-muted); }
.phm-lang button { background: none; border: 0; color: var(--phm-muted); cursor: pointer; padding: 0 4px; }
.phm-lang button.on { color: var(--phm-gold); text-decoration: underline; }

.phm-keys { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 16px; }
.phm-key { display: flex; gap: 8px; align-items: flex-start; min-width: 0; }
.phm-key kbd { font-family: inherit; line-height: 1; background: var(--phm-parch-hi); color: var(--phm-ink); border: 2px solid var(--phm-ink); border-radius: 6px; padding: 0 6px; max-width: 55%; overflow-wrap: anywhere; flex: none; }
.phm-key span { color: var(--phm-muted); line-height: 1.05; min-width: 0; padding-top: 2px; }

/* HUD system buttons: top right in every game. */
.phm-sys { position: fixed; top: calc(6px + env(safe-area-inset-top, 0px)); right: calc(8px + env(safe-area-inset-right, 0px)); z-index: var(--phm-sys-z, 50); display: flex; gap: 6px; }
.phm-rb { width: 34px; height: 34px; border-radius: 50%; padding: 0; display: grid; place-items: center; cursor: pointer; color: var(--phm-ink);
  background: linear-gradient(var(--phm-btn-hi), var(--phm-btn-lo)); border: 3px solid var(--phm-ink); box-shadow: 0 3px 0 var(--phm-ink); }
/* Pixel icons (make-icons.py): art grid doubled, shown 1:1 so one art pixel stays whole. */
.phm-ic { display: block; width: 26px; height: 20px; background: center / contain no-repeat; image-rendering: pixelated; }
.phm-b-chat .phm-ic { background-image: url(ico_chat.png); }
.phm-b-music .phm-ic { background-image: url(ico_music.png); }
.phm-b-music.off .phm-ic { background-image: url(ico_music_off.png); }
.phm-b-sound .phm-ic { background-image: url(ico_sound.png); }
.phm-b-sound.off .phm-ic { background-image: url(ico_sound_off.png); }
.phm-b-menu .phm-ic { background-image: url(ico_menu.png); }
.phm-rb.off { background: linear-gradient(#8a6a44, #5c4024); }
.phm-rb { position: relative; }
.phm-rb.phm-b-menu { box-shadow: 0 0 0 3px var(--phm-gold), 0 3px 0 var(--phm-ink); }
.phm-rb:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--phm-ink); }

@media (max-width: 760px), (max-height: 520px) {
  .phm-panel { height: min(560px, 100%); padding: 10px 12px; border-width: 10px; }
  .phm-keys { grid-template-columns: 1fr; }
  .phm-menu.phm-menu .phm-stat b { font-size: var(--phm-px) !important; line-height: 1.2; }
  .phm-sys .phm-b-sound, .phm-sys:not(.phm-tm) .phm-b-music { display: none; }
}
/* Short windows (phone in landscape): tighter panel, the body scrolls, the links row stays. */
@media (max-height: 520px) {
  .phm-menu { padding: 6px; }
  .phm-panel { height: min(560px, calc(100vh - 12px)); height: min(560px, calc(100dvh - 12px)); gap: 6px; padding: 8px 12px; }
  .phm-head em { display: none; }
}
@media (pointer: coarse) { .phm-sys .phm-b-sound, .phm-sys:not(.phm-tm) .phm-b-music { display: none; } .phm-rb { width: 44px; height: 44px; } }
/* Touch: every control at least 40 px; desktop look stays as is. */
@media (pointer: coarse) {
  .phm-tab, .phm-btn, .phm-legal, .phm-lang button { min-height: 40px; }
  .phm-legal { display: inline-flex; align-items: center; padding: 0 12px; }
  .phm-lang button { min-width: 40px; }
  .phm-sliders input { height: 40px; }
}
