html, body {
  height: 100%;
  overflow: hidden;
  touch-action: manipulation;
}

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

:root {
  --bg1: #071120;
  --bg2: #13233f;
  --card: rgba(255, 255, 255, 0.08);
  --card-border: rgba(255, 255, 255, 0.12);
  --text: #f8fafc;
  --muted: #cbd5e1;
  --green: #22c55e;
  --green-dark: #16a34a;
  --yellow: #fde047;
  --blue-soft: #93c5fd;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.35);
}

html,
body {
  min-height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(34, 197, 94, 0.12), transparent 24%),
    linear-gradient(135deg, var(--bg1), var(--bg2));
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.hidden {
  display: none !important;
}

/* MENU */
.start-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.start-card {
  width: 100%;
  max-width: 780px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 28px;
  padding: 34px 24px;
  text-align: center;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.eyebrow {
  color: #86efac;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.88rem;
  margin-bottom: 14px;
}

.start-card h1 {
  font-size: clamp(2.2rem, 5vw, 3.8rem);
  line-height: 1.05;
  margin-bottom: 14px;
}

.subtitle {
  max-width: 560px;
  margin: 0 auto 22px;
  color: var(--muted);
  line-height: 1.6;
}

.menu-mascot-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-bottom: 22px;
}

.menu-mascot {
  width: min(360px, 80vw);
  max-height: 280px;
  object-fit: contain;
  filter: drop-shadow(0 16px 18px rgba(0, 0, 0, 0.28));
  animation: floatMenu 2.6s ease-in-out infinite;
}

.button-group {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}

.primary-btn,
.secondary-btn,
.option-btn,
.area-btn {
  border: none;
  border-radius: 14px;
  padding: 14px 22px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, opacity 0.18s ease;
}

.primary-btn {
  background: var(--green);
  color: white;
}

.primary-btn:hover {
  background: var(--green-dark);
  transform: translateY(-2px);
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.12);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.secondary-btn:hover {
  transform: translateY(-2px);
}

.panel {
  max-width: 620px;
  margin: 18px auto 0;
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
  text-align: left;
}

.panel h2 {
  margin-bottom: 12px;
}

.panel p {
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 6px;
}

.settings-block + .settings-block {
  margin-top: 18px;
}

.settings-block label,
.settings-label {
  display: block;
  margin-bottom: 8px;
  font-weight: bold;
}

.settings-block select {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.08);
  color: white;
}

.settings-note {
  margin-top: 8px;
  font-size: 0.92rem;
}

.study-areas-wrap {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.area-btn {
  text-align: left;
  background: rgba(255,255,255,0.08);
  color: white;
  border: 1px solid rgba(255,255,255,0.12);
  min-height: 92px;
}

.area-btn small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-weight: normal;
}

.area-btn.active {
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(34, 197, 94, 0.40);
}

.area-btn.disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* GAME */
.game-screen {
  min-height: 100vh;
  padding: 18px;
}

.hud {
  max-width: 1200px;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.hud-label {
  color: #86efac;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.84rem;
  margin-bottom: 4px;
}

.hud h2 {
  font-size: clamp(1.4rem, 3vw, 2rem);
}

.hud-right {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.hud-box {
  min-width: 130px;
  text-align: center;
  padding: 12px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow);
}

.hud-box span {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.hud-box strong {
  font-size: 1.35rem;
  color: var(--yellow);
}

.game-wrapper {
  max-width: 1200px;
  margin: 0 auto;
}

.game-area {
  position: relative;
  width: 100%;
  min-height: 72vh;
  height: 100dvh; /* 🔥 ESSENCIAL (melhor que vh no iPhone) */
  max-height: 100dvh;
  overflow: hidden;
  border-radius: 26px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, #081427 0%, #0f2343 35%, #17355f 36%, #17355f 100%);
}

.arena-sky {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 14%, rgba(255,255,255,0.08), transparent 18%),
    radial-gradient(circle at 80% 10%, rgba(255,255,255,0.07), transparent 18%),
    linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0));
  pointer-events: none;
}

.arena-lights {
  position: absolute;
  top: 26px;
  left: 50%;
  width: 72%;
  height: 18px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255,255,255,0.05), rgba(255,255,255,0.26), rgba(255,255,255,0.05));
  filter: blur(3px);
  pointer-events: none;
}

