/* Quebra Bloco — mobile first */

:root {
  --ink: #120c2c;
  --ink-2: #1c1446;
  --ink-3: #2a2063;
  --line: rgba(214, 200, 255, 0.14);
  --text: #f6f2ff;
  --muted: #a99fd6;

  --coral: #ff4f79;
  --tangerine: #ff8a3d;
  --sun: #ffce3a;
  --mint: #2fd99b;
  --sky: #36b5ff;
  --grape: #8e6cff;
  --gum: #ff5fd2;

  --glow-a: #8e6cff;
  --glow-b: #ff5fd2;

  --font-display: "Bungee", "Arial Black", Impact, system-ui, sans-serif;
  --font-ui: "Fredoka", "Nunito", ui-rounded, "Segoe UI", system-ui, sans-serif;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);

  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

button {
  font: inherit;
  color: inherit;
}

[hidden] {
  display: none !important;
}

/* ---------- Palco ---------- */

.app {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  overflow: hidden;
  background:
    radial-gradient(110% 55% at 10% -5%, color-mix(in srgb, var(--glow-a) 38%, transparent), transparent 62%),
    radial-gradient(110% 55% at 95% 105%, color-mix(in srgb, var(--glow-b) 32%, transparent), transparent 62%),
    var(--ink);
}

.app::before {
  content: "";
  position: absolute;
  inset: -20%;
  pointer-events: none;
  background:
    radial-gradient(30% 22% at 70% 30%, color-mix(in srgb, var(--glow-b) 16%, transparent), transparent 70%),
    radial-gradient(28% 20% at 25% 70%, color-mix(in srgb, var(--glow-a) 16%, transparent), transparent 70%);
  animation: drift 26s ease-in-out infinite alternate;
}

@keyframes drift {
  from { transform: translate3d(-4%, -2%, 0) rotate(0deg); }
  to { transform: translate3d(4%, 3%, 0) rotate(8deg); }
}

.shell {
  position: relative;
  width: min(100%, 560px, calc(100vh * 0.64));
  width: min(100%, 560px, calc(100dvh * 0.64));
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
  padding-left: var(--safe-l);
  padding-right: var(--safe-r);
}

@media (min-width: 620px) {
  .shell {
    border-inline: 1px solid var(--line);
    background: rgba(10, 6, 30, 0.35);
    box-shadow: 0 0 80px rgba(0, 0, 0, 0.45);
  }
}

/* ---------- HUD ---------- */

.hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: calc(var(--safe-t) + 10px) 14px 6px;
  transition: opacity 0.25s ease;
}

.app.is-menu .hud {
  opacity: 0;
  pointer-events: none;
}

.label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.hud-score {
  display: flex;
  flex-direction: column;
  gap: 3px;
  line-height: 1;
  min-width: 0;
}

.hud-value {
  font-family: var(--font-display);
  font-size: 21px;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

.hud-level {
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.hud-right {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

.hud-lives {
  display: flex;
  align-items: center;
  gap: 2px;
  font-weight: 700;
  font-size: 14px;
}

.hud-lives svg {
  width: 17px;
  height: 17px;
  fill: var(--coral);
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--coral) 60%, transparent));
}

.hud-lives .pop {
  animation: heart-pop 0.45s cubic-bezier(0.2, 1.6, 0.4, 1);
}

