/* BALLS & GAMBLING — phones & tablets
   Touch hints, the pause button, the Funky Balls touch buttons and layout
   fixes for small screens. body.touch and body.no-fs come from js/mobil.js. */

/* ---------------------------------------------------------------- basics */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}
img { -webkit-user-drag: none; -webkit-touch-callout: none; }
/* fast taps on buttons must not zoom the page (iOS double-tap zoom) */
button, input, label, a { touch-action: manipulation; }

/* the arena canvas takes every touch itself (no page scroll, no zoom) */
#stage, #stage canvas { touch-action: none; -webkit-user-select: none; user-select: none; }

/* keyboard hints on PC, touch hints on phones */
body:not(.touch) .touch-only { display: none !important; }
body.touch .kb-only { display: none !important; }
body.touch .mode-key { display: none; }
/* no mouse to capture on a touch screen, and iPhones have no fullscreen */
body.touch #btn-cursor, body.no-fs #btn-fullscreen { display: none; }
body.touch .sys-btn { opacity: 0.8; }

/* pause button: only while a run is going */
#btn-pause { display: none; }
body.playing #btn-pause { display: grid; }

/* ----------------------------------- first start: PC, phone or tablet? */
.platform-screen { z-index: 50; }
.platform-panel { width: min(620px, 100%); }
.pf-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 18px 0 14px; }
.pf-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 18px 6px 14px;
  color: #fff;
  font: inherit;
  cursor: pointer;
  border: 1px solid rgba(25, 230, 255, 0.45);
  background: linear-gradient(180deg, rgba(25, 230, 255, 0.14), rgba(4, 2, 13, 0.85));
  clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px);
  transition: filter 0.15s;
}
.pf-card svg { width: 58px; height: 58px; fill: none; stroke: var(--cyan); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 6px var(--cyan)); }
.pf-card b { font-family: var(--font-head); font-weight: 900; font-size: 17px; letter-spacing: 0.14em; }
.pf-card span { font-size: 11px; color: var(--dim); }
/* the device the game guessed */
.pf-card.guess { border-color: var(--gold); box-shadow: inset 0 0 22px rgba(255, 201, 51, 0.25); }
.pf-card.guess svg { stroke: var(--gold); filter: drop-shadow(0 0 6px var(--gold)); }
.pf-card:hover, .pf-card:active { filter: brightness(1.35); }
.pf-note { margin: 0; font-size: 12px; line-height: 1.5; color: var(--dim); }

