:root {
  --fg: #ffffff;
  --font-bg: transparent;
  --counter-bg: #4caf50;
  --counter-text: #f9f9f9;
  --bubble-tile: #f3f4f6;
  --bubble-subtle: #374151;
  --message-font:
    "Inter", Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  background: #000;
  color: var(--fg);
  font-family:
    Inter,
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    sans-serif;
  overflow: hidden;
}

.stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.layer {
  position: absolute;
  inset: 0;
}

.bg-image {
  z-index: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-color: transparent;
}

.bg-tint {
  z-index: 1;
  background: rgba(0, 0, 0, 1);
  transition: background-color 300ms ease;
  pointer-events: none;
}

.celebration-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
}

.layer-watermark {
  z-index: 2;
  position: absolute;
  left: 14px;
  bottom: 14px;
  height: 28px;
  width: auto;
  opacity: 0.4;
  pointer-events: none;
}

.content-layer {
  z-index: 3;
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(12px, 2vh, 28px);
  padding: 4vh 4vw;
  pointer-events: none;
}

/* Title above counter when using flex layout (matches Flutter stack: counter then title on top). */
.content-layer > .pingbell-image {
  order: 0;
}

.content-layer > .title-notification {
  order: 1;
}

.content-layer > .counter {
  order: 2;
}

.content-layer > .bubble-notification {
  order: 3;
}

.stage.has-positions .content-layer {
  display: block;
  padding: 0;
}

.pingbell-image {
  position: absolute;
  object-fit: cover;
  border-radius: 4px;
  display: none;
  pointer-events: none;
}

.pingbell-image.visible {
  display: block;
}

/* --- Counter: split-flap tiles sized from celebration_settings (counterHeightWebRelative) --- */
.counter {
  display: inline-flex;
  flex-direction: row;
  align-items: stretch;
  /* Space between digit tiles; scales with --digit-slot-h. Override: e.g. gap: 12px; */
  gap: clamp(4px, calc(var(--digit-slot-h, 64px) * 0.14), 18px);
  user-select: none;
  line-height: 0;
  z-index: 1;
  overflow: visible;
}

.currency-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: calc(var(--digit-slot-h, 64px) * 0.75);
  height: var(--digit-slot-h, 64px);
  font-size: calc(var(--digit-slot-h, 64px) * 0.68);
  font-weight: 700;
  color: var(--counter-text);
  flex-shrink: 0;
}

.fc-wrap {
  --fc-half: calc(var(--digit-slot-h, 64px) * 0.5);
  --fc-font: calc(var(--digit-slot-h, 64px) * 0.8125);
  position: relative;
  display: inline-block;
  perspective: calc(3 * var(--digit-slot-w, 48px));
  perspective-origin: 50% 50%;
  width: var(--digit-slot-w, 48px);
  height: var(--digit-slot-h, 64px);
  margin: 0;
  flex-shrink: 0;
  transform: translateZ(0);
  -webkit-font-smoothing: antialiased;
}

.fc-wrap-num {
  position: absolute;
  left: 0;
  right: 0;
  width: 100%;
  height: var(--fc-half);
  overflow: hidden;
  box-sizing: border-box;
}

