/* Game font (Baloo 2, OFL license in assets/fonts): ships in the package, with no Google Fonts call. */
@font-face { font-family: 'Baloo 2'; font-style: normal; font-weight: 700; font-display: swap; src: url(./assets/fonts/baloo-2-latin-ext-700.woff2) format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: 'Baloo 2'; font-style: normal; font-weight: 700; font-display: swap; src: url(./assets/fonts/baloo-2-latin-700.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'Baloo 2'; font-style: normal; font-weight: 800; font-display: swap; src: url(./assets/fonts/baloo-2-latin-ext-800.woff2) format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: 'Baloo 2'; font-style: normal; font-weight: 800; font-display: swap; src: url(./assets/fonts/baloo-2-latin-800.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }

/* Ocean Block Puzzle. Measures in --u = 1% of the reference's shorter side (941 px), scaled to fit the screen:
   portrait, 1u = 1% of the reference width; landscape, 1u = 1% of the height. Colors taken from the reference designs (docs/mockups). */
:root {
  --u: min(1vw, calc(100vh * 941 / 1672 / 100));
  --ink: #062024;
  --gold: #fff4dc;
  --gold-deep: #9fdcff;
  --cream: #eef9ff;
  --plum: #0a2a30;
  --veil: rgba(2, 10, 20, 0.6);
  --font: 'Baloo 2', 'Nunito', 'Fredoka', system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', 'Noto Sans CJK JP', 'Hiragino Sans', 'Yu Gothic', 'Microsoft YaHei', 'Malgun Gothic', sans-serif;
  --outline: calc(var(--u) * 0.36);
}
@media (min-aspect-ratio: 23/20) {
  :root { --u: min(0.8vh, calc(100vw * 941 / 1672 / 125)); }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #06161c;
  color: var(--cream);
  font-family: var(--font);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  overscroll-behavior: none;
}

canvas#game { position: fixed; inset: 0; display: block; touch-action: none; }

/* text with a dark outline (reference style): outline under the fill */
.ol, h2, .btn, .row, .lang-grid button, .best-plaque, .big-score, .near, .label, .revive-text, .tap-start, #revive-count {
  -webkit-text-stroke: var(--outline) var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 calc(var(--u) * 0.35) 0 rgba(2, 12, 24, 0.75);
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(env(safe-area-inset-top), 8px) max(env(safe-area-inset-right), 8px) max(env(safe-area-inset-bottom), 8px) max(env(safe-area-inset-left), 8px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s ease, visibility 0.22s;
  background: var(--veil);
  z-index: 10;
}
.overlay.show { opacity: 1; visibility: visible; pointer-events: auto; }
#title { background: transparent; }
#adcover { z-index: 30; background: rgba(0, 0, 0, 0.92); }

/* ---------- art pieces (9 slices; src/nine.js pastes onto a canvas to avoid seams) ---------- */
.panel {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--u) * 3.2);
  width: calc(var(--u) * 60.4);
  padding: calc(var(--u) * 3.6) calc(var(--u) * 2.6) calc(var(--u) * 4);
  border: solid transparent;
  border-width: calc(var(--u) * 3.4);
  border-image: url(./assets/skin/panel-plain.webp) 64 fill / calc(var(--u) * 7.7) stretch;
  transform: scale(0.92);
  transition: transform 0.25s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.overlay.show .panel { transform: none; }
.panel::before, .plaque::before, .disc::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  width: calc(var(--u) * 6.4);
  height: calc(var(--u) * 6.4);
  transform: translate(-50%, -62%);
  background: url(./assets/skin/stud.webp) center / contain no-repeat;
  pointer-events: none;
}
.panel::before { top: calc(var(--u) * -3.4); transform: translate(-50%, -38%); }

.plaque {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: solid transparent;
  border-width: calc(var(--u) * 3.4) calc(var(--u) * 6.2);
  border-image: url(./assets/skin/plaque.webp) 60 110 fill / calc(var(--u) * 3.4) calc(var(--u) * 6.2) stretch;
}
.plaque::before { width: calc(var(--u) * 5.3); height: calc(var(--u) * 5.3); top: calc(var(--u) * -3.4); transform: translate(-50%, -40%); }
.plaque.small { border-image-width: calc(var(--u) * 1.9) calc(var(--u) * 3.6); }
.plaque.small::before { display: none; }