@keyframes heart-pop {
  from { transform: scale(0.2); }
  to { transform: scale(1); }
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.icon-btn:active {
  transform: scale(0.94);
}

/* ---------- Campo ---------- */

.field {
  position: relative;
  min-height: 0;
  margin-bottom: var(--safe-b);
  touch-action: none;
  cursor: none;
}

.app.is-menu .field,
.app.is-paused .field {
  cursor: default;
}

#canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------- Telas ---------- */

.screen {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(var(--safe-t) + 16px) 16px calc(var(--safe-b) + 16px);
  background: radial-gradient(120% 80% at 50% 50%, rgba(18, 12, 44, 0.55), rgba(18, 12, 44, 0.88));
  overflow-y: auto;
  animation: fade-in 0.22s ease-out both;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.panel {
  width: min(100%, 360px);
  margin-block: auto;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 28px 22px 22px;
  border-radius: 28px;
  text-align: center;
  background: linear-gradient(180deg, rgba(46, 35, 108, 0.94), rgba(26, 18, 64, 0.96));
  border: 1px solid var(--line);
  box-shadow: 0 30px 60px -24px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  animation: panel-in 0.38s cubic-bezier(0.2, 1.3, 0.4, 1) both;
}

@keyframes panel-in {
  from { transform: translateY(18px) scale(0.96); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.screen-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 28px;
  line-height: 1.1;
  text-wrap: balance;
}

.screen-sub {
  margin: -6px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
  text-wrap: balance;
}

.eyebrow {
  margin: 0 0 -10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--sun);
}

.sub-title {
  margin: 4px 0 -6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.row {
  display: flex;
  gap: 12px;
}

.row > * {
  flex: 1;
}

/* ---------- Botões (blocos) ---------- */

.btn {
  --btn: var(--sun);
  appearance: none;
  border: 0;
  cursor: pointer;
  min-height: 54px;
  padding: 0 20px;
  border-radius: 16px;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.01em;
  color: #1a1238;
  background: var(--btn);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.55),
    inset 0 -5px 0 rgba(0, 0, 0, 0.16),
    0 12px 24px -12px color-mix(in srgb, var(--btn) 90%, transparent);
  transition: transform 0.12s ease, filter 0.12s ease;
}

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

.btn:active {
  transform: translateY(2px) scale(0.985);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.4), inset 0 -2px 0 rgba(0, 0, 0, 0.16);
}

.btn:focus-visible,
.toggle:focus-visible,
.icon-btn:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.btn-primary {
  --btn: var(--sun);
  background: linear-gradient(180deg, #ffe487 0%, var(--sun) 48%, #f4b100 100%);
}

.btn-secondary {
  --btn: var(--mint);
  background: linear-gradient(180deg, #8af3cb 0%, var(--mint) 48%, #1bb57e 100%);
}

.btn-ghost {
  color: var(--text);
  font-weight: 600;
  font-size: 16px;
  min-height: 48px;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1px var(--line);
}

.btn-ghost:active {
  box-shadow: inset 0 0 0 1px var(--line);
}

.toggles {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.toggle::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #5d5390;
  transition: background 0.2s, box-shadow 0.2s;
}

.toggle[aria-pressed="true"] {
  color: var(--text);
}

.toggle[aria-pressed="true"]::before {
  background: var(--mint);
  box-shadow: 0 0 10px var(--mint);
}

/* ---------- Menu ---------- */

.screen-menu {
  display: flex;
  justify-content: center;
  padding: 0 16px;
  background: linear-gradient(
    180deg,
    rgba(18, 12, 44, 0.78) 0%,
    rgba(18, 12, 44, 0.3) 34%,
    rgba(18, 12, 44, 0.15) 48%,
    rgba(18, 12, 44, 0.86) 70%,
    rgba(18, 12, 44, 0.97) 100%
  );
}

.menu {
  width: min(100%, 380px);
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
  padding-block: calc(var(--safe-t) + clamp(28px, 8vh, 72px)) calc(var(--safe-b) + 22px);
}

.menu-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.logo {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1;
}

.logo-row {
  display: flex;
  gap: 5px;
}

.tile {
  --c: var(--coral);
  display: grid;
  place-items: center;
  width: clamp(38px, 12.4vw, 52px);
  aspect-ratio: 1 / 1.04;
  padding-top: 0.08em;
  font-size: clamp(22px, 7.6vw, 32px);
  color: #fff;
  border-radius: 11px;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--c) 62%, white) 0%,
    var(--c) 46%,
    color-mix(in srgb, var(--c) 76%, black) 100%
  );
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.5),
    inset 0 -4px 0 rgba(0, 0, 0, 0.18),
    0 8px 20px -6px color-mix(in srgb, var(--c) 75%, transparent);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
  animation:
    tile-drop 0.7s cubic-bezier(0.2, 1.5, 0.4, 1) both,
    tile-bob 3.2s ease-in-out infinite;
  animation-delay: calc(var(--i) * 55ms), calc(0.8s + var(--i) * 140ms);
}

