/* Visual alegre: cores vivas, botões "fofinhos" com relevo e fonte arredondada */
@font-face {
  font-family: 'Fredoka';
  src: url('fonts/fredoka.woff2') format('woff2');
  font-weight: 300 700;
  font-display: swap;
}

:root {
  --pink: #ff4d6d;
  --yellow: #ffd23f;
  --cyan: #3ec1ff;
  --purple: #7c5cff;
  --green: #36d07a;
  --orange: #ff9f43;
  --ink: #24305e;
  --ink-soft: #66709a;
  --paper: #ffffff;
  --cloud: #f2f5ff;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #58ccf0;
  font-family: 'Fredoka', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-weight: 500;
  color: var(--ink);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  overscroll-behavior: none;
}

button { font-family: inherit; }

#game { display: block; position: fixed; inset: 0; }

/* botão com relevo: a sombra de baixo é a "lateral" do botão */
.chunky {
  border: 0;
  border-radius: 18px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--edge, rgba(36, 48, 94, .25));
  transition: transform .08s, box-shadow .08s;
}

.chunky:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--edge, rgba(36, 48, 94, .25)); }

/* ---------- Placar ---------- */
#hud {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 66px); /* abaixo dos botões do topo */
  left: 0;
  right: 0;
  text-align: center;
  pointer-events: none;
}

#score {
  font-size: 74px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 5px 0 rgba(36, 48, 94, .22);
  line-height: 1;
}

#best {
  margin-top: 4px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 2px 0 rgba(36, 48, 94, .2);
}

#combo {
  display: inline-block;
  margin-top: 8px;
  padding: 5px 14px;
  border-radius: 999px;
  background: var(--pink);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  box-shadow: 0 4px 0 #c9244a;
  opacity: 0;
  transform: scale(.5) rotate(-6deg);
  transition: opacity .2s, transform .25s cubic-bezier(.3, 1.8, .5, 1);
}

#combo.show { opacity: 1; transform: scale(1) rotate(-3deg); }

#shells {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 18px);
  left: 16px;
  padding: 7px 14px;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
  box-shadow: 0 4px 0 rgba(36, 48, 94, .18);
  pointer-events: none;
}

.corner-buttons {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 14px);
  right: 14px;
  display: flex;
  gap: 8px;
  z-index: 15;
}

.corner-buttons button {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(36, 48, 94, .18);
}

.corner-buttons button:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(36, 48, 94, .18); }

#music.off { opacity: .5; }

/* na demonstração da tela inicial o placar fica escondido */
body.demo #hud { visibility: hidden; }

/* ---------- Telas por cima do jogo ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  color: #fff;
  transition: opacity .25s;
}

.overlay.hidden { opacity: 0; pointer-events: none; }
.hidden { display: none; }
.overlay.hidden { display: flex; }

.overlay p { font-size: 18px; line-height: 1.4; text-shadow: 0 2px 0 rgba(36, 48, 94, .25); }
.overlay .hint { font-size: 16px; }

/* logo com uma cor por letra */
.logo {
  display: flex;
  gap: 2px;
  font-size: 76px;
  font-weight: 700;
  line-height: 1;
}

.logo span {
  display: inline-block;
  -webkit-text-stroke: 7px #fff;
  paint-order: stroke fill;
  text-shadow: 0 7px 0 rgba(36, 48, 94, .25);
  animation: hop 2.4s ease-in-out infinite;
}

.logo span:nth-child(1) { color: var(--pink); transform: rotate(-8deg); }
.logo span:nth-child(2) { color: var(--yellow); transform: rotate(5deg); animation-delay: .15s; }
.logo span:nth-child(3) { color: var(--cyan); transform: rotate(-4deg); animation-delay: .3s; }
.logo span:nth-child(4) { color: var(--purple); transform: rotate(7deg); animation-delay: .45s; }

@keyframes hop {
  0%, 70%, 100% { translate: 0 0; }
  80% { translate: 0 -12px; }
  90% { translate: 0 2px; }
}

.menu {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 6px;
  max-width: 380px;
}

.menu button {
  pointer-events: auto;
  padding: 11px 16px;
  border: 0;
  border-radius: 16px;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .15);
  cursor: pointer;
  background: var(--bg);
  box-shadow: 0 5px 0 var(--edge);
  transition: transform .08s, box-shadow .08s;
}

.menu button:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--edge); }