/* ------------------------------------------ Funky Balls: FAST / RECALL */
.touch-bar {
  position: fixed;
  right: 14px;
  bottom: 16px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.touch-bar button {
  min-width: 108px;
  padding: 12px 14px;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.15em;
  color: #fff;
  cursor: pointer;
  border: 1px solid var(--lime);
  background: rgba(4, 2, 13, 0.82);
  box-shadow: inset 0 0 12px rgba(141, 255, 42, 0.25);
  clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
}
.touch-bar button.on { color: #04020d; background: var(--lime); }
.touch-bar button:active { filter: brightness(1.4); }

/* ---------------------------------------------- phone held upright */
@media (orientation: portrait) {
  /* the arena fills the whole width: while playing only the pause button stays,
     small in the top left corner (settings and fullscreen are in the pause menu) */
  body.playing #sys-bar { top: 8px; left: 8px; transform: none; }
  body.playing #sys-bar .sys-btn:not(#btn-pause) { display: none; }
  body.playing #btn-pause { width: 36px; height: 36px; }
  body.playing #hud, body.playing #fb-hud { padding: 8px 10px 6px 52px; }
  /* a shorter HUD leaves more room for the arena: lives and coins share one row */
  #hud .hud-right { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; column-gap: 10px; }
  #hud .hud-right .label, #hud .hud-right .value { flex-basis: 100%; }
  #hud .lives { margin-top: 2px; }
  .hud-coins { margin-top: 2px; font-size: 15px; }
  #hud .chain { margin-top: 0; font-size: 11px; }
  #fb-hud .hud-right { display: flex; flex-direction: column; align-items: flex-end; }
  #fb-hud .hud-coins { margin-top: 0; }
  body.touch #fb-speed { bottom: 140px; }
  /* the longer arena reaches the bottom: the Funky Balls hint sits above the gun */
  body:not(.pf-pc) #fb-hint { bottom: 15%; }
}

@media (max-width: 520px) {
  /* RPG battle: wave info on the left, speed buttons on the right */
  .mb-top { left: 50px; transform: none; gap: 8px; padding: 6px 8px; background: rgba(4, 2, 13, 0.8); }
  .mb-stage { display: none; }
  .mb-wave { font-size: 14px; letter-spacing: 0.1em; }
  .mb-speed { right: 8px; top: 10px; padding: 3px; }
  .mb-speed span { display: none; }
  .mb-speed button { min-width: 34px; padding: 6px; }
  /* the hero cards use the whole width, the arena ends right above them */
  .mb-bottom { left: 8px; right: 8px; bottom: 8px; transform: none; gap: 6px; }
  .mb-team { gap: 8px; }
  .mb-hpbar { width: 100%; }
  /* Neon Bubbles: the arena reaches the bottom now, the "?" sits in the top right corner */
  .bb-top { gap: 8px; padding: 6px 10px; }
  .bb-bar { width: 110px; }
  .bb-help { top: 8px; right: 8px; width: 34px; height: 34px; font-size: 16px; }
}

/* phones and tablets: the RPG hint sits with the hero cards (js/rpg-kampf.js moves it there) */
.mb-bottom .mb-hint { position: static; width: 100%; min-height: 2.6em; padding: 0 6px; font-size: 10px; line-height: 1.3; }
/* phones and tablets: the controls are explained on the first tutorial card and behind "?" */
body:not(.pf-pc) .bb-hint { display: none !important; }
body:not(.pf-pc) .bb-shots span { display: none; }

/* ------------------------------------------ small screens, both ways */
@media (max-width: 860px), (orientation: landscape) and (max-height: 500px) {
  /* lottery: big icon tiles with a name, the long texts only fit on a PC */
  .lot-hub { grid-template-columns: repeat(2, 1fr); gap: 12px; align-content: center; padding: 8px 2px; overflow-y: auto; }
  .lot-hub .hub-card { min-height: auto; height: auto; padding: 16px 8px 14px; gap: 6px; }
  .lot-hub .hub-card p, .lot-hub .hub-go { display: none; }
  .lot-hub .hub-icon { position: relative; zoom: 0.7; }
  .lot-hub .hub-card h3 { font-size: 15px; letter-spacing: 0.08em; }
}

/* upright phone: the round buttons on the left would cover the menus, which have their own BACK button */
@media (orientation: portrait) and (max-width: 860px) {
  body:has(#screen-modes:not(.hidden)) #sys-bar,
  body:has(#screen-collection:not(.hidden)) #sys-bar,
  body:has(#screen-lottery:not(.hidden)) #sys-bar,
  body:has(#screen-skills:not(.hidden)) #sys-bar,
  body:has(#screen-rpg:not(.hidden)) #sys-bar,
  body:has(#screen-bubble:not(.hidden)) #sys-bar,
  body:has(#screen-help:not(.hidden)) #sys-bar,
  body:has(#screen-platform:not(.hidden)) #sys-bar { display: none; }
  body.playing[data-mode="marble"] #sys-bar { display: flex; }
}

/* collection on an upright phone: the item list gets the space,
   the selected item becomes a small bar at the bottom */
@media (orientation: portrait) and (max-width: 860px) {
  .coll { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; gap: 8px; }
  .coll-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
  .tabs { gap: 6px; }
  .tab { padding: 7px 9px; font-size: 10px; letter-spacing: 0.1em; }
  .coll-detail {
    order: 1;
    display: grid;
    grid-template-columns: 84px 1fr;
    align-items: start;
    column-gap: 12px;
    max-height: 36vh;
    padding: 8px 10px 10px;
    overflow-y: auto;
  }
  .coll-preview { grid-row: 1 / 4; width: 84px; height: 84px; min-height: 0; flex: none; }
  .coll-detail .rarity-tag { grid-column: 2; margin: 0; padding: 2px 6px; font-size: 8px; letter-spacing: 0.2em; }
  .coll-detail h3 { grid-column: 2; margin: 4px 0 0; font-size: 16px; }
  .coll-detail .abilities { grid-column: 2; gap: 4px; margin: 4px 0 8px; }
  .coll-detail .ab .ability-desc { font-size: 11px; line-height: 1.35; }
  #coll-equip { grid-column: 1 / -1; padding: 10px; font-size: 13px; }
}

/* ------------------------------------------- phone held sideways */
@media (orientation: landscape) and (max-height: 500px) {
  /* keep menus clear of the system buttons on the left */
  .screen { padding-left: 62px; }
  .title-panel { padding: 12px 24px; }
  .title-panel .title-wallet { margin: 0 0 4px; }
  .title-panel h1 { margin: 4px 0; font-size: 30px; }
  .title-panel .tagline { display: none; }
  .title-panel .btn { padding: 10px 18px; }
  .title-panel .menu-row { margin-top: 8px; }
  .title-panel .loadout { margin-top: 8px; }
  .title-panel .hi { margin-top: 6px; }
  /* mode select: three small cards per row instead of one big card */
  .mode-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; align-content: start; padding: 10px 2px; }
  .mode-card { min-height: auto; padding: 12px 10px; gap: 6px; }
  .mode-icon { transform: scale(0.6); margin: -22px 0 -20px; }
  .mode-card h3 { font-size: 16px; }
  .mode-card p { font-size: 11px; line-height: 1.35; }

  /* menus: header in one row and the side-by-side layouts from the PC */
  .menu-panel { padding: 10px 14px; }
  .menu-head { grid-template-columns: auto 1fr auto; gap: 10px; }
  .menu-head .wallet { grid-column: auto; justify-self: end; }
  .menu-head h2 { font-size: 22px; }
  .coll { grid-template-columns: 1fr 270px; grid-template-rows: none; }
  .coll-detail { order: 0; overflow-y: auto; }
  .coll-preview { flex: 1; height: auto; min-height: 90px; }
  .coll-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .skills, .plinko { grid-template-columns: 1fr 260px; grid-template-rows: none; overflow-y: visible; margin-top: 8px; }
  .skill-map, .plinko-board { min-height: 0; }
  .plinko-side { overflow-y: auto; }
  .lot-hub { grid-template-columns: repeat(4, 1fr); }
  .box-offers { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .offer img { max-width: 120px; }
  /* Neon Bubbles: tutorial and result cards must fit the low screen */
  .bb-tut-panel, .bb-res-panel, .bm-card, .sd-card { max-height: calc(100% - 16px); overflow-y: auto; }
  .bb-tut-panel { width: min(600px, 80vw); gap: 6px; padding: 12px 18px; }
  .bb-tut-img { width: 76px; height: 76px; }
  .bb-tut-img img { width: 86px; height: 86px; }
  .bb-tut-card h3 { font-size: 18px; }
  .bb-tut-card p { max-width: 60ch; font-size: 12px; line-height: 1.4; }
  /* Black Jack: table on the left, chips and buttons on the right */
  #lot-bj { flex-direction: row; gap: 10px; margin-top: 8px; }
  .bj-table { padding: 8px; }
  .bj-row { gap: 4px; }
  .bj-hand { min-height: 94px; }
  .bj-rules { font-size: 8px; letter-spacing: 0.1em; }
  .bj-controls { flex: 0 0 220px; align-items: center; }
  .chip { width: 46px; height: 46px; font-size: 11px; }

  /* RPG hub: header in one row, loot + buttons + battle in one low row */
  .rpg-top { grid-template-columns: 1fr auto 1fr; padding: 8px 14px 14px; }
  .rpg-wallets { grid-column: auto; justify-self: end; }
  .rpg-kicker { display: none; }
  .hub-plate { top: 58px; }
  .run-stats { top: 92px; }
  .rpg-dock { left: 62px; right: 12px; bottom: 10px; grid-template-columns: minmax(0, 1.4fr) auto minmax(0, 1fr); gap: 10px; }
  .afk-chest { grid-column: auto; gap: 4px; padding: 8px 12px; }
  .afk-head b { font-size: 18px; }
  .afk-loot { font-size: 13px; }
  .afk-rate { display: none; }
  .dock-mid { gap: 6px; }
  .dock-btn { min-width: 0; padding: 9px 12px; }
  .battle-btn { padding: 8px 14px; }
  .battle-btn .bb-label { font-size: 20px; }
  /* RPG formation: one compact screen, the round buttons stay free on the left */
  .rpg-screen[data-view="form"] .rpg-wallets { display: none; }
  #rpg-form { padding: 52px 12px 8px 62px; gap: 6px; }
  .form-info { flex-direction: row; gap: 14px; }
  .form-lineup { width: min(520px, 100%); gap: 8px; }
  .lu-slot { padding: 6px 2px 5px; gap: 2px; }
  .lu-ball { width: min(62px, 80%); }
  .form-lineup-hint { display: none; }
  .form-panel { grid-template-columns: minmax(0, 1fr) auto; padding: 8px 10px; gap: 6px 12px; }
  .form-roster { min-height: 0; padding: 2px 2px 4px; }
  .form-roster .hcard { width: 70px; height: 86px; }
  .form-roster .hcard img { width: 70px; height: 70px; }
  .rpg-begin { width: auto; padding: 12px 18px; font-size: 14px; }
  /* RPG heroes: list on the left, details on the right (like on PC) */
  .hero-roster-wrap { left: 62px; right: calc(50% + 4px); top: 58px; bottom: 10px; display: flex; flex-direction: column; }
  .hero-roster { flex: 1; min-height: 0; max-height: none; align-content: flex-start; }
  .hero-roster-head { font-size: 8px; letter-spacing: 0.15em; }
  .hero-panel { left: calc(50% + 4px); right: 10px; top: 58px; bottom: 10px; width: auto; max-height: none; }

  /* RPG battle: hero cards 2 x 2 in the free space left of the arena */
  .mb-bottom { left: 62px; bottom: 8px; transform: none; align-items: flex-start; gap: 6px; }
  .mb-team { display: grid; grid-template-columns: repeat(2, auto); gap: 6px; }
  .mbh { width: 64px; height: 74px; }
  .mbh img { width: 68px; height: 68px; }
  .mbh-type { padding: 1px 4px 1px 6px; font-size: 7px; letter-spacing: 0; }
  .mbh.active { transform: translateX(6px); }
  .mb-hpbar { width: 134px; grid-template-columns: 1fr; gap: 2px; }
  .mb-hp-label { font-size: 8px; }
  .mb-hp-text { font-size: 11px; }
  .mb-bottom .mb-hint { width: 134px; min-height: 0; font-size: 8px; }
}

/* collection: level and stars of a hero card */
.ic-lvl { margin-top: 2px; font-family: var(--font-mono); font-size: 11px; color: var(--gold); }
.hero-card .ic-img img { transform: scale(1.1); }
