/* Bubble Shooter Xmas: the game fills its frame from edge to edge, with square corners and nothing around it.
   Wide frames (an 800 x 600 iframe, laptops) get the game on the left and a panel on the right, upright frames
   (phones) a bar on top. Menus open as cards on top. */
:root {
  box-sizing: border-box;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  --bar: #091126;          /* score bar and panel */
  --bar-ink: #f3f7ff;
  --bar-soft: #8ea5d6;
  --snow-ink: #34507f;     /* texts on the snow, as in the picture ("misses left", "next") */
  --card: #152649;         /* menus */
  --ink: #f3f7ff;
  --ink-soft: #adbee6;
  --line: #2d4782;
  --primary: #ffd76a;      /* gold: the buttons and "Shooter" in the name */
  --primary-ink: #3a2405;
  --red: #ff7b7b;          /* the last word of the name, in script */
  --snow: #f4f9ff;
  --focus: #ffd76a;
  --backdrop: rgba(4, 8, 22, 0.66);
  --font: "Fredoka", "Nunito", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  --script: "Pacifico", "Fredoka", "Nunito", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: inherit; }
html, body { height: 100%; overflow: hidden; }                 /* the page never scrolls, also not with the space bar */
html { background: var(--bar); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink); font-family: var(--font);
  -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none;
}
#app { height: 100%; }
#wrap { display: flex; flex-direction: column; height: 100%; background: var(--bar); }
/* the game picture, and under it the snow going on where the frame is taller than the game (the script sets its colours) */
#stage { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; align-items: center; }
#ground { flex: 1 1 0; min-height: 0; }
.hud { position: relative; display: flex; align-items: center; gap: 26px; min-height: 54px; padding: 7px 9px 7px 24px; color: var(--bar-ink); background: linear-gradient(180deg, #101e42 0%, #081024 100%); }
#hudArt { display: none; }
/* The game name, centered in the score bar: "Bubble Shooter" with its last word in script under it.
   When it doesn't fit, the bar gets a second line for it and the name goes on one line. */
.brand {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  margin: 0; font-size: 21px; font-weight: 700; line-height: 1; letter-spacing: 0.01em; text-align: center;
  color: var(--bar-ink); white-space: nowrap; pointer-events: none;
}
.brand span, .card h2 span { color: var(--primary); }
.brand em, .card h2 em { font-family: var(--script); font-style: normal; font-weight: 400; letter-spacing: 0; color: var(--red); }
.brand em { display: block; font-size: 0.7em; line-height: 1.1; margin: 2px 0 -4px; }
/* A narrow bar (a small tablet): slightly smaller buttons, so the name still fits in the middle */
.hud.compact { gap: 16px; padding-left: 20px; }
.hud.compact .icon { width: 34px; height: 34px; }
.hud.compact .tools { gap: 5px; }
.hud.compact .stat .v { font-size: 19px; }
.hud.two-rows { flex-wrap: wrap; row-gap: 5px; gap: 5px 16px; padding: 9px 8px 6px 20px; }
.hud.two-rows .brand { position: static; transform: none; flex: 0 0 100%; font-size: 18px; }
.hud.two-rows .brand em { display: inline; font-size: 1em; line-height: 1; margin: 0; }
.hud.two-rows .stat .v { font-size: 18px; }
.hud.two-rows .icon { width: 34px; height: 34px; }
.hud.two-rows .tools { gap: 5px; }
/* An upright phone with height to spare: the bar is a header, with the name large on top (the script sets its sizes) */
.hud.tall { align-content: space-evenly; padding-top: 10px; padding-bottom: 10px; }
.hud.tall .brand { line-height: 1.04; }
.hud.tall .brand em { display: block; font-size: 0.8em; line-height: 1.24; margin: 0; }
@media (min-width: 381px) {            /* a narrower phone keeps the smaller scores and buttons, so six digits still fit beside them */
  .hud.tall .stat .v { font-size: 21px; }
  .hud.tall .icon { width: 40px; height: 40px; }
  .hud.tall .tools { gap: 6px; }
}
.hud.tall .foot { left: 8px; top: 7px; bottom: auto; width: auto; }          /* the version number: small in the top-left corner */
.hud.tall #version { writing-mode: horizontal-tb; transform: none; }
.stat { display: flex; flex-direction: column; line-height: 1.05; }
.stat .k { font-size: 12px; font-weight: 500; color: var(--bar-soft); }
.stat .v { font-size: 21px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tools { margin-left: auto; display: flex; gap: 6px; }
.icon {
  width: 40px; height: 40px; padding: 0; border: 0; border-radius: 12px;
  display: grid; place-items: center; cursor: pointer;
  color: var(--bar-ink);                                     /* like frosted glass: lighter at the top, a thin bright edge */
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.17), rgba(255, 255, 255, 0.07));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24), inset 0 0 0 1px rgba(255, 255, 255, 0.07);
}
.icon:hover { background: linear-gradient(180deg, rgba(255, 255, 255, 0.27), rgba(255, 255, 255, 0.14)); }
.icon svg { width: 22px; height: 22px; }
.icon[aria-pressed="false"] { color: var(--bar-soft); }       /* music or sound switched off */
.icon:disabled { opacity: 0.4; cursor: default; background: linear-gradient(180deg, rgba(255, 255, 255, 0.17), rgba(255, 255, 255, 0.07)); }   /* no music button while the sound is off */
/* The version number lives in the HUD. In the bar on top it stands upright along the left edge, small and soft. */
.foot { position: absolute; left: 0; top: 0; bottom: 0; width: 17px; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.site { display: none; }
#version { font-size: 9px; font-weight: 500; line-height: 1; letter-spacing: 0.05em; color: var(--bar-soft); opacity: 0.8; writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; }

/* Landscape frames (an 800 x 600 iframe, laptops, Chromebooks, phones on their side): the game stands on the left
   at the full height of the frame, and the bar is a panel on the right that takes all the width that is left.
   The panel is drawn for 248 x 600 px (an 800 x 600 frame); --k scales it for other frames (the script sets it,
   with --garland, --snow and the place of the texts on the snow). The fir garland of the game goes on along the
   panel's top and the snow along its bottom: #hudArt is that picture. */
#wrap.side { flex-direction: row-reverse; }
#wrap.side #stage { flex: 0 0 auto; }
#wrap.side .hud {
  flex: 1 1 0; min-width: 0; min-height: 0; overflow: hidden;
  flex-direction: column; align-items: center; gap: 0; text-align: center;
  padding: calc(var(--garland, 21px) + 15px * var(--k, 1)) calc(12px * var(--k, 1)) calc(var(--snow, 45px) + 13px * var(--k, 1));
  background: linear-gradient(180deg, #080f2b 0%, #0c1a42 46%, #122b5c 100%);
  box-shadow: inset 1px 0 0 rgba(176, 202, 255, 0.2);       /* a thin line of light: the wall of the field */
}
#wrap.side #hudArt { display: block; position: absolute; left: 0; top: 0; z-index: 0; pointer-events: none; }
#wrap.side .brand, #wrap.side .stat, #wrap.side .tools { position: relative; z-index: 1; }
#wrap.side .brand { left: auto; top: auto; transform: none; white-space: normal; font-size: max(19px, calc(38px * var(--k, 1))); line-height: 1.04; }
#wrap.side .brand em { font-size: max(17px, 0.8em); line-height: 1.24; margin: calc(1px * var(--k, 1)) 0 0; }
/* the scores stand halfway between the name and the buttons, each on a tile of frosted glass as wide as the buttons */
#wrap.side .hud { --btn: max(40px, calc(44px * var(--k, 1))); --gap: max(10px, calc(10px * var(--k, 1))); --tiles: calc(2 * var(--btn) + var(--gap)); }
#wrap.side .hud.row4 { --gap: max(6px, calc(8px * var(--k, 1))); --tiles: calc(4 * var(--btn) + 3 * var(--gap)); }
#wrap.side .stat {
  align-items: center; width: var(--tiles); margin-top: var(--gap); padding: calc(8px * var(--k, 1)) calc(6px * var(--k, 1)) calc(7px * var(--k, 1));
  border-radius: max(12px, calc(13px * var(--k, 1)));
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.04));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}
#wrap.side .brand + .stat { margin-top: auto; }
#wrap.side .stat .k { font-size: max(12px, calc(14px * var(--k, 1))); }
#wrap.side .stat .v { font-size: max(21px, calc(34px * var(--k, 1))); }
/* the buttons: four in a row where the panel is wide enough (.row4), otherwise two by two */
#wrap.side .tools { margin: auto 0 0; display: grid; grid-template-columns: repeat(2, auto); justify-content: center; gap: var(--gap); }
#wrap.side .hud.row4 .tools { grid-template-columns: repeat(4, auto); }
#wrap.side .icon { width: var(--btn); height: var(--btn); border-radius: max(12px, calc(13px * var(--k, 1))); }
#wrap.side .icon svg { width: max(22px, calc(24px * var(--k, 1))); height: max(22px, calc(24px * var(--k, 1))); }
/* a very small frame (not higher than 310 px): everything in the panel a size smaller, so it still fits */
@media (max-height: 310px) {
  #wrap.side .hud { --btn: 34px; --gap: 6px; padding-top: calc(var(--garland, 21px) + 3px); padding-bottom: calc(var(--snow, 45px) + 3px); }
  #wrap.side .hud.row4 { --gap: 6px; }
  #wrap.side .brand { font-size: 16px; line-height: 1; }
  #wrap.side .brand em { font-size: 14px; line-height: 1.1; }
  #wrap.side .stat { margin-top: 4px; padding: 3px 4px 2px; border-radius: 9px; }
  #wrap.side .stat .k { font-size: 10px; }
  #wrap.side .stat .v { font-size: 17px; }
  #wrap.side .icon { border-radius: 10px; }
  #wrap.side .icon svg { width: 20px; height: 20px; }
}
/* on the snow: a link to GameBoss.com and the version number, on the line of "misses left" and "next" */
#wrap.side .foot {
  left: 0; right: 0; top: var(--foot-top, 560px); bottom: auto; width: auto; height: var(--foot-h, 25px); z-index: 1;
  padding: 0 calc(10px * var(--k, 1)); flex-wrap: wrap; align-content: center; gap: 0 calc(9px * var(--k, 1)); align-items: baseline; pointer-events: auto;
}
#wrap.side .site { display: block; font-size: max(11px, calc(17.5px * var(--k, 1))); font-weight: 600; line-height: 1.15; letter-spacing: 0.01em; color: var(--snow-ink); text-decoration: none; }
#wrap.side .site:hover { text-decoration: underline; }
.site:focus-visible { outline: 3px solid #1d3a78; outline-offset: 2px; border-radius: 4px; }
#wrap.side #version { writing-mode: horizontal-tb; transform: none; font-size: max(9px, calc(15px * var(--k, 1))); font-weight: 600; letter-spacing: 0.02em; color: var(--snow-ink); opacity: 0.78; }
#game { display: block; touch-action: none; cursor: default; outline: none; }   /* the normal arrow, no crosshair */
#game:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
button { font: inherit; color: inherit; }
button:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

/* GameBoss splash: white with the logo, over everything (nothing underneath can be clicked) */
#splash {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 100;   /* (written out: browsers from before 2021 do not know the short form "inset") */
  display: grid; place-items: center;
  background: #fff;
  transition: opacity 0.3s ease-in, visibility 0s linear 0.3s;
}
#splash.out { opacity: 0; visibility: hidden; }
/* the logo grows with the screen: about 340 px in an 800 x 600 iframe, 70 % of the width on upright phones,
   about a third of the width on a big full screen, never wider than 640 px */
