/* ── سانس‌چی پنالتی: رسپانسیو موبایل · تبلت · آیپد · دسکتاپ ── */

html {
  overflow-x: clip;
  max-width: 100%;
}

body {
  overflow-x: clip;
  max-width: 100%;
}

.game {
  height: 100dvh;
  height: 100svh;
  min-height: -webkit-fill-available;
  max-width: 100vw;
  margin: 0 auto;
}

.field {
  min-height: 0;
}

.topbar {
  height: auto;
  min-height: 48px;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px max(12px, env(safe-area-inset-right, 0px))
    max(8px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
  padding-top: max(8px, env(safe-area-inset-top, 0px));
}

.topbar-l {
  font-size: clamp(12px, 3.2vw, 15px);
  min-width: 0;
  flex: 1 1 auto;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.topbar-site-link {
  font-size: clamp(11px, 2.8vw, 12px);
  font-weight: 700;
  color: var(--body);
  text-decoration: none;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  white-space: nowrap;
}

.score-bar {
  min-height: 48px;
  height: auto;
}

.bottom-bar {
  height: auto;
  min-height: 52px;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding: 8px max(12px, env(safe-area-inset-right, 0px))
    max(10px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
}

.bottom-bar .restart-btn,
.bottom-bar .share-btn {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 140px;
}

.shots-dots {
  order: -1;
  width: 100%;
  justify-content: center;
  padding-bottom: 2px;
}

.instr {
  white-space: normal;
  max-width: min(340px, 92vw);
  text-align: center;
  line-height: 1.45;
  font-size: clamp(10px, 2.8vw, 12px);
  bottom: max(5%, 44px);
  padding: 7px 12px;
  z-index: 24;
}

.power-wrap {
  max-width: calc(100vw - 24px);
}

.power-track {
  width: min(100px, 28vw);
}

.diff-screen {
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  align-items: flex-start;
  padding: max(12px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px))
    max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}

.diff-screen .diff-box {
  margin: auto;
  width: 100%;
  max-width: min(560px, 100%);
}

.final-ov,
.msg-ov {
  padding: 16px;
  box-sizing: border-box;
}

.final-box {
  min-width: unset;
  width: min(400px, 100%);
  max-width: 100%;
  max-height: min(88dvh, 100%);
  overflow-y: auto;
  padding: clamp(20px, 5vw, 34px) clamp(16px, 4vw, 28px);
  box-sizing: border-box;
}

.msg-box {
  max-width: min(360px, calc(100vw - 32px));
  padding: clamp(16px, 4vw, 20px) clamp(20px, 5vw, 32px);
  box-sizing: border-box;
}

.goal {
  width: min(72vw, 360px);
  height: min(26vh, 145px);
  top: clamp(4%, 8%, 10%);
}

/* ── موبایل کوچک ── */
@media (max-width: 479px) {
  .topbar-site-link .topbar-site-full {
    display: none;
  }

  .diff-subtitle {
    font-size: 12px;
    margin-bottom: 16px;
  }

  .diff-icon {
    font-size: 24px;
  }

  .keeper.dive-left {
    animation-name: diveL-sm;
  }
  .keeper.dive-right {
    animation-name: diveR-sm;
  }
  @keyframes diveL-sm {
    to {
      transform: translateX(-72px) rotate(35deg);
    }
  }
  @keyframes diveR-sm {
    to {
      transform: translateX(72px) rotate(-35deg);
    }
  }
}

/* ── تبلت عمودی (۶۰۰–۸۳۳) ── */
@media (min-width: 600px) {
  .topbar {
    min-height: 52px;
    padding-inline: 20px;
  }

  .score-bar {
    height: 54px;
  }

  .goal {
    width: min(58vw, 400px);
    height: min(28vh, 170px);
  }

  .ball {
    width: 32px;
    height: 32px;
  }

  .bottom-bar {
    min-height: 56px;
    flex-wrap: nowrap;
    justify-content: space-between;
  }

  .shots-dots {
    order: 0;
    width: auto;
  }

  .bottom-bar .restart-btn,
  .bottom-bar .share-btn {
    max-width: none;
    flex: 0 0 auto;
  }

  .diff-title {
    font-size: clamp(24px, 4vw, 30px);
  }

  .diff-box {
    max-width: 520px;
  }
}

/* ── آیپد / تبلت بزرگ عمودی ── */
@media (min-width: 768px) {
  .game {
    max-width: 820px;
    border-inline: 1px solid var(--border);
  }

  .field {
    border-radius: 0;
  }

  .instr {
    font-size: 13px;
    max-width: 420px;
  }

  .final-score {
    font-size: clamp(36px, 6vw, 48px);
  }
}

/* ── آیپد افقی و تبلت عریض: کارت‌های سختی کنار هم ── */
@media (min-width: 900px) and (min-height: 520px) {
  .diff-screen {
    align-items: center;
  }

  .diff-box {
    max-width: min(960px, 96vw);
  }

  .diff-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
  }

  .diff-card {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
    height: 100%;
  }

  .diff-icon {
    margin: 0 auto 4px;
  }

  .diff-stats {
    justify-content: center;
  }
}

/* ── دسکتاپ: قاب بازی در وسط ── */
@media (min-width: 1024px) {
  .game {
    max-width: 480px;
    box-shadow: 0 0 80px rgba(0, 0, 0, 0.45);
  }

  .goal {
    width: min(85%, 320px);
    height: min(32%, 150px);
  }
}

/* ── گوشی افقی / ارتفاع کم ── */
@media (max-height: 520px) and (orientation: landscape) {
  .topbar {
    min-height: 40px;
    padding-block: 4px;
  }

  .score-bar {
    height: 42px;
  }

  .sc-n {
    font-size: 16px;
  }

  .bottom-bar {
    min-height: 44px;
    padding-block: 4px;
  }

  .goal {
    top: 2%;
    width: min(36vw, 260px);
    height: min(55vh, 110px);
  }

  .ball {
    bottom: 16%;
    width: 24px;
    height: 24px;
  }

  .ball-shadow {
    bottom: 15.5%;
  }

  .penalty-spot {
    bottom: 18%;
  }

  .instr {
    display: none;
  }

  .power-wrap {
    bottom: 8%;
    padding: 4px 10px;
  }

  .diff-screen {
    align-items: flex-start;
  }

  .diff-cards {
    gap: 8px;
  }

  .diff-card {
    padding: 10px 12px;
  }

  .diff-desc {
    font-size: 10px;
    line-height: 1.45;
  }

  @media (min-width: 700px) {
    .diff-cards {
      grid-template-columns: repeat(3, minmax(0, 1fr));
    }
  }
}

/* ── آیپد mini / عرض میانی ── */
@media (min-width: 744px) and (max-width: 899px) {
  .diff-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .diff-card:last-child {
    grid-column: 1 / -1;
    max-width: 420px;
    justify-self: center;
    width: 100%;
  }
}