.arena-seats {
  position: absolute;
  left: 0;
  right: 0;
  top: 76px;
  height: 190px;
  opacity: 0.62;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.015) 100%),
    repeating-linear-gradient(
      180deg,
      rgba(255,255,255,0.08) 0px,
      rgba(255,255,255,0.08) 10px,
      rgba(255,255,255,0.02) 10px,
      rgba(255,255,255,0.02) 28px
    );
  clip-path: polygon(0 0, 100% 0, 100% 78%, 0 100%);
}

.arena-seats::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      90deg,
      transparent 0px,
      transparent 78px,
      rgba(255,255,255,0.05) 78px,
      rgba(255,255,255,0.05) 82px
    );
  opacity: 0.45;
}

.arena-seats::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  height: 6px;
  background: rgba(255,255,255,0.12);
}

.court-floor {
  position: absolute;
  left: -2%;
  width: 104%;
  bottom: 0;
  height: 58%;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0.00) 20%),
    repeating-linear-gradient(
      90deg,
      #d18340 0px,
      #d18340 58px,
      #c97531 58px,
      #c97531 116px
    );
  clip-path: polygon(9% 22%, 91% 22%, 100% 100%, 0% 100%);
  border-top: 3px solid rgba(255,255,255,0.08);
}

.mid-line {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 6px;
  height: 49%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.10);
  clip-path: polygon(44% 0, 56% 0, 100% 100%, 0 100%);
  z-index: 1;
}

.center-circle {
  position: absolute;
  left: 50%;
  bottom: 14%;
  width: 220px;
  height: 92px;
  transform: translateX(-50%);
  border: 4px solid rgba(255,255,255,0.16);
  border-radius: 50%;
  z-index: 1;
}

.rotate-overlay {
  position: absolute;
  inset: 0;
  z-index: 700;
  background: rgba(2, 6, 23, 0.84);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  text-align: center;
}

.rotate-card {
  max-width: 320px;
  padding: 18px;
  border-radius: 20px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(255,255,255,0.10);
}

.rotate-card h3 {
  margin-bottom: 8px;
}

.rotate-card p {
  color: var(--muted);
  line-height: 1.5;
}

/* BASKET */
.basket-zone {
  position: absolute;
  right: 20px;
  top: 48%;
  transform: translateY(-50%);
  width: 200px;
  height: 120px;
  z-index: 150;
}

.basket-pole {
  position: absolute;
  right: -12px;
  top: 62px;
  width: 12px;
  height: 150px;
  background: linear-gradient(180deg, #cbd5e1, #64748b);
  border-radius: 8px;
}

.backboard {
  position: absolute;
  right: 0;
  top: 0;
  width: 20px;
  height: 100px;
  background: linear-gradient(180deg, #f8fafc, #cbd5e1);
  border: 2px solid rgba(15, 23, 42, 0.2);
  border-radius: 4px;
  box-shadow: 0 10px 18px rgba(0,0,0,0.2);
}

.backboard::after {
  content: "";
  position: absolute;
  left: -18px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border: 3px solid rgba(15, 23, 42, 0.25);
}

.rim {
  position: absolute;
  top: 58px;
  right: 18px;
  width: 68px;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, #fb923c, #ea580c);
  box-shadow: 0 3px 8px rgba(0,0,0,0.2);
}

.net {
  position: absolute;
  top: 68px;
  right: 29px;
  width: 44px;
  height: 28px;
  border-left: 2px solid rgba(255,255,255,0.72);
  border-right: 2px solid rgba(255,255,255,0.72);
  border-bottom: 2px solid rgba(255,255,255,0.72);
  border-radius: 0 0 18px 18px;
}

.net::before,
.net::after {
  content: "";
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  background: rgba(255,255,255,0.56);
}

.net::before {
  left: 12px;
}

.net::after {
  right: 12px;
}

.hoop-shadow {
  position: absolute;
  right: 20px;
  top: 76px;
  width: 56px;
  height: 12px;
  background: rgba(15, 23, 42, 0.12);
  filter: blur(4px);
  border-radius: 999px;
}

.hoop-contact-box {
  position: absolute;
  right: 20px;
  top: 44px;
  width: 80px;
  height: 70px;
  border: none;
  background: transparent;
  /* border: 2px dashed rgba(147, 197, 253, 0.5);
  background: rgba(147, 197, 253, 0.08); */
  border-radius: 8px;
  pointer-events: none;
}

/* OBJECTS */
.obstacles-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.obstacle {
  position: absolute;
  bottom: 16%;
  width: 100px;
  height: 100px;
  border-radius: 10px;
  overflow: visible;
  border: none;
  background: transparent;
  transform-origin: bottom left;
  pointer-events: none;
}

.obstacle img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 8px 10px rgba(0,0,0,0.22));
}

