:root {
  --ink: #23301f;
  --ink-soft: #4b5a45;
  --cream: rgba(255, 249, 238, 0.82);
  --line: rgba(60, 40, 30, 0.12);
  --green: #4fcb5b;
  --green-dark: #2a8f3a;
  --sun: #ffc75f;
  --shadow: 0 18px 50px rgba(60, 25, 50, 0.28);
  /* cores da moeda (logo Degen Pepe): roxo do fundo, dourado da corrente */
  --coin: rgba(40, 16, 80, 0.74);
  --coin-line: rgba(255, 217, 120, 0.3);
  --coin-shadow: 0 8px 24px rgba(40, 10, 80, 0.35);
  --coin-text: #fff6e2;
  --lilac: #dccdff;
  --purple: #5a2bc4;
  --gold-1: #ffd978;
  --gold-2: #f5b53a;
  --gold-ink: #3a2600;
  --display: 'Baloo 2', ui-rounded, system-ui, sans-serif;
  --body: 'Nunito', ui-rounded, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
  background: #f0a88e;
  color: var(--ink);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  cursor: pointer;
}

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

/* ---------------------------------------------------------------- topo */

.hud-top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) 16px 0;
  pointer-events: none;
  z-index: 5;
}

.hud-top > * {
  pointer-events: auto;
}

/* topo com a cara da moeda: vidro roxo com borda dourada */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 16px 5px 5px;
  border: 1px solid var(--coin-line);
  border-radius: 20px;
  background: var(--coin);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--coin-shadow);
  color: var(--coin-text);
}

.brand strong {
  color: var(--coin-text);
  text-shadow: 0 2px 0 rgba(20, 5, 45, 0.45);
}

.brand small {
  color: var(--lilac);
}

.brand-sub {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 3px;
}

.chip {
  padding: 1px 8px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--gold-1), var(--gold-2));
  color: var(--gold-ink);
  font-family: var(--display);
  font-weight: 800;
  font-size: 12px;
  line-height: 1.5;
  letter-spacing: 0.4px;
}

.brand-logo {
  display: block;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  object-fit: cover;
  box-shadow: 0 6px 16px rgba(70, 30, 140, 0.35);
}

.brand strong {
  display: block;
  font-family: var(--display);
  font-weight: 800;
  font-size: 24px;
  line-height: 1;
  letter-spacing: 0.5px;
}

.brand small {
  font-weight: 700;
  font-size: 13px;
  opacity: 0.92;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: var(--coin);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--coin-shadow);
  color: var(--coin-text);
  font-weight: 800;
  font-size: 14px;
  white-space: nowrap;
}

.pill:empty {
  display: none;
}

.pill.count b {
  font-family: var(--display);
  font-size: 20px;
  line-height: 1;
  color: var(--gold-1);
  font-variant-numeric: tabular-nums;
}

.pill.count em {
  font-style: normal;
  font-size: 12px;
  color: var(--lilac);
}

.pill.small {
  padding: 6px 12px;
  font-size: 12px;
}

.status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #b9b1a6;
}

.status[data-state='online']::before {
  background: #34c759;
  box-shadow: 0 0 0 3px rgba(52, 199, 89, 0.25);
}

.status[data-state='connecting']::before {
  background: #ffb020;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #34c759;
  box-shadow: 0 0 0 0 rgba(52, 199, 89, 0.6);
  animation: ping 1.8s infinite;
}

@keyframes ping {
  70% {
    box-shadow: 0 0 0 8px rgba(52, 199, 89, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(52, 199, 89, 0);
  }
}

.icon-btn {
  width: 38px;
  height: 38px;
  border: 1px solid var(--coin-line);
  border-radius: 50%;
  background: var(--coin);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--coin-shadow);
  font-size: 17px;
}

/* ---------------------------------------------------------------- cartão de entrada */

.card {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -46%);
  width: min(92vw, 380px);
  max-height: calc(100vh - 32px);
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px 24px 18px;
  border-radius: 28px;
  background: var(--cream);
  backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: var(--shadow);
  z-index: 10;
  animation: rise 0.7s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
  transition: opacity 0.35s, transform 0.35s;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translate(-50%, -30%) scale(0.96);
  }
}

body.playing .card {
  opacity: 0;
  transform: translate(-50%, -30%) scale(0.95);
  pointer-events: none;
}