h2 {
  margin: 0;
  font-weight: 800;
  font-size: calc(var(--u) * 8);
  line-height: 1;
  color: var(--gold);
  background: linear-gradient(#e4f8ff, #5ee0d0 55%, #3a98e0);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-align: center;
}
/* the outline disappears with the gradient's transparent text: the title uses a surrounding shadow */
h2 { -webkit-text-stroke: 0; filter: drop-shadow(0 0 0 var(--ink)) drop-shadow(0 calc(var(--u) * 0.4) 0 var(--ink)) drop-shadow(calc(var(--u) * 0.3) 0 0 var(--ink)) drop-shadow(calc(var(--u) * -0.3) 0 0 var(--ink)) drop-shadow(0 calc(var(--u) * -0.3) 0 var(--ink)); text-shadow: none; }

/* src/nine.js replaces the browser's 9 slices with a single image (no 1 px seam at the joint) */
.nine { border-image: none !important; background-size: 100% 100% !important; background-origin: border-box !important; background-clip: border-box !important; background-repeat: no-repeat !important; }

/* ---------- buttons ---------- */
.btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: calc(var(--u) * 2.4);
  width: 100%;
  min-height: 44px;
  height: calc(var(--u) * 12.8);
  padding: 0;
  font: 800 calc(var(--u) * 6.6) / 1 var(--font);
  color: var(--gold);
  background: none;
  border: solid transparent;
  border-width: calc(var(--u) * 1.5) calc(var(--u) * 3);
  border-image: url(./assets/skin/btn-plum.webp) 90 100 fill / calc(var(--u) * 5.6) calc(var(--u) * 6.2) stretch;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.08s ease;
  white-space: nowrap;
}
.btn.primary { border-image-source: url(./assets/skin/btn-green.webp); }
.btn:active { transform: translateY(calc(var(--u) * 0.6)) scale(0.97); filter: brightness(0.88); }
.btn:focus-visible, .disc:focus-visible, .switch:focus-visible, .lang-grid button:focus-visible, .lang-value:focus-visible { outline: 3px solid #f2fbff; outline-offset: 3px; }
.btn svg { width: calc(var(--u) * 6); height: calc(var(--u) * 6); flex: none; color: var(--gold); filter: drop-shadow(0 0 calc(var(--u) * 0.35) var(--ink)) drop-shadow(0 calc(var(--u) * 0.3) 0 var(--ink)); }
.btn .btn-ico { width: calc(var(--u) * 10.4); height: auto; flex: none; }
.btn.big span { overflow: hidden; text-overflow: ellipsis; }
.btn.link::after { content: ''; position: absolute; inset: -14px -24px; } /* 44 px touch target without changing the text size */
.btn.link {
  height: auto;
  min-height: 0;
  width: auto;
  border: 0;
  border-image: none;
  font-size: calc(var(--u) * 4.4);
  font-weight: 700;
  color: #dff4ff;
  text-decoration: underline;
  text-underline-offset: calc(var(--u) * 0.8);
  -webkit-text-stroke: 0;
  padding: 0;
  position: relative;
}

.disc {
  position: relative;
  width: calc(var(--u) * 17.6);
  height: calc(var(--u) * 17.6);
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: url(./assets/skin/disc.webp) center / contain no-repeat;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.08s ease;
}
.disc::before { width: calc(var(--u) * 3.6); height: calc(var(--u) * 3.6); transform: translate(-50%, -30%); }
.disc img { width: 54%; height: auto; }
.disc svg { width: 52%; height: 52%; color: var(--gold); filter: drop-shadow(0 0 calc(var(--u) * 0.35) var(--ink)) drop-shadow(0 calc(var(--u) * 0.3) 0 var(--ink)); }
.disc:active { transform: scale(0.94); }
.discs { display: flex; justify-content: center; gap: calc(var(--u) * 7.3); }
[hidden] { display: none !important; }

/* ---------- menu ---------- */
.title-wrap { display: flex; flex-direction: column; align-items: center; width: calc(var(--u) * 82); }
.logo { margin: calc(var(--u) * 5) 0 0; width: calc(var(--u) * 71.4); line-height: 0; }
.logo img { width: 100%; height: auto; }
.tap-start {
  margin: calc(var(--u) * 4) 0 calc(var(--u) * 4.5);
  font-weight: 800;
  font-size: calc(var(--u) * 6.4);
  line-height: 1;
  color: var(--cream);
  animation: breathe 2.4s ease-in-out infinite;
}
#title.started .tap-start { visibility: hidden; }
@keyframes breathe { 50% { opacity: 0.55; } }
.title-actions { display: flex; flex-direction: column; align-items: center; gap: calc(var(--u) * 3.8); width: 100%; }
.title-actions .btn.big { height: calc(var(--u) * 18.4); font-size: calc(var(--u) * 7.6); border-image-width: calc(var(--u) * 8.6) calc(var(--u) * 9.4); }
.title-actions .btn.primary { height: calc(var(--u) * 20.4); font-size: calc(var(--u) * 8.4); }
.title-actions .btn svg { width: calc(var(--u) * 8); height: calc(var(--u) * 8); }
.btn.daily { justify-content: center; gap: calc(var(--u) * 3); }
.daily-text { display: flex; flex-direction: column; align-items: center; line-height: 1.05; min-width: 0; font-size: 0.86em; }
.daily-text > span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.daily-text small { font-size: 0.62em; color: var(--gold-deep); }
.best-plaque { gap: calc(var(--u) * 2.6); font-weight: 800; font-size: calc(var(--u) * 6.8); color: var(--gold); line-height: 1; }
.best-plaque img { width: 1.25em; height: auto; }
.title-actions .best-plaque { min-width: calc(var(--u) * 50); height: calc(var(--u) * 13.7); margin-top: calc(var(--u) * 1); }
.title-actions .discs { margin-top: calc(var(--u) * 1); }
.privacy-notice { margin-top: calc(var(--u) * 2); width: calc(var(--u) * 80); color: #b8a8c8; font-size: max(11px, calc(var(--u) * 2.6)); line-height: 1.35; text-align: center; -webkit-text-stroke: 0; }
.privacy-notice summary { cursor: pointer; padding: 4px; list-style: none; opacity: 0.7; }
.privacy-notice p { margin: 4px 0; text-align: left; }



/* panel center a little below the middle of the screen, as in the portrait references */
@media (max-aspect-ratio: 23/20) {
  #settings .panel { margin-top: calc(var(--u) * 14.7); }
  #langs .panel { margin-top: calc(var(--u) * 9.3); }
  #pause .panel { margin-top: calc(var(--u) * 7); }
  #over .panel { margin-top: calc(var(--u) * 17); }
  #revive .panel { margin-top: calc(var(--u) * 5); }
}


/* ---------- pause ---------- */
#pause .panel { width: calc(var(--u) * 60.4); }
#pause h2 { font-size: calc(var(--u) * 9.6); }
#pause .btn.big { width: calc(var(--u) * 47.6); height: calc(var(--u) * 12.8); }
#pause .disc { width: calc(var(--u) * 12.5); height: calc(var(--u) * 12.5); }
#pause .disc::before { display: none; }
#pause .discs { gap: calc(var(--u) * 5.4); }

/* ---------- settings ---------- */
.settings-panel { width: calc(var(--u) * 74.2); gap: calc(var(--u) * 2.3); padding: calc(var(--u) * 1) calc(var(--u) * 0.2) calc(var(--u) * 1.6); }
.title-plaque { border-image-width: calc(var(--u) * 2.4) calc(var(--u) * 4.4); -webkit-text-fill-color: var(--gold); background: none; filter: none; -webkit-text-stroke: var(--outline) var(--ink); text-shadow: 0 calc(var(--u) * 0.35) 0 rgba(2, 12, 24, 0.75); font-size: calc(var(--u) * 6.6); padding: 0 calc(var(--u) * 2); height: calc(var(--u) * 9.4); margin-bottom: calc(var(--u) * 1); }
.title-plaque::before { display: none; }
.row {
  position: relative;
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 2);
  width: calc(var(--u) * 67.2);
  height: calc(var(--u) * 11.5);
  padding: 0 calc(var(--u) * 0.6);
  border: solid transparent;
  border-width: calc(var(--u) * 2.4) calc(var(--u) * 2.4);
  border-image: url(./assets/skin/plaque.webp) 60 60 fill / calc(var(--u) * 2.9) stretch;
  font-weight: 800;
  font-size: calc(var(--u) * 4.4);
  color: var(--gold);
}
.row label, .row .row-label { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row label { flex: 0 0 auto; }
.row-ico { flex: none; width: calc(var(--u) * 8.1); height: calc(var(--u) * 8); margin-left: calc(var(--u) * -0.6); display: grid; place-items: center; background: url(./assets/skin/disc.webp) center / contain no-repeat; }
.row-ico svg { width: 60%; height: 60%; color: var(--gold); filter: drop-shadow(0 0 calc(var(--u) * 0.3) var(--ink)); }
.row output { flex: none; width: calc(var(--u) * 8); text-align: right; font-size: calc(var(--u) * 3.6); color: var(--gold); }

input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  flex: 0 1 calc(var(--u) * 27);
  margin-left: auto;
  min-width: calc(var(--u) * 16);
  height: calc(var(--u) * 5);
  margin: 0;
  background: transparent;
  cursor: pointer;
  --p: 50%;
}
input[type=range]::-webkit-slider-runnable-track {
  height: calc(var(--u) * 3);
  border-radius: 99px;
  background: linear-gradient(90deg, #bfeeff, #2fc4b4) 0 50% / var(--p) 70% no-repeat, url(./assets/skin/track.webp) center / 100% 100% no-repeat;
}
input[type=range]::-moz-range-track {
  height: calc(var(--u) * 3);
  border-radius: 99px;
  background: linear-gradient(90deg, #bfeeff, #2fc4b4) 0 50% / var(--p) 70% no-repeat, url(./assets/skin/track.webp) center / 100% 100% no-repeat;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: calc(var(--u) * 4.8);
  height: calc(var(--u) * 4.8);
  margin-top: calc(var(--u) * -0.9);
  border: 0;
  background: url(./assets/skin/stud.webp) center / contain no-repeat;
}
input[type=range]::-moz-range-thumb { width: calc(var(--u) * 4.8); height: calc(var(--u) * 4.8); border: 0; background: url(./assets/skin/stud.webp) center / contain no-repeat; }

.switch {
  flex: none;
  position: relative;
  width: calc(var(--u) * 15.1);
  height: auto;
  aspect-ratio: 314 / 166;
  padding: 0;
  border: 0;
  border-radius: 99px;
  background: url(./assets/skin/toggle.webp) center / 100% 100% no-repeat;
  cursor: pointer;
}
.switch::after {
  content: '';
  position: absolute;
  inset: 16% 9%;
  border-radius: 99px;
  background: linear-gradient(#2fd36b, #0f8a3c);
  opacity: 0;
  transition: opacity 0.18s;
}
.switch i {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 8%;
  width: 41%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fffaf0, #dff0ff 60%, #8fb6d8);
  box-shadow: 0 calc(var(--u) * 0.4) calc(var(--u) * 0.6) rgba(0, 0, 0, 0.5);
  transform: translateY(-50%);
  transition: left 0.18s cubic-bezier(0.3, 1.3, 0.5, 1);
}
.switch[aria-checked=true]::after { opacity: 1; }
.switch[aria-checked=true] i { left: 51%; }

.lang-value {
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 1.4);
  height: calc(var(--u) * 5.9);
  padding: 0 calc(var(--u) * 1);
  font: 800 calc(var(--u) * 3.9) / 1 var(--font);
  color: var(--gold);
  background: none;
  border: solid transparent;
  border-width: calc(var(--u) * 1.4) calc(var(--u) * 2);
  border-image: url(./assets/skin/plaque.webp) 60 110 fill / calc(var(--u) * 1.4) calc(var(--u) * 2.6) stretch;
  cursor: pointer;
  -webkit-text-stroke: var(--outline) var(--ink);
  paint-order: stroke fill;
}
.lang-value svg { width: calc(var(--u) * 2.4); height: calc(var(--u) * 2.4); }
.settings-panel .btn.big { width: calc(var(--u) * 37.7); height: calc(var(--u) * 10.1); font-size: calc(var(--u) * 5.6); margin-top: calc(var(--u) * 1.5); border-image-width: calc(var(--u) * 4.4) calc(var(--u) * 5); }

/* ---------- languages ---------- */
.langs-panel { width: calc(var(--u) * 65.7); gap: calc(var(--u) * 2.2); padding: calc(var(--u) * 1.4) calc(var(--u) * 1.4) calc(var(--u) * 1.8); }
.langs-panel h2 { font-size: calc(var(--u) * 6.6); }
.lang-grid { display: grid; grid-template-columns: 1fr 1fr; gap: calc(var(--u) * 2.2) calc(var(--u) * 2.2); width: 100%; }
.lang-grid button {
  height: calc(var(--u) * 8.5);
  min-height: 44px;
  padding: 0;
  font: 800 calc(var(--u) * 4.4) / 1 var(--font);
  color: var(--gold);
  background: none;
  border: solid transparent;
  border-width: calc(var(--u) * 1.2) calc(var(--u) * 2);
  border-image: url(./assets/skin/btn-plum.webp) 90 100 fill / calc(var(--u) * 3.6) calc(var(--u) * 4) stretch;
  cursor: pointer;
  white-space: nowrap;
}
.lang-grid button[aria-pressed=true] { filter: brightness(1.18) drop-shadow(0 0 calc(var(--u) * 0.8) rgba(140, 220, 255, 0.8)); }
.lang-grid button[aria-pressed=true]::after { content: ''; display: inline-block; width: 0.95em; height: 0.95em; margin-left: 0.3em; vertical-align: -0.12em; background: url(./assets/skin/ic-check.webp) center / contain no-repeat; }
.langs-panel .btn.big { width: calc(var(--u) * 32.9); height: calc(var(--u) * 9.1); font-size: calc(var(--u) * 5.3); border-image-width: calc(var(--u) * 4) calc(var(--u) * 4.6); }

/* ---------- game over ---------- */
#over .panel { width: calc(var(--u) * 68.9); gap: calc(var(--u) * 1.2); padding-top: calc(var(--u) * 3); padding-bottom: calc(var(--u) * 2); }
#over h2 { font-size: calc(var(--u) * 8.6); }
.label { font-weight: 800; font-size: calc(var(--u) * 3.9); color: var(--cream); line-height: 1; height: calc(var(--u) * 6.2); padding: 0 calc(var(--u) * 1); }
.big-score { font-weight: 800; font-size: calc(var(--u) * 10.2); line-height: 1; color: var(--gold); margin: calc(var(--u) * -1) 0; }
.near { font-weight: 800; font-size: calc(var(--u) * 4); color: var(--cream); text-align: center; opacity: 0; transition: opacity 0.3s; min-height: 1em; }
.near.show { opacity: 1; }
.near-bar {
  position: relative;
  width: calc(var(--u) * 57.4);
  height: calc(var(--u) * 6.4);
  border: solid transparent;
  border-width: calc(var(--u) * 1.4) calc(var(--u) * 2);
  border-image: url(./assets/skin/track.webp) 50 56 fill / calc(var(--u) * 1.4) calc(var(--u) * 2.2) stretch;
}
.near-bar i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 99px; background: linear-gradient(#c8fff4, #5ee0d0 55%, #168a86); transition: width 1s cubic-bezier(0.2, 0.8, 0.2, 1); }
.near-bar img { position: absolute; right: calc(var(--u) * -1.4); top: 50%; width: calc(var(--u) * 4.8); transform: translateY(-50%); }
#over .best-plaque { font-size: calc(var(--u) * 4.4); height: calc(var(--u) * 7.3); width: calc(var(--u) * 30.2); padding: 0; }
#over .btn.big { width: calc(var(--u) * 51.5); }
.ribbon { display: none; position: relative; width: calc(var(--u) * 55.8); aspect-ratio: 900 / 250; margin: calc(var(--u) * -1) 0 calc(var(--u) * -0.5); }
.ribbon.show { display: block; }
.ribbon > img { position: absolute; left: 16%; top: 4%; width: 12%; height: auto; z-index: 1; }
.ribbon svg.rb { width: 100%; height: 100%; display: block; overflow: visible; }
.ribbon svg.rb text { font: 800 74px var(--font); fill: #3a2410; }

/* ---------- second chance ---------- */
.revive-panel { width: calc(var(--u) * 63.5); gap: calc(var(--u) * 1.4); padding-top: calc(var(--u) * 2.6); padding-bottom: calc(var(--u) * 1.2); }
.revive-panel h2 { font-size: calc(var(--u) * 8.4); }
.revive-text { margin: 0; font-weight: 800; font-size: calc(var(--u) * 4.2); line-height: 1.15; text-align: center; color: var(--cream); }
.revive-timer { position: relative; width: calc(var(--u) * 23.2); height: calc(var(--u) * 23.2); background: url(./assets/skin/disc.webp) center / contain no-repeat; display: grid; place-items: center; }
.revive-timer svg { position: absolute; inset: 6%; width: 88%; height: 88%; transform: rotate(-90deg); }
.revive-timer .track { fill: none; stroke: rgba(4, 18, 34, 0.8); stroke-width: 13; }
.revive-timer .ring { fill: none; stroke: #5ee0d0; stroke-width: 13; stroke-linecap: round; stroke-dasharray: 251.3; stroke-dashoffset: 0; }
#revive-count { position: relative; font-weight: 800; font-size: calc(var(--u) * 12); line-height: 1; color: var(--gold); }
.revive-panel .btn.big { width: calc(var(--u) * 50.2); height: calc(var(--u) * 13.3); }
.revive-panel .btn svg { width: calc(var(--u) * 8.4); }

/* ---------- in-game ad buttons ---------- */
.ad-actions { position: fixed; z-index: 5; display: flex; gap: 8px; transform: translate(-50%, -50%); }
.ad-actions.compact .ad-pill span { display: none; }
.ad-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 4px;
  font: 800 15px / 1 var(--font);
  color: var(--gold);
  background: none;
  border: solid transparent;
  border-width: 14px 18px;
  border-image: url(./assets/skin/btn-plum.webp) 90 100 fill / 14px 18px stretch;
  cursor: pointer;
  -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill;
}
.ad-pill svg { width: 18px; height: 18px; }
.ad-tag { font-style: normal; font-size: 10px; padding: 1px 4px; border-radius: 4px; background: var(--gold); color: var(--ink); -webkit-text-stroke: 0; }

/* ---------- simulated ad (test only) ---------- */
.fake-ad { border-image: none; border: 0; background: #222; border-radius: 16px; color: #fff; }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 4px solid #555; border-top-color: #fff; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* reduced motion: same state, no animation */
.calm .tap-start, .calm .panel, .calm .btn, .calm .switch i { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  .tap-start { animation: none; }
  .panel { transition: none; }
}


/* Studio signature at startup (src/studio-splash.js). Copy of the approved studio kit. */
.polar-studio-splash {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 48%, #10283d 0%, #091523 48%, #060e19 100%);
  touch-action: none;
  user-select: none;
  overscroll-behavior: none;
}
.polar-studio-splash__mark {
  position: relative;
  display: block;
  width: min(66vw, 620px);
  opacity: 0;
  will-change: transform, opacity;
}
.polar-studio-splash__mark img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 60svh;
  object-fit: contain;
  filter: drop-shadow(0 0 25px #5bd6ff20);
}
.polar-studio-splash--ready {
  animation: polar-studio-exit 2050ms linear both;
}
.polar-studio-splash--ready .polar-studio-splash__mark {
  animation: polar-studio-enter 750ms cubic-bezier(.16, 1, .3, 1) both;
}
.polar-studio-splash--ready .polar-studio-splash__mark::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(108deg, transparent 42%, #b9eeff10 48%, #e2faff25 50%, #b9eeff10 52%, transparent 58%);
  background-size: 300% 100%;
  mask: url('./assets/brand/polar-games-logo-horizontal.png') center / contain no-repeat;
  opacity: 0;
  animation: polar-studio-sweep 650ms 700ms ease-in-out both;
}
@keyframes polar-studio-enter {
  0% { opacity: 0; transform: translateY(10px) scale(.91); }
  65% { opacity: 1; transform: translateY(-1px) scale(1.015); }
  100% { opacity: 1; transform: none; }
}
@keyframes polar-studio-sweep {
  0% { opacity: 0; background-position: 100% 0; }
  25%, 65% { opacity: 1; }
  100% { opacity: 0; background-position: 0 0; }
}
@keyframes polar-studio-exit {
  0%, 79% { opacity: 1; }
  100% { opacity: 0; }
}
.polar-studio-splash--reduced.polar-studio-splash--ready {
  animation-duration: 700ms;
}
.polar-studio-splash--reduced .polar-studio-splash__mark {
  animation: polar-studio-fade 180ms ease-out both;
}
.polar-studio-splash--reduced .polar-studio-splash__mark::after { display: none; }
@keyframes polar-studio-fade { from { opacity: 0; } to { opacity: 1; } }
@media (max-aspect-ratio: 4/5) {
  .polar-studio-splash__mark { width: min(64vw, 320px); }
  .polar-studio-splash--ready .polar-studio-splash__mark::after { mask-image: url('./assets/brand/polar-games-logo-vertical.webp'); }
}

/* best score: thin golden ring behind the number (reference 07-recorde) */
#over.record .big-score { position: relative; margin: calc(var(--u) * 1.4) 0; }
#over.record .big-score::before {
  content: '';
  position: absolute;
  inset: calc(var(--u) * -2.4) calc(var(--u) * -7);
  border: calc(var(--u) * 0.45) solid rgba(170, 230, 255, 0.85);
  border-radius: 50%;
  box-shadow: 0 0 calc(var(--u) * 3) rgba(120, 210, 255, 0.35), inset 0 0 calc(var(--u) * 3) rgba(120, 210, 255, 0.25);
  -webkit-text-stroke: 0;
}

/* long text (German, Russian): two lines instead of cutting (src/ui.js fitTexts) */
.two-lines { white-space: normal !important; text-overflow: clip !important; overflow: visible !important; line-height: 0.98 !important; text-align: center; }
.row .two-lines { text-align: left; }

/* golden icons (assets/skin/ic-*.webp) */
.ico { display: block; flex: none; height: auto; pointer-events: none; }
.btn .ico { width: calc(var(--u) * 5.6); }
.title-actions .btn .ico { width: calc(var(--u) * 7.7); }
.btn.daily .btn-ico { width: calc(var(--u) * 10.4); }
.disc .ico { width: 52%; }
.row-ico .ico { width: 62%; }
.lang-value .ico { width: calc(var(--u) * 2.3); }
.revive-panel .btn .ico { width: calc(var(--u) * 9.4); }

/* landscape game over: bigger panel and smaller number, as in docs/mockups/07-recorde-paisagem.png */
@media (min-aspect-ratio: 23/20) {
  #over { --u: min(0.92vh, calc(100vw * 941 / 1672 / 109)); }
  #over .big-score { font-size: calc(var(--u) * 8.4); }
  #over .ribbon { width: calc(var(--u) * 60); }
}

/* ready-made round button (disc + icon in a single image, assets/skin/bt-* and bs-*): no centering the icon on top */
.disc.ready { background: none; }
.disc.ready::before { display: none; }
.disc.ready img { width: 100%; height: 100%; }

/* Pills (plaques and buttons) without distortion: slices only the ends (whole curve) and stretches the middle.
   Each end is half the piece height, so the curve always stays round. --ph / --bh = piece height. */
.plaque, .row, .lang-value {
  height: var(--ph) !important;
  border-width: 0 calc(var(--ph) * 0.42) !important;
  border-image-source: url(./assets/skin/plaque.webp);
  border-image-slice: 0 120 fill !important;
  border-image-width: 0 calc(var(--ph) * 0.52) !important;
  border-image-repeat: stretch;
}
.plaque { --ph: calc(var(--u) * 9.4); }
.title-actions .best-plaque { --ph: calc(var(--u) * 13.7); }
#over .best-plaque { --ph: calc(var(--u) * 7.3); }
.label.plaque { --ph: calc(var(--u) * 6.2); }
.title-plaque { --ph: calc(var(--u) * 9.4); padding: 0 calc(var(--u) * 1); }
.row { --ph: calc(var(--u) * 11.5); padding: 0 calc(var(--u) * 1); border-width: 0 calc(var(--ph) * 0.3) !important; }
.lang-value { --ph: calc(var(--u) * 5.9); }
.btn, .lang-grid button {
  height: var(--bh) !important;
  min-height: 0 !important;
  border-width: 0 calc(var(--bh) * 0.3) !important;
  border-image-slice: 0 100 fill !important;
  border-image-width: 0 calc(var(--bh) * 0.5) !important;
}
.btn { --bh: max(44px, calc(var(--u) * 12.8)); }
.title-actions .btn.big { --bh: calc(var(--u) * 18.4); }
.title-actions .btn.primary { --bh: calc(var(--u) * 20.4); }
.settings-panel .btn.big { --bh: max(44px, calc(var(--u) * 10.1)); }
.langs-panel .btn.big { --bh: max(44px, calc(var(--u) * 9.1)); }
.lang-grid button { --bh: max(44px, calc(var(--u) * 8.5)); }
.btn.link { height: auto !important; border-width: 0 !important; }
@media (min-aspect-ratio: 23/20) {
  .title-actions .btn.big { --bh: calc(var(--tu) * 12.6); }
  .title-actions .btn.primary { --bh: calc(var(--tu) * 14); }
  .title-actions .btn.daily { --bh: calc(var(--tu) * 15); }
  .title-actions .best-plaque { --ph: calc(var(--tu) * 10.5); }
}
.plaque::before { top: 0 !important; transform: translate(-50%, -58%) !important; }

/* ---------- screen juice ---------- */
/* buttons: sink on touch and spring back */
.btn, .disc, .lang-grid button, .switch, .lang-value { transition: transform 0.22s cubic-bezier(0.3, 1.7, 0.5, 1), filter 0.12s ease; }
.btn:active, .lang-grid button:active, .lang-value:active { transform: translateY(calc(var(--u) * 0.7)) scale(0.95); filter: brightness(0.86); transition-duration: 0.06s; }
.disc:active { transform: scale(0.9); transition-duration: 0.06s; }
/* shine sweeping across Play every few seconds */
#btn-play { overflow: hidden; }
#btn-play::after {
  content: '';
  position: absolute;
  inset: 8% 3%;
  border-radius: 999px;
  background: linear-gradient(105deg, transparent 38%, rgba(255, 255, 255, 0.32) 50%, transparent 62%) no-repeat;
  background-size: 260% 100%;
  background-position: 160% 0;
  animation: shine 4.6s ease-in-out 1.2s infinite;
  pointer-events: none;
}
@keyframes shine { 0% { background-position: 160% 0; } 22%, 100% { background-position: -60% 0; } }

/* best score in 3 beats: number pops (impact) -> ribbon drops with a spring -> fountain of gems */
#over.record.show .big-score { animation: scorePop 0.55s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
#over.record.show .ribbon { animation: ribbonDrop 0.6s cubic-bezier(0.25, 1.55, 0.45, 1) 0.35s both; }
#over.record.show .big-score::before { animation: ringPulse 1.4s ease-out 0.2s both; }
@keyframes scorePop { 0% { transform: scale(0.55); } 60% { transform: scale(1.14); } 100% { transform: scale(1); } }
@keyframes ribbonDrop { 0% { transform: translateY(-70%) scale(0.85); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes ringPulse { 0% { transform: scale(0.6); opacity: 0; } 35% { opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
.big-score { position: relative; }
.fgem {
  position: absolute;
  left: 50%;
  top: 0;
  width: calc(var(--u) * 4.2);
  height: auto;
  opacity: 0;
  pointer-events: none;
  animation: fgem 1.1s cubic-bezier(0.15, 0.7, 0.4, 1) both;
  -webkit-text-stroke: 0;
}
@keyframes fgem {
  0% { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
  12% { opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx) * var(--u)), calc(-50% + var(--dy) * var(--u) + calc(var(--u) * 10))) rotate(var(--rot)) scale(0.9); opacity: 0; }
}
.calm #over.record.show .big-score, .calm #over.record.show .ribbon, .calm #over.record.show .big-score::before, .calm #btn-play::after { animation: none !important; }
.calm .fgem { animation-duration: 0.6s; }
@media (prefers-reduced-motion: reduce) { #btn-play::after { animation: none; } }

.fountain { position: absolute; left: 0; right: 0; height: 0; pointer-events: none; z-index: 0; }
#over .big-score { z-index: 1; }

/* language grid: the two columns split the panel evenly and never pass the edge */
.lang-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
.lang-grid button { min-width: 0; width: 100%; border-width: 0 calc(var(--bh) * 0.2) !important; overflow: hidden; text-overflow: clip; }
.langs-panel { width: calc(var(--u) * 70) !important; }

/* Settings labels on 1 line (the size shrinks together in src/ui.js fitRowLabels) */
.row-label, .row label { white-space: nowrap !important; overflow: hidden; text-overflow: clip !important; }
.row .two-lines { white-space: nowrap !important; }

/* ---------- menu: logo in the center; Play, Challenge and best score at the bottom; discs at the top right ---------- */
#title { padding: 0; align-items: stretch; justify-content: stretch; }
#title .title-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: 1fr auto;
  justify-items: center;
  align-items: center;
  padding: calc(var(--u) * 16) calc(var(--u) * 6) max(calc(var(--u) * 9), env(safe-area-inset-bottom));
}
.menu-top {
  position: absolute;
  top: max(calc(var(--u) * 4), env(safe-area-inset-top));
  right: max(calc(var(--u) * 4), env(safe-area-inset-right));
  display: flex;
  gap: calc(var(--u) * 2.4);
}
.menu-top .disc { width: calc(var(--u) * 13) !important; height: calc(var(--u) * 13) !important; }
.disc .snd-off { display: none; }
.disc.silent .snd-on { display: none; }
.disc.silent .snd-off { display: block; }
#title .logo { grid-row: 1; margin: 0; width: calc(var(--u) * 80); }
#title .tap-start, #title .title-actions { grid-row: 2; grid-column: 1; }
#title .tap-start { align-self: center; margin: 0; }
#title .title-actions { display: flex; flex-direction: column; align-items: center; gap: calc(var(--u) * 3.4); width: calc(var(--u) * 82); }
#title .title-actions > * { margin: 0 !important; }

/* tap to start: only the logo and the prompt */
#title.splash .title-actions, #title.splash .menu-top { visibility: hidden; }
#title:not(.splash) .tap-start { visibility: hidden; }
/* menu entrance after the tap */
#title.intro .logo { animation: logoSettle 0.5s cubic-bezier(0.3, 1.5, 0.5, 1) both; }
#title.intro .title-actions > *, #title.intro .menu-top .disc { animation: popIn 0.5s cubic-bezier(0.25, 1.6, 0.45, 1) both; }
#title.intro .title-actions > :nth-child(1) { animation-delay: 0.08s; }
#title.intro .title-actions > :nth-child(3) { animation-delay: 0.16s; }
#title.intro .title-actions > :nth-child(4) { animation-delay: 0.24s; }
#title.intro .menu-top .disc:nth-child(1) { animation-delay: 0.3s; }
#title.intro .menu-top .disc:nth-child(2) { animation-delay: 0.36s; }
#title.intro .menu-top .disc:nth-child(3) { animation-delay: 0.42s; }
@keyframes popIn { 0% { transform: translateY(calc(var(--u) * 5)) scale(0.7); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes logoSettle { 0% { transform: scale(1.06); } 100% { transform: none; } }
.calm #title.intro .logo, .calm #title.intro .title-actions > *, .calm #title.intro .menu-top .disc { animation: fadeOnly 0.3s ease both !important; }
@keyframes fadeOnly { from { opacity: 0; } to { opacity: 1; } }

/* landscape: smaller logo in the center; Play and Challenge side by side, best score below */
@media (min-aspect-ratio: 23/20) {
  #title .title-wrap { --u: min(1vh, calc(100vw * 941 / 1672 / 100)); padding: calc(var(--u) * 9) calc(var(--u) * 6) calc(var(--u) * 6); }
  #title .logo { width: calc(var(--u) * 82); }
  #title .title-actions { display: grid; grid-template-columns: 1fr 1fr; width: calc(var(--u) * 140); gap: calc(var(--u) * 3) calc(var(--u) * 4); }
  #title .title-actions > .best-plaque { grid-column: 1 / span 2; justify-self: center; }
  .title-actions .btn.big { --bh: calc(var(--u) * 15) !important; font-size: calc(var(--u) * 6.6) !important; }
  .title-actions .btn.primary { --bh: calc(var(--u) * 15) !important; }
  .title-actions .btn.daily { --bh: calc(var(--u) * 15) !important; }
  .title-actions .best-plaque { --ph: calc(var(--u) * 10.5) !important; font-size: calc(var(--u) * 6) !important; min-width: calc(var(--u) * 40) !important; }
  .menu-top .disc { width: calc(var(--u) * 12) !important; height: calc(var(--u) * 12) !important; }
}

/* True center of buttons and plaques: the art has a rim on top and relief (dark tab) at the bottom, so the center of the
   face sits above the center of the box. Measured on the art: button 9% of the height above; plaque 4%. */
.btn:not(.link), .lang-grid button { padding-top: 0 !important; padding-bottom: calc(var(--bh) * 0.18) !important; }
.plaque, .row, .lang-value { padding-top: 0 !important; padding-bottom: calc(var(--ph) * 0.085) !important; }
.btn, .lang-grid button, .plaque, .row, .lang-value { line-height: 1; }

/* Button content always inside the face (from the relief inward). The face takes 61% of the art height (y 20 to 138
   of 193): text and icons are measured from --bh, so they fit any button size. */
.btn:not(.link), .lang-grid button { font-size: calc(var(--bh) * 0.36) !important; gap: calc(var(--bh) * 0.16) !important; }
.btn:not(.link) .ico, .btn:not(.link) > svg { width: calc(var(--bh) * 0.36) !important; height: auto !important; }
.btn.daily .btn-ico { width: auto !important; height: calc(var(--bh) * 0.44) !important; }
.btn.daily .daily-text { font-size: calc(var(--bh) * 0.29) !important; line-height: 1 !important; }
.btn.daily .daily-text small { font-size: 0.62em; margin-top: calc(var(--bh) * 0.015); }
.lang-grid button { font-size: calc(var(--bh) * 0.34) !important; }

/* Focus and hover: golden glow following the button shape (drop-shadow respects the art's transparency),
   without the browser's square. */
.btn:focus-visible, .disc:focus-visible, .switch:focus-visible, .lang-grid button:focus-visible, .lang-value:focus-visible, button:focus { outline: none !important; }
.btn:not(.link), .disc, .lang-grid button, .lang-value, .switch { transition: transform 0.22s cubic-bezier(0.3, 1.7, 0.5, 1), filter 0.18s ease !important; }
@media (hover: hover) {
  .btn:not(.link):hover, .disc:hover, .lang-grid button:hover, .lang-value:hover, .switch:hover {
    filter: brightness(1.1) drop-shadow(0 0 calc(var(--u) * 1.6) rgba(150, 225, 255, 0.75));
    transform: translateY(calc(var(--u) * -0.4));
  }
}
.btn:not(.link):focus-visible, .disc:focus-visible, .lang-grid button:focus-visible, .lang-value:focus-visible, .switch:focus-visible {
  filter: brightness(1.12) drop-shadow(0 0 calc(var(--u) * 1.8) rgba(170, 230, 255, 0.95));
}
.btn.link:hover, .btn.link:focus-visible { color: #f2fbff; text-shadow: 0 0 calc(var(--u) * 1.4) rgba(150, 225, 255, 0.8); }
/* button text never clipped at the top (accents and tall letters) */
.btn span, .btn .daily-text, .btn .daily-text > span { overflow: visible !important; }
/* adjustment measured in pixels (midway between the golden rims) */
.btn:not(.link), .lang-grid button { padding-bottom: calc(var(--bh) * 0.08) !important; }
.plaque, .row, .lang-value { padding-bottom: calc(var(--ph) * 0.03) !important; }

/* Ocean: sea-blue ribbon, light text with outline */
.ribbon svg.rb text { fill: #ffffff !important; stroke: #062024; stroke-width: 10px; paint-order: stroke fill; }

/* Button text centered on the smooth face (no rim, no relief), measured on this game's art */
/* btn-green: face 37-149 of 193 px, center 0.482 */
.btn.primary:not(.link), #title .btn.primary:not(.link) { padding-top: calc(var(--bh) * 0.000) !important; padding-bottom: calc(var(--bh) * 0.036) !important; }
/* btn-plum: face 40-146 of 192 px, center 0.484 */
.btn:not(.primary):not(.link), #title .btn:not(.primary):not(.link), .lang-grid button { padding-top: calc(var(--bh) * 0.000) !important; padding-bottom: calc(var(--bh) * 0.031) !important; }