.book-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: #111827;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-align: center;
  padding: 6px;
  font-size: 0.75rem;
  border-radius: 10px;
  background: linear-gradient(180deg, #fde68a, #f59e0b);
  box-shadow: 0 10px 24px rgba(0,0,0,0.35);
}

.player {
  position: absolute;
  left: 70px;
  bottom: 16%;
  width: 124px;
  height: 176px;
  will-change: transform;
  transform-origin: bottom left;
}

.player-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: bottom center;
  filter: drop-shadow(0 14px 14px rgba(0,0,0,0.3));
  transform-origin: center bottom;
}

.player.running .player-img {
  animation: runPulse 0.35s ease-in-out infinite;
}

.player.idle .player-img {
  animation: idleFloat 1.8s ease-in-out infinite;
}

.shot-ball {
  position: absolute;
  width: 30px;
  height: 30px;
  z-index: 450;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 30%, #fed7aa 0%, #fb923c 48%, #ea580c 100%);
  border: 2px solid rgba(0,0,0,0.22);
  box-shadow: 0 8px 16px rgba(0,0,0,0.25);
}

.shot-ball::before,
.shot-ball::after {
  content: "";
  position: absolute;
  background: rgba(0,0,0,0.35);
  border-radius: 999px;
}

.shot-ball::before {
  left: 12px;
  top: 2px;
  width: 3px;
  height: 22px;
}

.shot-ball::after {
  left: 2px;
  top: 12px;
  width: 22px;
  height: 3px;
}

/* POWER */
.power-hud {
  position: absolute;
  left: 24px;
  top: 20px;
  z-index: 500;
  width: 220px;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid rgba(255,255,255,0.08);
}

.power-hud span {
  display: block;
  margin-bottom: 8px;
  color: #bfdbfe;
  font-size: 0.85rem;
  font-weight: bold;
}

.power-track {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255,255,255,0.08);
}

.power-fill {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #22c55e, #facc15, #f97316);
  transition: width 0.04s linear;
}

/* FEEDBACK */
.flash-overlay {
  position: absolute;
  inset: 0;
  z-index: 520;
  background: rgba(239, 68, 68, 0.14);
  pointer-events: none;
}

.status-text {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 530;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.84);
  color: #fef08a;
  font-weight: bold;
  letter-spacing: 0.06em;
  text-align: center;
}

/* SCORE CELEBRATION */
.score-celebration {
  position: absolute;
  inset: 0;
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.score-celebration img {
  width: min(340px, 60vw);
  max-height: 320px;
  object-fit: contain;
  animation: popScore 0.7s ease;
  filter: drop-shadow(0 10px 20px rgba(0,0,0,0.35));
}

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

.firework {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fde047;
  box-shadow:
    0 0 0 6px rgba(253, 224, 71, 0.15),
    0 0 0 14px rgba(249, 115, 22, 0.10),
    0 0 24px rgba(255,255,255,0.45);
  animation: fireworkBurst 0.8s ease-out forwards;
}

/* GAME OVER */
.game-over-screen {
  position: absolute;
  inset: 0;
  z-index: 800;
  background: rgba(2, 6, 23, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.game-over-card {
  width: 100%;
  max-width: 460px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 26px;
  padding: 24px;
  text-align: center;
  box-shadow: 0 30px 60px rgba(0,0,0,0.38);
}

.game-over-img {
  width: min(260px, 60vw);
  max-height: 260px;
  object-fit: contain;
  margin-bottom: 16px;
}

.game-over-card h3 {
  font-size: 1.8rem;
  margin-bottom: 10px;
}

.game-over-card p {
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 18px;
}

/* HELP */
.game-help {
  text-align: center;
  color: var(--muted);
  padding: 14px 8px 10px;
  line-height: 1.8;
}

/* MOBILE */
.mobile-gamepad {
  position: absolute;
  bottom: 10px;
  left: 0;
  right: 0;
  z-index: 999;
  display: flex;
  justify-content: space-between;
  padding: 0 10px;
}

.mobile-pad-left,
.mobile-pad-right {
  flex: 1;
}

.mobile-pad-left {
  display: flex;
  justify-content: flex-start;
}

.mobile-pad-right {
  display: flex;
  justify-content: flex-end;
  align-items: end;
  gap: 12px;
}

.joystick-pad {
  position: relative;
  width: 90px;
  height: 90px;
  background-image: url("assets/ui/joystick.png");
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 36px;
  height: 36px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(255,255,255,0.22);
  border: 2px solid rgba(255,255,255,0.36);
  box-shadow: 0 6px 12px rgba(0,0,0,0.24);
  pointer-events: none;
}

.icon-action-btn {
  width: 60px;
  height: 60px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
}

.icon-action-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 8px 14px rgba(0,0,0,0.25));
  user-select: none;
  -webkit-user-drag: none;
}

/* MODAL */
.injury-modal {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(2, 6, 23, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  overflow-y: auto;
}

.injury-card {
  width: 100%;
  max-height: 85dvh;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.98), rgba(15, 23, 42, 0.95));
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 24px;
  box-shadow: 0 28px 60px rgba(0,0,0,0.4);
  padding: 24px;
  overflow-y: auto;
}