.fc-number {
  display: block;
  font-size: var(--fc-font);
  font-weight: bold;
  line-height: 1;
  user-select: none;
  color: var(--counter-text, #fff);
  font-variant-numeric: tabular-nums;
  text-align: center;
  width: 100%;
  margin: 0;
}

.fc-top {
  top: 0;
  background: var(--counter-bg, #0b0b0b);
  border-radius: 6px 6px 0 0;
  /* box-shadow: 0 2px 4px 1px rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid #a9a9a9; */
}

.fc-top .fc-number {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  transform: translateY(-50%);
}

.fc-bottom {
  top: var(--fc-half);
  background: var(--counter-bg, #000);
  border-radius: 0 0 6px 6px;
  /* box-shadow: 0 4px 4px 1px rgba(0, 0, 0, 0.35);
  border-top: 1px solid #a9a9a9; */
}

.fc-bottom .fc-number {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  transform: translateY(50%);
}

.fc-flip-outer {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: var(--fc-half);
  opacity: 1;
  background: var(--counter-bg, #0b0b0b);
  z-index: 1;
  border-radius: 6px 6px 0 0;
  border-bottom: 1px solid #a9a9a9;
  transform-origin: 50% 100%;
  transform: rotateX(0deg) translateZ(0.1px);
  will-change: transform;
  overflow: hidden;
  box-sizing: border-box;
}

.fc-flip-outer.fc-in .fc-number {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  transform: translateY(-50%);
}

.fc-flip-outer.fc-out {
  top: -1px;
}

.fc-flip-outer.fc-out .fc-number {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% - 1px);
  transform: translateY(-50%) scaleY(-1);
}

.fc-flip-outer.fc-animating {
  animation: fc-flip-anim 0.8s ease-in-out forwards;
}

@keyframes fc-flip-anim {
  0% {
    transform: rotateX(0deg) translateZ(0.1px);
  }
  50% {
    transform: rotateX(-90deg) translateZ(0.1px);
  }
  100% {
    transform: rotateX(-180deg) translateZ(0.1px);
  }
}

.title-notification,
.bubble-notification {
  z-index: 5;
  max-width: min(92vw, 900px);
  text-align: center;
  transition: opacity 0.7s ease-in;
  font-family: var(--message-font);
}

.title-notification.title-from-settings {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-sizing: border-box;
}

/* Flutter `Scalable` + `Positioned(left, top)`: content grows from top-left like the counter. */
.title-notification.title-from-settings.positioned {
  align-items: flex-start;
  justify-content: flex-start;
  text-align: left;
}

.title-notification.title-from-settings.positioned .title-fit-scale {
  align-items: flex-start;
  justify-content: flex-start;
}

.title-fit-scale {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.title-notification.title-from-settings.positioned .title-line {
  max-width: 100%;
}

.title-notification.title-from-settings .title-line {
  font-size: 40px;
  line-height: 1.15;
  font-weight: 400;
  font-synthesis: none;
}

.title-notification.dissolve-hidden,
.bubble-notification.dissolve-hidden {
  opacity: 0;
}

.title-notification.notification-visible,
.bubble-notification.notification-visible {
  opacity: 1;
}

.title-line {
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--font-bg);
  display: inline-block;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 400;
  font-synthesis: none;
}

.title-line.secondary-hidden {
  display: none;
}

.title-line + .title-line {
  margin-top: 4px;
}

.bubble-notification[hidden] {
  display: none !important;
}

.bubble-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  background: var(--bubble-tile);
  color: #111;
  padding: 8px 12px;
  border-radius: 8px;
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.6),
    0 2px 12px rgba(0, 0, 0, 0.25);
  min-height: 64px;
  width: max-content;
  max-width: min(94vw, 320px * var(--bubble-scale, 1));
  transform-origin: left center;
  transform: scale(var(--bubble-scale, 1));
}

.bubble-text-col {
  text-align: left;
  overflow: hidden;
}

.bubble-title {
  font-size: 16px;
  font-weight: 600;
  color: #111;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bubble-subtitle {
  margin-top: 2px;
  font-size: 14px;
  color: var(--bubble-subtle);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.bubble-icon {
  flex-shrink: 0;
  border-radius: 8px;
}

/* Positioned mode (celebration *WebRelative) */
.counter.positioned,
.title-notification.positioned,
.bubble-notification.positioned {
  position: absolute;
  margin: 0;
  max-width: none;
}

.pingbell-image.positioned {
  margin: 0;
}

.counter.positioned .currency-slot {
  width: calc(var(--digit-slot-h, 64px) * 0.75);
}

.status {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  opacity: 0.5;
  pointer-events: none;
  z-index: 5;
}

.status.error {
  opacity: 1;
  color: #ff6b6b;
}

.status:empty {
  display: none;
}

.spectate-load-overlay {
  position: absolute;
  inset: 0;
  z-index: 10000;
  background-color: #000;
  pointer-events: auto;
  opacity: 1;
  transition: opacity 0.5s ease-out;
}

.spectate-load-overlay.spectate-overlay-done {
  opacity: 0;
  pointer-events: none;
}

@keyframes spectate-mute-pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.12);
  }
  100% {
    transform: scale(1);
  }
}

.sound-toggle.spectate-mute-pulse {
  animation: spectate-mute-pulse 0.4s ease-out;
}

.sound-toggle {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  font-size: 20px;
  line-height: 1;
  font-family: inherit;
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition:
    background 150ms ease,
    transform 150ms ease;
  z-index: 6;
  pointer-events: auto;
}

.sound-toggle:hover {
  background: rgba(0, 0, 0, 0.8);
}
.sound-toggle:active {
  transform: scale(0.95);
}
.sound-toggle[aria-pressed="true"] {
  background: rgba(220, 38, 38, 0.85);
  border-color: rgba(220, 38, 38, 0.85);
}