/* cada botão do menu com uma cor */
[data-panel="loja"] { --bg: var(--pink); --edge: #c9244a; }
[data-panel="missoes"] { --bg: var(--cyan); --edge: #1c8fc9; }
[data-panel="conquistas"] { --bg: var(--orange); --edge: #d6721c; }
[data-panel="ranking"] { --bg: var(--purple); --edge: #5537d6; }
#shareBtn { --bg: var(--green); --edge: #1f9e58; }

/* tela inicial: título em cima, botões embaixo, demonstração livre no meio */
#start {
  pointer-events: none;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 78px) 20px calc(env(safe-area-inset-bottom) + 28px);
  background: linear-gradient(rgba(36, 48, 94, .28), rgba(36, 48, 94, 0) 34%, rgba(36, 48, 94, 0) 64%, rgba(36, 48, 94, .3));
}

.start-top, .start-bottom { display: flex; flex-direction: column; align-items: center; gap: 10px; }

.tap {
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .92);
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
  animation: bob 1.3s ease-in-out infinite;
}

@keyframes bob { 50% { transform: translateY(-4px) scale(1.03); } }
@keyframes pulse { 50% { opacity: .55; } }

/* ---------- Fim de jogo ---------- */
#over { background: linear-gradient(rgba(124, 92, 255, .45), rgba(255, 77, 109, .4)); }

#over h2 {
  font-size: 40px;
  font-weight: 700;
  text-shadow: 0 4px 0 rgba(36, 48, 94, .25);
}

.final { display: flex; flex-direction: column; line-height: 1; }

.final span {
  font-size: 104px;
  font-weight: 700;
  text-shadow: 0 6px 0 rgba(36, 48, 94, .25);
  animation: popin .45s cubic-bezier(.3, 1.8, .5, 1);
}

@keyframes popin { from { transform: scale(.4); opacity: 0; } }

.final small { font-size: 18px; font-weight: 600; }

#newBest {
  padding: 6px 16px;
  border-radius: 999px;
  background: var(--yellow);
  color: var(--ink);
  font-weight: 700;
  box-shadow: 0 4px 0 #d9a400;
  transform: rotate(-3deg);
}

.final-best { font-size: 18px; font-weight: 600; }
.final-shells { font-size: 18px; font-weight: 700; }

#restart {
  margin-top: 8px;
  padding: 16px 44px;
  border: 0;
  border-radius: 20px;
  background: var(--yellow);
  color: var(--ink);
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 0 #d9a400;
  transition: transform .08s, box-shadow .08s;
}

#restart:active { transform: translateY(5px); box-shadow: 0 1px 0 #d9a400; }

/* ---------- Tutorial ---------- */
#tutorial {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 80px);
  transform: translateX(-50%) translateY(10px);
  padding: 12px 22px;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 19px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 5px 0 rgba(36, 48, 94, .2);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}

#tutorial.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Painel (loja, missões, conquistas, ranking, ajustes) ---------- */
#panel {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(36, 48, 94, .4);
}

#panel.hidden { display: none; }

.sheet {
  width: 100%;
  max-width: 480px;
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  border-radius: 28px 28px 0 0;
  background: var(--cloud);
  color: var(--ink);
  padding-bottom: env(safe-area-inset-bottom);
  animation: up .3s cubic-bezier(.3, 1.4, .5, 1);
}

@keyframes up { from { transform: translateY(60px); opacity: 0; } }

.sheet header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 10px;
}

.sheet h3 { font-size: 26px; font-weight: 700; }

#panelClose {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(36, 48, 94, .15);
}

#panelBody { overflow-y: auto; padding: 4px 16px 20px; }

.wallet { margin-bottom: 12px; font-size: 17px; }

.tabs { display: flex; gap: 8px; margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; padding-bottom: 5px; }

.tab {
  flex: 0 0 auto;
  padding: 9px 16px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(36, 48, 94, .12);
}