#splash img { display: block; width: clamp(240px, max(56vmin, min(70vw, 45vh)), 640px); max-width: 90vw; height: auto; animation: logoIn 0.45s ease-out both; }
@keyframes logoIn { from { opacity: 0; transform: scale(0.94); } }
@keyframes logoFade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { #splash img { animation-name: logoFade; } }
/* The loader (v1.29): a bar with a line of text, low in the splash, for a game that has not started 2.6 seconds
   after the page began to load. The script in the head of the page fetches js/game.js itself, counts what has
   arrived and makes these elements when they are needed. The colours are those of the logo. The letters are
   the device's own: the web font may not be there yet on a slow connection, which is when this shows. */
#splash .load {
  position: absolute; left: 50%; bottom: 8%; width: 340px; max-width: 72vw; transform: translateX(-50%);
  text-align: center; color: #3e3c3c; font: 600 15px/1.3 "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  opacity: 0; transition: opacity 0.4s ease;
}
#splash .load.on { opacity: 1; }
#splash .load-track { height: 12px; border-radius: 6px; background: rgba(62, 60, 60, 0.16); overflow: hidden; }
#splash .load-fill { width: 0; height: 100%; border-radius: 6px; background: #f82d98; transition: width 0.3s linear; }
#splash .load-pct { margin-top: 8px; font-size: 16px; font-weight: 700; }
#splash .load-msg { margin-top: 2px; min-height: 1.3em; text-wrap: balance; }   /* (two lines of about the same length, where a browser can) */
#splash .load.failed .load-track { display: none; }   /* the game could not be loaded: the two lines say so */
@media (prefers-reduced-motion: reduce) { #splash .load, #splash .load-fill { transition: none; } }

/* Overlay screens */
#overlay {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 10;
  display: grid; place-items: center; overflow-y: auto;
  padding: calc(22px + env(safe-area-inset-top, 0px)) calc(16px + env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) calc(16px + env(safe-area-inset-left, 0px));
  background: var(--backdrop);
}
#overlay[hidden] { display: none; }
.card {
  position: relative; width: min(480px, 100%); padding: 28px 24px 20px; border-radius: 24px;
  background: var(--card) linear-gradient(180deg, #1d3567 0%, #122246 100%); color: var(--ink);
  border: 1px solid rgba(150, 180, 245, 0.3);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.09);
  -webkit-user-select: text; user-select: text;
}
/* a layer of snow on top of every card */
.card::before {
  content: ""; position: absolute; left: 14px; right: 14px; top: -11px; height: 30px; pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 30' preserveAspectRatio='none'%3E%3Cpath fill='%23f4f9ff' d='M4,16 C0,8 8,3 22,5 C40,0 70,1 92,5 C120,0 160,1 186,4 C214,0 250,1 276,5 C304,0 340,1 364,5 C382,2 398,6 396,16 C394,22 384,22 380,17 C372,18 370,28 362,28 C354,28 354,18 346,17 C330,16 318,17 300,17 C294,17 294,24 288,24 C282,24 282,17 276,17 C240,16 220,17 196,17 C190,17 190,27 183,27 C176,27 176,17 170,17 C140,16 120,17 100,17 C95,17 95,23 90,23 C85,23 85,17 80,17 C60,16 44,17 30,17 C24,17 22,24 14,22 C8,21 5,19 4,16 Z'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}
.card h1, .card h2 { margin: 0 0 10px; font-size: 32px; line-height: 1.05; font-weight: 700; letter-spacing: -0.01em; }
.card h2 em { display: block; font-size: 0.66em; line-height: 1.15; margin-top: 1px; }
.card h2.subhead { margin: 16px 0 8px; font-size: 19px; line-height: 1.25; font-weight: 600; letter-spacing: 0; }
.card p { margin: 0 0 10px; font-size: 16px; line-height: 1.45; }
.muted { color: var(--ink-soft); }
.tally { display: grid; gap: 4px; max-width: 300px; margin: 4px 0 14px; }
.tally div { display: flex; justify-content: space-between; align-items: baseline; font-size: 18px; }
.tally dt { color: var(--ink-soft); }
.tally dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.tally .total { margin-top: 2px; padding-top: 6px; border-top: 2px solid var(--line); font-size: 21px; }
.tally .total dt { color: var(--ink); font-weight: 600; }
.actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.solid, .ghost { border-radius: 999px; padding: 10px 20px; font-size: 16px; font-weight: 600; line-height: 1.15; border: 2px solid var(--primary); cursor: pointer; }
.solid {                                                      /* polished gold */
  background: var(--primary) linear-gradient(180deg, #ffe99c 0%, #ffd55e 48%, #f6b93a 100%); color: var(--primary-ink); border-color: #f2b637;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75), 0 6px 18px rgba(255, 186, 60, 0.26);
}
.solid:hover { filter: brightness(1.06); }
/* "Play again" comes up pale and gets its colour in 0.7 s: that long it does not work yet, so a press that was meant
   as a shot does not start a new game before the result has been seen (AGAIN_MS in js/game.js) */
#btnAgain { animation: againIn 0.7s ease-in; }
@keyframes againIn { from { opacity: 0.35; } }
.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.ghost:hover { border-color: var(--primary); }
/* a card in another language than English that does not fit (see fitCard in js/game.js): the buttons closer together, the first paragraph left out */
.card.snug .actions { gap: 8px; }
.card.snug .solid, .card.snug .ghost { padding: 10px 12px; font-size: 15px; }
.card.brief #intro { display: none; }


@media (max-width: 520px) and (max-height: 700px) {
  .card { padding: 22px 16px 14px; }
  #menuTitle { font-size: 24px; margin-bottom: 8px; }
  .card p { font-size: 14px; line-height: 1.38; margin-bottom: 8px; }
  .card h2.subhead { font-size: 16px; margin: 10px 0 6px; }
  .actions { margin-top: 12px; }
}
/* A small upright phone (320 x 568): the menu just fits, with its lower edge in view */
@media (max-width: 520px) and (max-height: 580px) {
  #overlay { padding-top: calc(14px + env(safe-area-inset-top, 0px)); padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
  .card { padding: 18px 16px 12px; }
  .card p { margin-bottom: 6px; }
  .card h2.subhead { margin: 8px 0 4px; }
}
/* A low, wide frame (a phone on its side): the menu uses the width and leaves out its first paragraph, so that
   Resume and New game are in view without scrolling */
@media (max-height: 480px) and (min-width: 560px) {
  #overlay { padding-top: calc(18px + env(safe-area-inset-top, 0px)); padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
  .card[data-shows="menu"] { width: min(700px, 100%); padding: 20px 22px 14px; }
  #menuTitle { font-size: 24px; margin-bottom: 6px; }
  #menuTitle em { display: inline; font-size: 0.9em; }
  #intro { display: none; }
  .card[data-shows="menu"] p { font-size: 14px; line-height: 1.36; margin-bottom: 6px; }
  .card[data-shows="menu"] h2.subhead { font-size: 16px; margin: 4px 0; }
  .card[data-shows="menu"] .actions { margin-top: 10px; }
}
@media (max-width: 480px) {
  .hud { gap: 18px; min-height: 48px; padding: 6px 8px 6px 19px; }
  .stat .v { font-size: 18px; }
  .icon { width: 36px; height: 36px; }
  .card { padding: 24px 18px 18px; border-radius: 20px; }
  .card h1, .card h2 { font-size: 28px; }
  .card h2.subhead { font-size: 18px; }
  .card p { font-size: 15px; }
}
