:root {
  --font: "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
  --gold: #ffd25a;
  --red: #b3261e;
  --deep: #3a0d06;
  --teal: #1f8a8a;
}
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden;
  background: #0d1b2a; color: #fff; font-family: var(--font);
  -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
}
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }

/* outlined game text */
.otext {
  font-weight: 900; color: #fff;
  text-shadow:
    3px 0 0 var(--deep), -3px 0 0 var(--deep), 0 3px 0 var(--deep), 0 -3px 0 var(--deep),
    2px 2px 0 var(--deep), -2px 2px 0 var(--deep), 2px -2px 0 var(--deep), -2px -2px 0 var(--deep),
    0 6px 0 rgba(0,0,0,0.35);
}

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.hud-pill {
  position: absolute; top: calc(10px + env(safe-area-inset-top, 0px));
  display: flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 14px; box-sizing: border-box;
  background: linear-gradient(180deg, rgba(150, 30, 22, 0.88), rgba(96, 16, 12, 0.88));
  border: 3px solid var(--gold); border-radius: 22px;
  box-shadow: 0 4px 0 rgba(0,0,0,0.3);
  font-size: 22px;
}
#hud-left { left: calc(12px + env(safe-area-inset-left, 0px)); }
#hud-center { left: 50%; transform: translateX(-50%); }
.hud-num { min-width: 1.2em; font-variant-numeric: tabular-nums; display: inline-block; }
#hud-score { margin-left: 6px; color: var(--gold); letter-spacing: 0.04em; }
#hud-time.low { color: #ff8a7a; animation: pulse 0.6s ease-in-out infinite alternate; }
.ico { width: 24px; height: 24px; flex: 0 0 auto; background-size: contain; background-repeat: no-repeat; background-position: center; filter: drop-shadow(0 2px 0 rgba(0,0,0,0.4)); }
.ico.heart { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 21l-1.5-1.3C5.4 15.1 2 12.1 2 8.4 2 5.4 4.4 3 7.4 3c1.7 0 3.4.8 4.6 2.1C13.2 3.8 14.9 3 16.6 3 19.6 3 22 5.4 22 8.4c0 3.7-3.4 6.7-8.5 11.3z' fill='%23ff5a5a' stroke='%233a0d06' stroke-width='2'/%3E%3C/svg%3E"); }
.ico.coin { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='10' fill='%23ffcf3a' stroke='%233a0d06' stroke-width='2'/%3E%3Ccircle cx='12' cy='12' r='6' fill='none' stroke='%23e09a10' stroke-width='2'/%3E%3Cpath d='M12 8.5l1 2.3 2.4.2-1.8 1.6.6 2.4L12 13.7l-2.2 1.3.6-2.4-1.8-1.6 2.4-.2z' fill='%23e09a10'/%3E%3C/svg%3E"); }
.ico.clock { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='10' fill='%23fff6dc' stroke='%233a0d06' stroke-width='2'/%3E%3Cpath d='M12 6v6l4 2' fill='none' stroke='%233a0d06' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E"); }
#hud-level { color: var(--gold); margin-right: 4px; }
#hud.bump-coins #hud-coins, #hud.bump-lives #hud-lives { animation: bump 0.25s ease-out; }

@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.15); } }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.5); } 100% { transform: scale(1); } }

/* floating score popups */
#popups { position: fixed; inset: 0; pointer-events: none; z-index: 9; overflow: hidden; }
.popup { position: absolute; font-size: 20px; transform: translate(-50%, -50%); animation: popup 0.9s ease-out forwards; white-space: nowrap; }
.popup.big { font-size: 28px; color: var(--gold); }
@keyframes popup { 0% { opacity: 0; transform: translate(-50%, -20%) scale(0.6); } 20% { opacity: 1; transform: translate(-50%, -80%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -260%) scale(1); } }