.card-head {
  text-align: center;
}

.badge {
  display: block;
  width: 76px;
  height: 76px;
  margin: 0 auto 8px;
  border-radius: 24px;
  object-fit: cover;
  box-shadow: 0 10px 24px rgba(70, 30, 140, 0.35);
  animation: bob 2.4s ease-in-out infinite;
}

@keyframes bob {
  50% {
    transform: translateY(-5px) rotate(-4deg);
  }
}

.card h1 {
  font-family: var(--display);
  font-weight: 800;
  font-size: 46px;
  line-height: 1;
  letter-spacing: 1px;
  background: linear-gradient(180deg, #7fe36b 0%, #2c9c43 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 #1d6b2d) drop-shadow(0 8px 14px rgba(30, 90, 40, 0.3));
}

.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 8px;
}

.ticker,
.motto {
  padding: 3px 11px;
  border-radius: 999px;
  font-family: var(--display);
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.5px;
}

.ticker {
  background: linear-gradient(180deg, var(--gold-1), var(--gold-2));
  color: var(--gold-ink);
  box-shadow: 0 3px 0 #c98a1e;
}

.motto {
  background: rgba(108, 60, 214, 0.12);
  color: var(--purple);
}

.lead {
  margin-top: 6px;
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 15px;
  line-height: 1.35;
}

.lead b {
  color: var(--ink);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field > span {
  font-weight: 800;
  font-size: 13px;
  color: var(--ink-soft);
}

.field input {
  width: 100%;
  padding: 13px 15px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: rgba(255, 255, 255, 0.85);
  font: 700 16px var(--body);
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(79, 203, 91, 0.2);
}

#skins {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
}

.skin {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.55), transparent 45%), var(--c);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.18);
  transition: transform 0.15s;
}

.skin:hover {
  transform: scale(1.08);
}

.skin.on {
  box-shadow: 0 0 0 3px var(--ink), 0 3px 8px rgba(0, 0, 0, 0.18);
  transform: scale(1.1);
}

.btn {
  position: relative;
  width: 100%;
  padding: 13px 16px 15px;
  border: 0;
  border-radius: 16px;
  font-family: var(--display);
  font-weight: 800;
  font-size: 19px;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.18);
  transition: transform 0.08s, box-shadow 0.08s, filter 0.2s;
}

.btn:active {
  transform: translateY(4px);
}

.btn.primary {
  background: linear-gradient(180deg, #6ee06a, #37b24a);
  box-shadow: 0 5px 0 var(--green-dark), 0 12px 22px rgba(40, 140, 60, 0.35);
}

.btn.primary:active {
  box-shadow: 0 1px 0 var(--green-dark), 0 6px 12px rgba(40, 140, 60, 0.3);
}

.safe {
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(79, 203, 91, 0.13);
  color: var(--green-dark);
  font-weight: 800;
  font-size: 13px;
  text-align: center;
}

.btn:hover {
  filter: brightness(1.06);
}

.foot {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 13px;
  color: var(--ink-soft);
}

.foot b {
  color: var(--ink);
}

/* ---------------------------------------------------------------- avisos */

#feed {
  position: fixed;
  left: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  max-width: min(78vw, 380px);
  pointer-events: none;
  z-index: 6;
}

.toast {
  padding: 9px 14px;
  border-radius: 14px;
  background: var(--cream);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 6px 18px rgba(60, 25, 50, 0.16);
  font-weight: 800;
  font-size: 14px;
  animation: toastIn 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.3) both;
  transition: opacity 0.5s, transform 0.5s;
}

.toast.out {
  opacity: 0;
  transform: translateX(-12px);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.95);
  }
}

#hints {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(30, 30, 45, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  z-index: 4;
}

/* aparece quando o sapo cai e some sozinho depois de uns segundos */
body.playing #hints {
  animation: hints 14s 1.8s both;
}

@keyframes hints {
  0% {
    opacity: 0;
  }
  5%,
  88% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

body.playing #feed {
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + 48px);
}

#banner {
  position: fixed;
  left: 50%;
  top: 22%;
  transform: translate(-50%, -50%);
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(40px, 9vw, 96px);
  white-space: nowrap;
  color: #fff;
  -webkit-text-stroke: 3px #2a8f3a;
  text-shadow: 0 6px 0 #1d6b2d, 0 16px 30px rgba(20, 60, 30, 0.45);
  opacity: 0;
  pointer-events: none;
  z-index: 8;
}

