@font-face {
  font-family: "Lilita One";
  src: url(assets/fonts/LilitaOne-Regular.ttf) format("truetype");
  font-display: block;
}
@font-face {
  font-family: "Fredoka";
  src: url(assets/fonts/Fredoka.ttf) format("truetype");
  font-weight: 300 700;
  font-display: block;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #3a2618; /* letterbox bars when held upright (the UI's dark brown) */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
  touch-action: none;
}

/* The HUD lives in the 1920x1080 design space; app.js sizes and scales it over the canvas. */
#hud {
  position: fixed;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  pointer-events: none;
  overflow: hidden;
  font-family: "Lilita One", sans-serif;
}
#hud .layer {
  position: absolute;
  inset: 0;
}
#hud button,
#hud .panel-root {
  pointer-events: auto;
}

/* Godot Label: Lilita One, outline painted under the fill. */
.lbl {
  font-family: "Lilita One", sans-serif;
  line-height: 1.12;
  text-align: center;
  white-space: pre-line;
  paint-order: stroke fill;
  stroke-linejoin: round;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.lbl.body {
  font-family: "Fredoka", sans-serif;
  font-weight: 500;
}

.hbox {
  display: flex;
  flex-direction: row;
  align-items: center;
}
.hbox.center {
  justify-content: center;
}
.hbox.end {
  justify-content: flex-end;
}
.vbox {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 22px;
}

/* --- buttons (ui_button: one white-ish block tinted per variation) --- */
.btn {
  position: relative;
  display: flex;
  align-items: center;
  box-sizing: border-box;
  padding: 18px 44px 30px 44px;
  border: 0;
  background: none;
  cursor: pointer;
  font-family: "Lilita One", sans-serif;
  font-size: 48px;
  color: #fffaed;
  -webkit-text-stroke: 10px #3a2618;
  paint-order: stroke fill;
  isolation: isolate;
  outline: none;
}
.btn::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-style: solid;
  border-width: 40px 60px 52px 60px;
  border-image: var(--btn-orange) 40 60 52 60 fill stretch;
}
.btn.orange:hover::before {
  border-image-source: var(--btn-orange-hover);
}
.btn.green::before {
  border-image-source: var(--btn-green);
}
.btn.grey::before {
  border-image-source: var(--btn-grey);
}
.btn:active::before {
  border-image-source: var(--btn-pressed);
}
.btn:active {
  padding-top: 24px;
  padding-bottom: 24px;
}
.btn.grey {
  color: #3a2618;
  -webkit-text-stroke: 0;
  font-size: 40px;
}
.btn-icon {
  width: 72px;
  height: 72px;
  object-fit: contain;
  margin-right: 14px;
  flex: none;
}
.btn-text {
  flex: 1;
  text-align: center;
  white-space: nowrap;
}