/* big banners */
#banner { position: fixed; left: 0; right: 0; top: 28%; z-index: 20; text-align: center; pointer-events: none; }
#banner .b-main { display: inline-block; font-size: clamp(36px, 9vh, 84px); letter-spacing: 0.04em; color: var(--gold); animation: slam 0.45s cubic-bezier(.2,1.6,.4,1) both; }
#banner .b-sub { margin-top: 10px; font-size: clamp(18px, 4.4vh, 34px); animation: slam 0.45s 0.2s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes slam { 0% { opacity: 0; transform: scale(2.4) rotate(-6deg); } 100% { opacity: 1; transform: scale(1) rotate(-3deg); } }

/* level card */
#levelcard {
  position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: radial-gradient(ellipse at center, #2a6f78 0%, #123543 70%, #0a1d26 100%);
  animation: lcin 0.3s ease-out both;
}
#levelcard.fade { animation: lcout 0.36s ease-in both; }
@keyframes lcin { from { opacity: 0; } to { opacity: 1; } }
@keyframes lcout { from { opacity: 1; } to { opacity: 0; } }
#levelcard .lc-world { font-size: clamp(22px, 5vh, 38px); color: var(--gold); animation: dropin 0.5s cubic-bezier(.2,1.5,.4,1) both; }
#levelcard .lc-name { font-size: clamp(34px, 9vh, 72px); text-align: center; padding: 0 20px; animation: dropin 0.5s 0.1s cubic-bezier(.2,1.5,.4,1) both; }
#levelcard .lc-lives { display: flex; align-items: center; gap: 10px; font-size: clamp(22px, 5vh, 36px); animation: dropin 0.5s 0.2s cubic-bezier(.2,1.5,.4,1) both; }
#levelcard .lc-lives .ico { width: 1.2em; height: 1.2em; }
#levelcard .lc-loading { font-size: 16px; opacity: 0.85; min-height: 20px; }
.lc-deco { width: min(60vw, 520px); height: 6px; border-radius: 3px; background: linear-gradient(90deg, transparent, var(--gold), transparent); }
@keyframes dropin { 0% { opacity: 0; transform: translateY(-40px) scale(0.9); } 100% { opacity: 1; transform: none; } }

/* title */
#title { position: fixed; inset: 0; z-index: 40; overflow: hidden; background: #6fb7c2; cursor: pointer; }
#title-bg { position: absolute; inset: -3%; background: url("../assets/title-bg.webp") center / cover no-repeat; animation: drift 18s ease-in-out infinite alternate; }
@keyframes drift { from { transform: scale(1.0) translateX(0); } to { transform: scale(1.06) translateX(-1.5%); } }
#title-logo {
  position: absolute; left: 50%; top: 4%; width: min(64vw, 820px); max-height: 34vh; object-fit: contain;
  transform: translateX(-50%); filter: drop-shadow(0 8px 10px rgba(0,0,0,0.35));
  animation: logoin 0.7s cubic-bezier(.2,1.6,.4,1) both, float 3.2s 0.7s ease-in-out infinite alternate;
}
@keyframes logoin { 0% { opacity: 0; transform: translateX(-50%) translateY(-60px) scale(0.6); } 100% { opacity: 1; transform: translateX(-50%) scale(1); } }
@keyframes float { from { transform: translateX(-50%) translateY(0) rotate(-1deg); } to { transform: translateX(-50%) translateY(8px) rotate(1deg); } }
#title-prompt { position: absolute; left: 0; right: 0; bottom: 22%; text-align: center; font-size: clamp(20px, 4.6vh, 34px); animation: breathe 1.4s ease-in-out infinite; pointer-events: none; }
@keyframes breathe { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.55; transform: scale(0.96); } }