.injury-card-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.injury-tag {
  display: inline-block;
  margin-bottom: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.16);
  color: #bfdbfe;
  font-weight: bold;
  font-size: 0.9rem;
}

.injury-card h3 {
  font-size: 1.65rem;
}

.medical-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
  font-size: 2rem;
  font-weight: bold;
}

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

.injury-meta-box {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  padding: 14px;
}

.injury-meta-box span {
  display: block;
  color: var(--blue-soft);
  font-size: 0.84rem;
  margin-bottom: 6px;
}

.injury-meta-box strong {
  font-size: 1rem;
}

.injury-medical-box {
  background: rgba(255,255,255,0.045);
  border: 1px solid rgba(255,255,255,0.08);
  border-left: 4px solid rgba(59,130,246,0.55);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 14px;
}

.medical-box-title {
  color: #bfdbfe;
  font-weight: bold;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.84rem;
}

.injury-scenario {
  color: var(--muted);
  line-height: 1.65;
}

.injury-options {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.option-btn {
  background: rgba(255,255,255,0.08);
  color: white;
  border: 1px solid rgba(255,255,255,0.12);
  text-align: left;
  width: 100%;
}

.option-btn.correct {
  background: rgba(34, 197, 94, 0.2);
  border-color: rgba(34, 197, 94, 0.5);
}

.option-btn.wrong {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.5);
}

.injury-feedback {
  margin-bottom: 14px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(255,255,255,0.06);
  color: var(--text);
  line-height: 1.6;
}

@keyframes floatMenu {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-8px); }
}

@keyframes idleFloat {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-4px); }
}

@keyframes runPulse {
  0%, 100% { transform: translateY(0px) scale(1); }
  50% { transform: translateY(-6px) scale(1.02); }
}

@keyframes popScore {
  0% {
    transform: scale(0.6);
    opacity: 0;
  }
  60% {
    transform: scale(1.08);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes fireworkBurst {
  0% {
    transform: scale(0.2);
    opacity: 0;
  }
  30% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(1.8);
    opacity: 0;
  }
}

@media (max-width: 1024px) {
  .hud {
    flex-direction: column;
    align-items: stretch;
  }

  .hud-right {
    justify-content: stretch;
  }

  .hud-box {
    flex: 1;
  }
}

@media (max-width: 900px) {
  .study-areas-wrap {
    grid-template-columns: 1fr;
  }

  .game-help {
    display: none;
  }

  .mobile-gamepad {
    display: flex;
  }

  .game-area {
    min-height: 56vh;
  }

  .basket-zone {
    right: 54px;
    transform: translateY(-50%) scale(0.92);
    transform-origin: right center;
  }

  .player {
    width: 108px;
    height: 154px;
  }

  .injury-meta-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .start-card {
    padding: 26px 18px;
    border-radius: 22px;
  }

  .button-group {
    flex-direction: column;
  }

  .primary-btn,
  .secondary-btn {
    width: 100%;
  }

  .game-area {
    min-height: 52vh;
  }

  .center-circle {
    width: 146px;
    height: 62px;
  }

  .power-hud {
    width: 170px;
    left: 12px;
    top: 12px;
  }

  .joystick-pad {
    width: 116px;
    height: 116px;
  }

  .icon-action-btn {
    width: 72px;
    height: 72px;
  }

  .injury-card {
    padding: 18px;
    border-radius: 18px;
  }

  .injury-card-top {
    align-items: flex-start;
  }

  .medical-icon {
    width: 44px;
    height: 44px;
    font-size: 1.7rem;
  }

  .rotate-card {
    max-width: 260px;
  }
}

@media (max-width: 768px) {

  /* PERSONAGEM */
  .player {
    width: 70px !important;
    height: 100px !important;
  }

  /* OBSTÁCULOS */
  .obstacle {
    width: 60px !important;
    height: 60px !important;
  }

  /* BOLA */
  .shot-ball {
    width: 14px !important;
    height: 14px !important;
  }

  /* CESTA */
  .basket-zone {
    transform: translateY(-50%) scale(0.7);
    right: 20px;
  }

  /* HUD menor */
  .hud-box {
    padding: 6px 8px;
    font-size: 0.75rem;
  }

}
/* =========================================================
   MOBILE RESPONSIVE FIXES - KEEP AT THE END OF THIS FILE
   ========================================================= */

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}