.tab.on { background: var(--pink); color: #fff; box-shadow: 0 3px 0 #c9244a; }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 6px 12px;
  border: 3px solid transparent;
  border-radius: 20px;
  background: linear-gradient(160deg, #8f7dff, #3ec1ff);
  box-shadow: 0 5px 0 rgba(85, 55, 214, .35);
}

.card.on { border-color: var(--yellow); }
.card canvas { width: 100%; max-width: 92px; aspect-ratio: 1; }
.card-name { color: #fff; font-size: 14px; font-weight: 700; text-align: center; text-shadow: 0 1px 0 rgba(0, 0, 0, .15); }
.card.item { justify-content: space-between; text-align: center; }
.item-icon { font-size: 46px; line-height: 72px; }
.card-desc { color: rgba(255, 255, 255, .92); font-size: 12px; line-height: 1.3; }

.small {
  padding: 6px 14px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(36, 48, 94, .2);
}

.small.buy { background: var(--yellow); box-shadow: 0 3px 0 #d9a400; }
.small:disabled { opacity: .55; cursor: default; }
.small:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 rgba(36, 48, 94, .2); }

.tag { padding: 6px 12px; border-radius: 999px; background: rgba(255, 255, 255, .3); color: #fff; font-size: 13px; font-weight: 700; }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  margin-bottom: 10px;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 3px 0 rgba(36, 48, 94, .08);
}

.row.done { background: #e3fbec; }
.row.locked { opacity: .6; }
.row-main { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.row-main b { font-weight: 600; }
.row-main small { color: var(--ink-soft); font-size: 14px; }
.reward { font-weight: 700; white-space: nowrap; }
.ach-icon { font-size: 30px; }

.bar { height: 10px; border-radius: 999px; background: #e6eaf8; overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--pink), var(--orange)); }

.note { margin: 6px 0 12px; color: var(--ink-soft); font-size: 15px; text-align: center; }

.name-form { display: flex; gap: 8px; margin-bottom: 14px; }

.name-form input {
  flex: 1;
  min-width: 0;
  padding: 11px 16px;
  border: 3px solid #e1e6f7;
  border-radius: 999px;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
}

.name-form input:focus { outline: none; border-color: var(--cyan); }

.rank-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  padding: 11px 14px;
  margin-bottom: 6px;
  border-radius: 14px;
  background: #fff;
}

.rank-row.me { background: #fff3bf; font-weight: 700; }

/* ---------- Avisos ---------- */
/* avisos embaixo, para não cobrir o placar; o mais novo fica mais perto da borda */
#toasts {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom) + 86px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(92vw, 380px);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: 20px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 5px 0 rgba(36, 48, 94, .15), 0 10px 24px rgba(36, 48, 94, .15);
  animation: drop .35s cubic-bezier(.3, 1.6, .5, 1);
  transition: opacity .4s, transform .4s;
}

.toast.out { opacity: 0; transform: translateY(10px); }
.toast-icon { font-size: 28px; }
.toast b { display: block; font-size: 16px; font-weight: 700; }
.toast small { font-size: 14px; color: var(--ink-soft); }

@keyframes drop { from { transform: translateY(18px) scale(.9); opacity: 0; } }

/* ---------- Itens (power-ups) durante o jogo ---------- */
#powerups {
  position: fixed;
  left: 16px;
  bottom: calc(env(safe-area-inset-bottom) + 18px);
  z-index: 15;
  display: flex;
  gap: 10px;
}

.pu {
  position: relative;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 18px;
  background: #fff;
  font-size: 24px;
  box-shadow: 0 5px 0 rgba(36, 48, 94, .2);
  cursor: pointer;
}

.pu:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(36, 48, 94, .2); }

.pu b {
  position: absolute;
  right: -6px;
  top: -6px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--pink);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  line-height: 22px;
  text-align: center;
}

.pu.passive { background: rgba(255, 255, 255, .7); cursor: default; }
.pu.used { opacity: .4; }
.pu.active { background: var(--yellow); box-shadow: 0 5px 0 #d9a400; animation: bob 1s ease-in-out infinite; cursor: default; }
.pu.active b { background: var(--purple); }

/* ---------- Ajustes ---------- */
.setting { cursor: pointer; }

.setting select {
  padding: 8px 12px;
  border: 3px solid #e1e6f7;
  border-radius: 14px;
  background: #fff;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
}

.switch {
  appearance: none;
  position: relative;
  flex: 0 0 auto;
  width: 54px;
  height: 32px;
  border-radius: 999px;
  background: #d9def0;
  cursor: pointer;
  transition: background .2s;
}

.switch::after {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 0 rgba(36, 48, 94, .2);
  transition: transform .2s cubic-bezier(.3, 1.6, .5, 1);
}

.switch:checked { background: var(--green); }
.switch:checked::after { transform: translateX(22px); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