/* buttons: the gold plate picture, cropped to its visible part by main.js (--btn-img / --btn-slice) */
.gbtn {
  position: absolute; min-width: 180px; min-height: 56px; padding: 6px 26px; box-sizing: border-box;
  border-style: solid; border-color: transparent; border-width: 14px 18px;
  border-image-source: var(--btn-img, none);
  border-image-slice: var(--btn-slice, 40 49 40 49 fill);
  border-image-width: 20px 22px;
  border-image-repeat: stretch;
  background: linear-gradient(180deg, #ffe08a, #e0a325); border-radius: 18px;
  color: #fff; font-family: var(--font); font-size: 20px; cursor: pointer;
  transition: transform 0.1s, filter 0.12s; outline: none;
}
.art-ready .gbtn { background: transparent; border-radius: 0; }
.gbtn:hover, .gbtn:focus-visible { filter: brightness(1.15); transform: scale(1.05); }
.gbtn:active { transform: scale(0.94); }
#btn-board { left: 50%; bottom: 7%; transform: translateX(-50%); }
#btn-board:hover, #btn-board:focus-visible { transform: translateX(-50%) scale(1.05); }
#btn-board:active { transform: translateX(-50%) scale(0.94); }
#btn-board .ico { display: inline-block; vertical-align: -5px; margin-right: 8px; }
.ico.trophy { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 3.5h10V8a5 5 0 0 1-10 0z' fill='%23ffd25a' stroke='%233a0d06' stroke-width='1.5'/%3E%3Cpath d='M7 5.5H4v1.2A3.8 3.8 0 0 0 7.8 10.5M17 5.5h3v1.2a3.8 3.8 0 0 1-3.8 3.8' fill='none' stroke='%233a0d06' stroke-width='2'/%3E%3Cpath d='M10.6 12.5h2.8v3.6h-2.8zM7.5 17h9v3.5h-9z' fill='%23ffd25a' stroke='%233a0d06' stroke-width='1.5'/%3E%3C/svg%3E"); }

/* cutscene */
#cutscene { position: fixed; inset: 0; z-index: 50; background: #6fb7c2 url("../assets/title-bg.webp") center / cover no-repeat; }
#intro { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: transparent; }
#btn-skip { right: calc(16px + env(safe-area-inset-right, 0px)); top: calc(14px + env(safe-area-inset-top, 0px)); min-width: 120px; }

/* subtitles */
#subtitle {
  position: fixed; left: 50%; bottom: 9%; transform: translateX(-50%); z-index: 60; pointer-events: none;
  max-width: 70vw; text-align: center; font-size: clamp(16px, 3.6vh, 26px);
  padding: 8px 18px; border-radius: 14px; background: rgba(20, 8, 4, 0.55);
  opacity: 0; transition: opacity 0.2s;
}
#subtitle.show { opacity: 1; }

/* help panel: the red lacquer panel picture (--panel-img / --panel-slice) */
#help { position: fixed; inset: 0; z-index: 2147483050; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.5); }
#help .panel {
  width: min(600px, 86vw); max-height: 88vh; overflow: auto; box-sizing: border-box;
  border-style: solid; border-color: transparent; border-width: 38px 18px 24px;
  border-image-source: var(--panel-img, none);
  border-image-slice: var(--panel-slice, 108 49 70 49 fill);
  border-image-width: 38px 18px 24px;
  border-image-repeat: stretch;
  background: linear-gradient(180deg, #a3261b, #6e140e); border-radius: 20px;
  padding: 2px 16px 10px; animation: popin 0.28s cubic-bezier(.2,1.5,.4,1) both;
  display: flex; flex-direction: column; gap: 10px; align-items: stretch;
}
.art-ready #help .panel { background: transparent; border-radius: 0; }
#help h2 { margin: 0; text-align: center; font-size: 30px; color: var(--gold); }
#help p { margin: 0; font-size: 17px; line-height: 1.4; font-weight: 700; }
#help .ctl { color: var(--gold); }
#help .gbtn { position: relative; align-self: center; margin-top: 6px; }
@keyframes popin { 0% { opacity: 0; transform: scale(0.7); } 100% { opacity: 1; transform: none; } }

/* short screens (phones held sideways) */
@media (max-height: 460px) {
  .hud-pill { font-size: 18px; gap: 6px; padding: 0 12px; }
  .ico { width: 20px; height: 20px; }
  #help .panel { border-width: 30px 14px 18px; border-image-width: 30px 14px 18px; gap: 6px; }
  #help h2 { font-size: 22px; }
  #help p { font-size: 14px; line-height: 1.3; }
  .gbtn { min-height: 48px; font-size: 17px; min-width: 150px; }
  #title-prompt { bottom: 24%; }
  #btn-board { bottom: 5%; }
}