#banner.show {
  animation: banner 3s cubic-bezier(0.2, 0.9, 0.3, 1.3) both;
}

@keyframes banner {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.3) rotate(-8deg);
  }
  12% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.08) rotate(2deg);
  }
  20% {
    transform: translate(-50%, -50%) scale(1) rotate(0);
  }
  80% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -60%) scale(0.9);
  }
}

/* ---------------------------------------------------------------- controles no celular */

#mobileCtl {
  position: fixed;
  right: 16px;
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + 84px);
  display: none;
  gap: 12px;
  z-index: 6;
}

body.playing.touch #mobileCtl {
  display: flex;
}

#mobileCtl button {
  width: 64px;
  height: 64px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(180deg, #6ee06a, #37b24a);
  box-shadow: 0 5px 0 var(--green-dark), 0 10px 20px rgba(40, 140, 60, 0.35);
  color: #fff;
  font-size: 28px;
  font-weight: 800;
  touch-action: manipulation;
}

#mobileCtl button:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--green-dark);
}

/* ---------------------------------------------------------------- nomes dos sapos */

#labels {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 2;
}

.label {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  will-change: transform, opacity;
}

.label .name {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(25, 30, 40, 0.5);
  color: #fff;
  font-weight: 800;
  font-size: 12px;
  white-space: nowrap;
}

.label.me .name {
  background: var(--sun);
  color: #4a3000;
  font-size: 13px;
  box-shadow: 0 3px 10px rgba(120, 80, 0, 0.3);
}

.label .bubble {
  position: relative;
  padding: 5px 10px;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-family: var(--display);
  font-weight: 800;
  font-size: 15px;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  animation: pop 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.5) both;
}

.label .bubble::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -6px;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #fff;
  border-bottom: 0;
}

@keyframes pop {
  from {
    transform: scale(0.4);
    opacity: 0;
  }
}

/* ---------------------------------------------------------------- celular */

@media (max-width: 640px) {
  .brand strong {
    font-size: 20px;
  }
  .brand small,
  #watchCount {
    display: none;
  }
  .brand-logo {
    width: 38px;
    height: 38px;
  }
  .pill {
    padding: 7px 11px;
    font-size: 12px;
  }
  .pill.count b {
    font-size: 17px;
  }
  .card {
    padding: 24px 18px 16px;
  }
  .card h1 {
    font-size: 40px;
  }
  #simCount {
    display: none;
  }
  #hints {
    font-size: 12px;
    white-space: normal;
    text-align: center;
    width: calc(100vw - 32px);
    bottom: calc(max(16px, env(safe-area-inset-bottom)) + 92px);
  }
  #mobileCtl {
    bottom: max(16px, env(safe-area-inset-bottom));
  }
  #feed,
  body.playing #feed {
    bottom: max(16px, env(safe-area-inset-bottom));
    max-width: calc(100vw - 196px);
  }
  .toast {
    font-size: 12px;
    padding: 7px 11px;
  }
}

/* tela baixa (notebook com janela pequena, celular deitado): cartão compacto, abaixo do topo */
@media (max-height: 600px) {
  .card {
    top: calc(50% + 26px);
    transform: translate(-50%, -50%);
    max-height: calc(100vh - 68px);
    gap: 10px;
    padding: 16px 20px 14px;
  }
  .badge {
    display: none;
  }
  .card h1 {
    font-size: 36px;
  }
  .chips {
    margin-top: 4px;
  }
  .ticker,
  .motto {
    font-size: 12px;
  }
  .lead {
    margin-top: 4px;
    font-size: 14px;
  }
  .lead br {
    display: none;
  }
  .field input {
    padding: 10px 13px;
  }
  .skin {
    width: 32px;
    height: 32px;
  }
  .btn {
    padding: 10px 16px 12px;
    font-size: 17px;
  }
  .safe {
    padding: 7px 10px;
    font-size: 12px;
  }
  /* o contador já aparece no topo da tela */
  .foot {
    display: none;
  }
}

@media (max-height: 440px) {
  .lead {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .badge,
  .dot {
    animation: none;
  }
}