@keyframes tile-drop {
  from { transform: translateY(-60px) rotate(-12deg); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@keyframes tile-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.tagline {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  opacity: 0.9;
}

.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.best-line {
  margin: 0;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
}

.best-line strong {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 20px;
  color: var(--sun);
  font-variant-numeric: tabular-nums;
}

.ios-hint {
  margin: 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(54, 181, 255, 0.12);
  border: 1px solid rgba(54, 181, 255, 0.3);
  font-size: 14px;
  line-height: 1.4;
  text-align: center;
}

/* ---------- Ajuda ---------- */

.panel-help {
  text-align: left;
  gap: 16px;
  margin-block: auto;
}

.panel-help .screen-title {
  text-align: center;
}

.howto {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 15px;
  line-height: 1.45;
  color: #dcd5f7;
}

.howto strong {
  color: var(--text);
}

.legend {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.legend li {
  display: grid;
  grid-template-columns: 48px 1fr;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  line-height: 1.3;
  color: #dcd5f7;
}

.legend canvas {
  width: 48px;
  height: 26px;
}

.legend strong {
  display: block;
  color: var(--text);
  font-size: 15px;
}

/* ---------- Resultados ---------- */

.stats {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stats div {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 6px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
}

.stats dt {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.stats dd {
  margin: 0;
  font-family: var(--font-display);
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.big-score {
  margin: -4px 0 0;
  font-family: var(--font-display);
  font-size: 46px;
  line-height: 1;
  color: var(--sun);
  text-shadow: 0 4px 24px color-mix(in srgb, var(--sun) 45%, transparent);
  font-variant-numeric: tabular-nums;
}

.badge {
  justify-self: center;
  align-self: center;
  margin: -6px 0 0;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  color: #1a1238;
  background: linear-gradient(90deg, var(--coral), var(--sun), var(--mint), var(--sky), var(--gum));
  animation: badge-pulse 1.2s ease-in-out infinite;
}

@keyframes badge-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

/* ---------- Configurações ---------- */

.btn-hint {
  margin-left: 0.35em;
  font-weight: 600;
  opacity: 0.72;
}

.btn-icon-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-icon-label svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  fill: currentColor;
}

.row .btn {
  padding-inline: 10px;
  font-size: 15px;
  white-space: nowrap;
}

.panel-settings {
  text-align: left;
}

.setting {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.setting-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.setting-head .sub-title {
  margin: 0;
}

.mode-pill {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: #0c2a1f;
  background: var(--mint);
}

.mode-pill.is-custom {
  color: #3a2800;
  background: var(--sun);
}

.level-preview {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 16px;
  border: 1px solid var(--line);
  background:
    radial-gradient(90% 80% at 50% 0%, color-mix(in srgb, var(--preview-glow, var(--grape)) 30%, transparent), transparent 70%),
    rgba(10, 6, 30, 0.6);
}

.stepper {
  display: grid;
  grid-template-columns: 52px 1fr 52px;
  align-items: center;
  gap: 10px;
}

.step-btn {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

.step-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.step-btn:active:not(:disabled) {
  transform: scale(0.94);
}

.step-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.step-btn:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.step-value {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  text-align: center;
}

.step-value strong {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 26px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.step-value span {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

.range {
  --pct: 13px;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 30px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  touch-action: pan-y;
}

.range:focus-visible {
  outline: none;
}

.range::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, transparent var(--pct), #2e2468 var(--pct)),
    linear-gradient(90deg, var(--mint), var(--sun) 50%, var(--coral));
}

.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px;
  height: 26px;
  margin-top: -9px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.16), 0 4px 12px rgba(0, 0, 0, 0.45);
}

.range:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 4px var(--sky), 0 4px 12px rgba(0, 0, 0, 0.45);
}

.range::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: #2e2468;
}

.range::-moz-range-progress {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--mint), var(--sun), var(--coral));
}

.range::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.16), 0 4px 12px rgba(0, 0, 0, 0.45);
}

.range:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 4px var(--sky), 0 4px 12px rgba(0, 0, 0, 0.45);
}

.range-scale {
  position: relative;
  height: 14px;
  margin-top: -10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.range-scale span {
  position: absolute;
  top: 0;
  left: calc(13px + (100% - 26px) * var(--t));
  transform: translateX(-50%);
}

.setting-note {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  color: #dcd5f7;
}

.setting-foot {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

/* ---------- Girar aparelho ---------- */

.rotate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  align-content: center;
  gap: 18px;
  background: var(--ink);
  font-weight: 600;
  font-size: 17px;
}

.rotate p {
  margin: 0;
}

.rotate-phone {
  width: 44px;
  height: 72px;
  border-radius: 10px;
  border: 3px solid var(--sun);
  animation: turn 1.8s ease-in-out infinite;
}

@keyframes turn {
  0%, 30% { transform: rotate(-90deg); }
  60%, 100% { transform: rotate(0deg); }
}

@media (orientation: landscape) and (max-height: 520px) and (pointer: coarse) {
  .rotate {
    display: grid;
  }
}

/* ---------- Movimento reduzido ---------- */

@media (prefers-reduced-motion: reduce) {
  .app::before,
  .tile,
  .badge,
  .rotate-phone,
  .panel,
  .screen {
    animation: none;
  }
}