body {
  -webkit-text-size-adjust: 100%;
}

#fullscreenBtn {
  background: rgba(255, 255, 255, 0.12);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 14px 22px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
}

.mobile-gamepad {
  display: none;
}

.game-over-card {
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
}

.ranking-panel {
  margin: 14px 0 18px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
}

.ranking-score {
  margin-bottom: 10px;
  color: var(--muted);
}

.ranking-label {
  display: block;
  margin-bottom: 8px;
  color: #bfdbfe;
  font-size: 0.9rem;
  font-weight: bold;
}

#playerName {
  width: 100%;
  max-width: 240px;
  padding: 12px 14px;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 12px;
  color: white;
  background: rgba(15, 23, 42, 0.84);
  text-align: center;
  font-size: 1rem;
  font-weight: bold;
  text-transform: uppercase;
  outline: none;
  margin-bottom: 10px;
}

.ranking-list {
  margin: 10px auto 0;
  padding-left: 22px;
  max-width: 250px;
  text-align: left;
  color: var(--text);
  line-height: 1.7;
}

.ranking-list li::marker {
  color: var(--yellow);
  font-weight: bold;
}

.injury-modal {
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

.injury-card {
  width: min(720px, 100%);
  max-height: calc(100dvh - 28px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

@media (pointer: coarse), (max-width: 900px) {
  .start-screen {
    min-height: 100dvh;
    padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
    overflow-y: auto;
  }

  .start-card {
    max-width: 560px;
    padding: 22px 16px;
    border-radius: 22px;
  }

  .start-card h1 {
    font-size: clamp(1.9rem, 8vw, 3rem);
  }

  .subtitle {
    font-size: 0.95rem;
    line-height: 1.45;
  }

  .menu-mascot {
    width: min(230px, 68vw);
    max-height: 190px;
  }

  .button-group {
    gap: 10px;
  }

  .primary-btn,
  .secondary-btn,
  #fullscreenBtn {
    padding: 12px 16px;
    min-height: 44px;
  }

  .game-screen {
    position: fixed;
    inset: 0;
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
    padding: 0;
    background: #081427;
  }

  .hud {
    position: fixed;
    top: max(8px, env(safe-area-inset-top));
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    z-index: 650;
    max-width: none;
    margin: 0;
    pointer-events: none;
    display: flex;
    justify-content: flex-end;
    align-items: flex-start;
  }

  .hud-left {
    display: none;
  }

  .hud-right {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
  }

  .hud-box {
    min-width: 72px;
    padding: 7px 9px;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.72);
    box-shadow: 0 8px 16px rgba(0,0,0,0.22);
  }

  .hud-box span {
    font-size: 0.66rem;
    margin-bottom: 2px;
  }

  .hud-box strong {
    font-size: 1rem;
  }

  .game-wrapper {
    width: 100%;
    max-width: none;
    height: 100dvh;
    margin: 0;
  }

  .game-area {
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
    box-shadow: none;
    overflow: hidden;
  }

  .game-help {
    display: none;
  }

  .arena-lights {
    top: 16px;
    height: 12px;
  }

  .arena-seats {
    top: 44px;
    height: 132px;
  }

  .court-floor {
    height: 62%;
  }

  .center-circle {
    width: 128px;
    height: 54px;
    bottom: 16%;
    border-width: 3px;
  }

  .mid-line {
    height: 50%;
    width: 4px;
  }

  .basket-zone {
    right: 18px;
    top: 49%;
    transform: translateY(-50%) scale(0.72);
    transform-origin: right center;
  }

  .hoop-contact-box {
    right: 14px;
    top: 46px;
    width: 72px;
    height: 58px;
  }

  .player {
    width: 82px !important;
    height: 116px !important;
  }

  .obstacle {
    width: 64px !important;
    height: 64px !important;
  }

  .shot-ball {
    width: 20px !important;
    height: 20px !important;
  }

  .shot-ball::before {
    left: 8px;
    top: 1px;
    height: 16px;
    width: 2px;
  }

  .shot-ball::after {
    left: 1px;
    top: 8px;
    width: 16px;
    height: 2px;
  }

  .mobile-gamepad {
    position: absolute;
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    z-index: 640;
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 12px;
    pointer-events: none;
  }

  .mobile-pad-left,
  .mobile-pad-right,
  .joystick-pad,
  .icon-action-btn {
    pointer-events: auto;
  }

  .mobile-pad-left {
    flex: 1;
    display: flex;
    justify-content: flex-start;
  }

  .mobile-pad-right {
    flex: 1;
    display: flex;
    justify-content: flex-end;
    align-items: end;
    gap: 8px;
  }

  .joystick-pad {
    width: clamp(76px, 18vw, 104px);
    height: clamp(76px, 18vw, 104px);
    opacity: 0.88;
  }

  .joystick-knob {
    width: 28px;
    height: 28px;
  }

  .icon-action-btn {
    width: clamp(52px, 13vw, 70px);
    height: clamp(52px, 13vw, 70px);
    opacity: 0.92;
  }

  .power-hud {
    top: max(8px, env(safe-area-inset-top));
    left: max(8px, env(safe-area-inset-left));
    width: min(176px, 44vw);
    padding: 8px 9px;
    border-radius: 12px;
    z-index: 660;
  }

  .power-hud span {
    font-size: 0.72rem;
    margin-bottom: 5px;
  }

  .power-track {
    height: 9px;
  }

  .status-text {
    top: max(50px, calc(env(safe-area-inset-top) + 44px));
    padding: 8px 13px;
    font-size: 0.82rem;
    z-index: 670;
  }

  .score-celebration img {
    width: min(300px, 72vw);
    max-height: 220px;
  }

  .game-over-screen {
    position: fixed;
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }

  .game-over-card {
    padding: 16px;
    border-radius: 20px;
    max-height: calc(100dvh - 28px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .game-over-img {
    width: min(190px, 44vw);
    max-height: 170px;
    margin-bottom: 10px;
  }

  .game-over-card h3 {
    font-size: 1.45rem;
    margin-bottom: 8px;
  }

  .game-over-card p {
    font-size: 0.92rem;
    line-height: 1.45;
    margin-bottom: 12px;
  }

  .ranking-panel {
    margin: 10px 0 14px;
    padding: 12px;
  }

  #playerName {
    max-width: 210px;
    padding: 10px 12px;
  }

  .injury-modal {
    align-items: flex-start;
    padding-top: max(12px, env(safe-area-inset-top));
  }

  .injury-card {
    max-height: calc(100dvh - 24px);
    padding: 14px;
    border-radius: 18px;
  }

  .injury-card-top {
    margin-bottom: 12px;
  }

  .injury-card h3 {
    font-size: 1.2rem;
  }

  .injury-tag {
    font-size: 0.72rem;
    padding: 6px 9px;
  }

  .medical-icon {
    width: 38px;
    height: 38px;
    font-size: 1.45rem;
    border-radius: 12px;
  }

  .injury-meta-grid {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 12px;
  }

  .injury-meta-box {
    padding: 10px;
    border-radius: 12px;
  }

  .injury-medical-box {
    padding: 10px;
    margin-bottom: 10px;
  }

  .option-btn {
    padding: 11px 12px;
    font-size: 0.92rem;
  }

  .injury-feedback {
    padding: 10px;
    font-size: 0.9rem;
  }
}

@media (pointer: coarse) and (orientation: landscape) and (max-height: 520px) {
  .arena-seats {
    top: 34px;
    height: 96px;
  }

  .court-floor {
    height: 66%;
  }

  .basket-zone {
    top: 47%;
    transform: translateY(-50%) scale(0.64);
  }

  .player {
    width: 70px !important;
    height: 98px !important;
  }

  .obstacle {
    width: 56px !important;
    height: 56px !important;
  }

  .joystick-pad {
    width: clamp(68px, 14vw, 86px);
    height: clamp(68px, 14vw, 86px);
  }

  .icon-action-btn {
    width: clamp(48px, 10vw, 60px);
    height: clamp(48px, 10vw, 60px);
  }

  .hud-box {
    padding: 5px 8px;
  }

  .score-celebration img {
    width: min(250px, 52vw);
    max-height: 170px;
  }
}


/* =========================================================
   MOBILE UX PATCH V2 - buttons 1.5x, safer fullscreen, iOS/Android touch fixes
   Keep this block at the very end.
   ========================================================= */
:root {
  --app-height: 100dvh;
}

html.game-active,
body.game-active {
  position: fixed;
  inset: 0;
  width: 100%;
  height: var(--app-height, 100dvh);
  overflow: hidden;
}

.start-screen {
  height: var(--app-height, 100dvh);
  min-height: var(--app-height, 100dvh);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.icon-action-btn,
.icon-action-btn img,
.joystick-pad,
.joystick-knob {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
  touch-action: none;
}

.icon-action-btn {
  border-radius: 999px;
}

.icon-action-btn:active,
.joystick-pad:active {
  transform: scale(0.96);
  filter: brightness(1.12);
}

@media (pointer: coarse), (max-width: 900px) {
  .game-screen,
  .game-wrapper,
  .game-area {
    height: var(--app-height, 100dvh);
    min-height: var(--app-height, 100dvh);
    max-height: var(--app-height, 100dvh);
  }

  .mobile-gamepad {
    bottom: max(12px, env(safe-area-inset-bottom));
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
    gap: 16px;
  }

  .mobile-pad-right {
    gap: 12px;
  }

  /* 1.5x larger than the previous mobile defaults */
  .joystick-pad {
    width: clamp(114px, 27vw, 156px);
    height: clamp(114px, 27vw, 156px);
    opacity: 0.92;
  }

  .joystick-knob {
    width: 42px;
    height: 42px;
  }

  .icon-action-btn {
    width: clamp(78px, 19.5vw, 105px);
    height: clamp(78px, 19.5vw, 105px);
    opacity: 0.96;
  }

  .icon-action-btn img {
    pointer-events: none;
  }
}

@media (pointer: coarse) and (orientation: landscape) and (max-height: 520px) {
  .start-screen {
    align-items: flex-start;
    padding-top: max(12px, env(safe-area-inset-top));
  }

  .start-card {
    margin: 0 auto;
  }

  /* 1.5x larger than the previous compact landscape defaults */
  .joystick-pad {
    width: clamp(102px, 21vw, 129px);
    height: clamp(102px, 21vw, 129px);
  }

  .joystick-knob {
    width: 38px;
    height: 38px;
  }

  .icon-action-btn {
    width: clamp(72px, 15vw, 90px);
    height: clamp(72px, 15vw, 90px);
  }

  .mobile-gamepad {
    bottom: max(8px, env(safe-area-inset-bottom));
  }
}

/* =========================================================
   MENU FULLSCREEN/FIT FIX V3 - mobile menu adapts after Fullscreen/Landscape
   Keep this block at the very end.
   ========================================================= */
html.menu-fit-active,
body.menu-fit-active {
  width: 100%;
  height: var(--app-height, 100dvh);
  min-height: var(--app-height, 100dvh);
  overflow: hidden;
}

.start-screen.menu-fit-active,
html.menu-fit-active .start-screen,
body.menu-fit-active .start-screen {
  width: 100%;
  height: var(--app-height, 100dvh);
  min-height: var(--app-height, 100dvh);
  max-height: var(--app-height, 100dvh);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.start-screen.menu-fit-active .start-card,
html.menu-fit-active .start-card,
body.menu-fit-active .start-card {
  max-height: calc(var(--app-height, 100dvh) - max(24px, env(safe-area-inset-top)) - max(24px, env(safe-area-inset-bottom)));
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

@media (pointer: coarse), (max-width: 900px) {
  .start-screen,
  .start-screen.menu-fit-active,
  html.menu-fit-active .start-screen,
  body.menu-fit-active .start-screen {
    height: var(--app-height, 100dvh);
    min-height: var(--app-height, 100dvh);
    max-height: var(--app-height, 100dvh);
    align-items: flex-start;
    justify-content: flex-start;
    padding:
      max(10px, env(safe-area-inset-top))
      max(10px, env(safe-area-inset-right))
      max(10px, env(safe-area-inset-bottom))
      max(10px, env(safe-area-inset-left));
    overflow-y: auto;
    overflow-x: hidden;
  }

  .start-card {
    width: min(94vw, 780px);
    margin: auto;
    padding: clamp(14px, 3vh, 24px) clamp(14px, 4vw, 22px);
    border-radius: 22px;
    max-height: calc(var(--app-height, 100dvh) - 20px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .start-card h1 {
    font-size: clamp(1.8rem, 7vw, 3rem);
    margin-bottom: 8px;
    line-height: 1;
  }

  .eyebrow {
    font-size: 0.72rem;
    margin-bottom: 8px;
  }

  .subtitle {
    font-size: 0.92rem;
    line-height: 1.35;
    margin-bottom: 12px;
  }

  .menu-mascot-wrap {
    margin-bottom: 12px;
  }

  .menu-mascot {
    width: min(230px, 52vw);
    max-height: min(160px, 28vh);
  }

  .button-group {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .button-group .primary-btn,
  .button-group .secondary-btn {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    font-size: 0.9rem;
    border-radius: 13px;
  }

  #fullscreenBtn {
    grid-column: 1 / -1;
  }

  .panel {
    max-height: min(42vh, 260px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px;
    margin-top: 10px;
    border-radius: 14px;
  }

  .panel h2 {
    font-size: 1.05rem;
    margin-bottom: 8px;
  }

  .panel p,
  .settings-note {
    font-size: 0.86rem;
    line-height: 1.35;
  }
}

@media (pointer: coarse) and (orientation: landscape) and (max-height: 540px) {
  .start-screen,
  .start-screen.menu-fit-active,
  html.menu-fit-active .start-screen,
  body.menu-fit-active .start-screen {
    align-items: flex-start;
    justify-content: flex-start;
    padding:
      max(8px, env(safe-area-inset-top))
      max(10px, env(safe-area-inset-right))
      max(8px, env(safe-area-inset-bottom))
      max(10px, env(safe-area-inset-left));
  }

  .start-card {
    width: min(96vw, 880px);
    max-height: calc(var(--app-height, 100dvh) - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    padding: 10px 14px;
    border-radius: 18px;
  }

  .start-card h1 {
    font-size: clamp(1.35rem, 4.4vw, 2.15rem);
    margin-bottom: 5px;
  }

  .eyebrow {
    font-size: 0.62rem;
    margin-bottom: 5px;
  }

  .subtitle {
    max-width: 720px;
    font-size: 0.78rem;
    line-height: 1.25;
    margin-bottom: 8px;
  }

  .menu-mascot-wrap {
    margin-bottom: 8px;
  }

  .menu-mascot {
    width: min(150px, 23vw);
    max-height: min(92px, 24vh);
  }

  .button-group {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }

  .button-group .primary-btn,
  .button-group .secondary-btn {
    min-height: 38px;
    padding: 8px 9px;
    font-size: 0.78rem;
    border-radius: 11px;
  }

  #fullscreenBtn {
    grid-column: auto;
  }

  .panel {
    max-height: calc(var(--app-height, 100dvh) - 178px);
    margin-top: 8px;
    padding: 9px;
  }

  .study-areas-wrap {
    grid-template-columns: repeat(3, 1fr);
    gap: 7px;
  }

  .area-btn {
    min-height: 58px;
    padding: 8px 9px;
    font-size: 0.78rem;
  }

  .area-btn small {
    font-size: 0.68rem;
    margin-top: 3px;
  }
}

/* =========================================================
   FINAL PATCH V4 - fullscreen modal + responsive hoop area
   ========================================================= */

/* This hitbox is invisible in final mode, but its measured size follows responsive layout. */
.hoop-contact-box {
  border: none;
  background: transparent;
}

/* Uncomment this class in DevTools if you want to see the scoring area. */
.hoop-contact-box.debug {
  border: 2px dashed rgba(255, 0, 0, 0.8);
  background: rgba(255, 0, 0, 0.18);
}

/* Keep the injury modal above mobile controls and visible inside fullscreen. */
.injury-modal {
  position: fixed;
  inset: 0;
  z-index: 1400;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.injury-card {
  max-height: calc(var(--app-height, 100dvh) - 28px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

@media (pointer: coarse), (max-width: 900px) {
  /* User-selected mobile action button transparency. */
  .icon-action-btn {
    width: clamp(78px, 19.5vw, 105px);
    height: clamp(78px, 19.5vw, 105px);
    opacity: 0.55;
    transition: opacity 0.15s ease, transform 0.15s ease, filter 0.15s ease;
  }

  .icon-action-btn:active {
    opacity: 1;
    transform: scale(0.96);
    filter: brightness(1.15);
  }

  .icon-action-btn img {
    pointer-events: none;
  }

  /* The visual hitbox scales with the basket and the game viewport. */
  .hoop-contact-box {
    right: clamp(10px, 3vw, 18px);
    top: clamp(38px, 10vh, 50px);
    width: clamp(54px, 14vw, 78px);
    height: clamp(42px, 10vw, 62px);
  }
}

@media (pointer: coarse) and (orientation: landscape) and (max-height: 520px) {
  .hoop-contact-box {
    right: 12px;
    top: 42px;
    width: clamp(56px, 10vw, 74px);
    height: clamp(42px, 9vw, 58px);
  }
}