/* --- cube buttons (ui_button_round) --- */
.cube {
  position: relative;
  box-sizing: border-box;
  border: 0;
  background: none;
  padding: 12px 16px 20px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  isolation: isolate;
  outline: none;
}
.cube::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-style: solid;
  border-width: 40px 40px 48px 40px;
  border-image: url(assets/ui/round.png) 40 40 48 40 fill stretch;
}
.cube:active::before {
  border-image-source: url(assets/ui/round_pressed.png);
}
.cube:active {
  padding: 16px;
}
.cube-icon {
  max-width: min(84px, 100%);
  max-height: 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* --- panels, planks, cards --- */
.panel-root {
  display: flex;
  align-items: center;
  justify-content: center;
}
.panel-col {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.plank {
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  border-style: solid;
  border-width: 34px 48px;
  border-image: url(assets/ui/banner.png) 34 48 fill stretch;
}
.plank-label {
  position: absolute;
  left: -48px;
  right: -48px;
  top: -34px;
  bottom: -26px;
}
.panel {
  margin-top: -40px;
  box-sizing: border-box;
  border-style: solid;
  border-width: 84px 56px 56px 56px;
  border-image: url(assets/ui/panel.png) 84 56 56 56 fill stretch;
  padding: 44px 44px 32px 44px;
}
.card {
  position: relative;
  width: 300px;
  height: 520px;
  box-sizing: border-box;
  border-style: solid;
  border-width: 40px 40px 60px 40px;
  border-image: url(assets/ui/card.png) 40 40 60 40 fill stretch;
  transform-origin: 150px 260px;
}
.card > * {
  margin: -40px 0 0 -40px;
}
.card-pic {
  position: absolute;
  left: 75px;
  top: 60px;
  width: 150px;
  height: 150px;
  object-fit: contain;
}
.coin-badge {
  position: relative;
  flex: none;
}
.coin-badge-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.dim {
  background: rgba(26, 15, 8, 0.45);
}
.title-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
}

/* --- HUD --- */
.life {
  width: 84px;
  height: 76px;
  object-fit: contain;
}
.life.dead {
  filter: brightness(0.36) saturate(0.6);
  opacity: 0.8;
}
.plate {
  position: relative;
  width: 196px;
  height: 74px;
  background: url(assets/ui/resource_plate.png) 0 0 / 100% 100% no-repeat;
  flex: none;
}
.plate-icon {
  position: absolute;
  left: 4px;
  top: 2px;
  width: 64px;
  height: 64px;
  object-fit: contain;
}
.socket {
  position: absolute;
  top: 0;
  width: 32px;
  height: 32px;
  box-shadow: 0 0 0 3px #3a2618;
  background: rgba(255, 242, 214, 0.35);
}
.socket.full::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 6px;
  background: rgba(255, 255, 255, 0.35);
}
.timer-plate {
  background: url(assets/ui/timer_plate.png) 0 0 / 100% 100% no-repeat;
  transform-origin: 150px 50px;
}
.timer-clock {
  position: absolute;
  left: 10px;
  top: 8px;
  width: 78px;
  height: 78px;
  object-fit: contain;
}
.carry .tray {
  position: absolute;
  left: 0;
  top: 0;
  width: 300px;
  height: 100px;
  object-fit: contain;
}
.carry-icon {
  position: absolute;
  width: 66px;
  height: 66px;
  object-fit: contain;
}
.toasts {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}
.toast {
  box-sizing: border-box;
  border-style: solid;
  border-width: 20px 20px 20px 40px;
  border-image: url(assets/ui/toast.png) 20 20 20 40 fill stretch;
  padding: 0 16px 0 24px;
  margin: -10px 0 -6px 0;
  transform-origin: 200px 40px;
}
.fly-coin {
  position: absolute;
  width: 72px;
  height: 72px;
  transform-origin: 36px 36px;
}
.race-row {
  position: absolute;
  left: 0;
  width: 420px;
  height: 40px;
}
.race-tag {
  position: absolute;
  left: 0;
  top: 0;
  width: 120px;
  height: 40px;
  box-shadow: 0 0 0 3px #3a2618, inset 0 7px 0 rgba(255, 255, 255, 0.35);
}
.race-tag .lbl {
  position: absolute;
  inset: 0;
}
.race-bar {
  position: absolute;
  left: 132px;
  top: 6px;
  width: 220px;
  height: 28px;
  background: rgba(255, 242, 214, 0.35);
  box-shadow: 0 0 0 3px #3a2618;
}
.race-bar.you {
  outline: 3px solid #fff3d6;
  outline-offset: 5px;
}
.race-fill {
  height: 100%;
  box-shadow: inset 0 6px 0 rgba(255, 255, 255, 0.35);
}
.race-count {
  position: absolute;
  left: 362px;
  top: 0;
  height: 40px;
  justify-content: flex-start;
}
.banner {
  transform-origin: 490px 95px;
}
.portrait {
  background: #3a2618;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}
.touch-canvas {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
}
.offer-bar {
  height: 22px;
  border-radius: 4px;
  background: #8a5a34;
  overflow: hidden;
}
.offer-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: #ff8a1f;
}

/* --- how-to card --- */
.howto-frame {
  position: relative;
  background: #3a2618;
  border-radius: 14px;
  padding: 8px;
}
.howto-canvas {
  display: block;
  width: 820px;
  height: 380px;
  border-radius: 6px;
}
.howto-ring {
  position: absolute;
  left: 32px;
  top: 238px;
  width: 130px;
  height: 130px;
}
.howto-ring svg {
  position: absolute;
  inset: 0;
}
.howto-ring img {
  position: absolute;
  left: 27px;
  top: 27px;
  width: 76px;
  height: 76px;
  object-fit: contain;
}
.howto-ring-label {
  position: absolute;
  left: 140px;
  top: 30px;
  width: 360px;
  height: 70px;
  font-size: 44px;
  color: #fff3d6;
  -webkit-text-stroke: 12px #3a2618;
  justify-content: flex-start;
  white-space: nowrap;
}

/* --- loading --- */
#loader {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 9vh;
  box-sizing: border-box;
  /* The boot splash, fitted to the window (keep aspect) on the project's clear colour. */
  background: #9fe3ff url(assets/ui/boot_splash.png) center / contain no-repeat;
  color: #3a2618;
  font: 20px sans-serif;
  transition: opacity 0.3s;
  z-index: 50;
}
#loader.done {
  opacity: 0;
  pointer-events: none;
}
.loader-track {
  width: min(60vw, 480px);
  height: 10px;
  border-radius: 5px;
  background: rgba(58, 38, 24, 0.35);
  box-shadow: 0 0 0 2px rgba(255, 243, 214, 0.6);
  overflow: hidden;
}
#loader-bar {
  width: 0;
  height: 100%;
  background: #ff8a1f;
}

/* --- test ad (local only) --- */
.mock-ad {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(5, 8, 20, 0.94);
  color: #edf2ff;
  font-family: sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
}
.mock-ad-icon {
  font-size: 96px;
}
.mock-ad-title {
  font-size: 64px;
  font-weight: bold;
}
.mock-ad-sub {
  opacity: 0.6;
  font-size: 20px;
}
.mock-ad-track {
  width: min(70vw, 720px);
  height: 8px;
  background: rgba(237, 242, 255, 0.15);
}
.mock-ad-bar {
  height: 100%;
  width: 0;
  background: #ffd46b;
}
.mock-ad-count {
  color: #ffd46b;
  font-size: 24px;
}
.mock-ad-skip {
  position: absolute;
  top: 24px;
  right: 24px;
  font-size: 18px;
  padding: 12px 20px;
}
