:root {
  --bg-1: #091a2b;
  --bg-2: #0d2842;
  --panel: #081725;
  --text: #f0f6ff;
  --accent: #f2c94c;
  --glass: rgba(8, 20, 34, 0.68);
}

@font-face {
  font-family: 'IRANYekanX';
  src:
    url('../font/woff2/IRANYekanX-Regular.woff2') format('woff2'),
    url('../font/woff/IRANYekanX-Regular.woff') format('woff');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'IRANYekanX';
  src:
    url('../font/woff2/IRANYekanX-Medium.woff2') format('woff2'),
    url('../font/woff/IRANYekanX-Medium.woff') format('woff');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'IRANYekanX';
  src:
    url('../font/woff2/IRANYekanX-DemiBold.woff2') format('woff2'),
    url('../font/woff/IRANYekanX-DemiBold.woff') format('woff');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'IRANYekanX';
  src:
    url('../font/woff2/IRANYekanX-Bold.woff2') format('woff2'),
    url('../font/woff/IRANYekanX-Bold.woff') format('woff');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: 'IRANYekanX', 'Vazirmatn', 'IRANSansX', 'Noto Sans Arabic', Tahoma, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 15%, #28557f 0%, transparent 35%),
    radial-gradient(circle at 80% 85%, #162f49 0%, transparent 28%),
    linear-gradient(180deg, #0a2035, #050b14);
  overscroll-behavior: none;
  touch-action: manipulation;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

button,
[role="button"],
a {
  touch-action: manipulation;
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  gap: 0;
}

.hud-top {
  text-align: center;
}

.hud-top h1 {
  margin: 0;
  font-size: clamp(1.2rem, 2.6vw, 2rem);
  letter-spacing: 0.3px;
}

.hud-top p {
  margin: 8px 0 0;
  opacity: 0.86;
}

.game-shell {
  position: relative;
  width: min(100%, 980px);
  aspect-ratio: 16 / 9;
  border: 2px solid #2d628f;
  border-radius: 14px;
  overflow: hidden;
  box-shadow:
    0 30px 55px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(137, 193, 241, 0.12) inset;
  background: linear-gradient(180deg, var(--bg-2), var(--panel));
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  background: transparent;
  touch-action: manipulation;
}

.hud {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 64px;
  display: flex;
  justify-content: space-between;
  font-size: clamp(0.9rem, 1.8vw, 1.08rem);
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.hud-chip {
  background: var(--glass);
  border: 1px solid rgba(144, 201, 249, 0.24);
  height: 42px;
  padding: 0 12px;
  border-radius: 999px;
  backdrop-filter: blur(2px);
  display: inline-flex;
  align-items: center;
}

.hud-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  direction: rtl;
  background: transparent;
  border: none;
  padding: 0;
}

.hud-home-btn {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid rgba(141, 201, 246, 0.3);
  background: rgba(10, 24, 39, 0.92);
  color: #f4f8ff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.28);
  transition: transform 120ms ease, background 120ms ease;
}

.hud-home-btn:hover {
  background: rgba(22, 42, 64, 0.95);
}

.hud-home-btn:active {
  transform: scale(0.96);
}

.sound-toggle {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 40;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(141, 200, 246, 0.33);
  border-radius: 12px;
  background: rgba(10, 24, 39, 0.88);
  color: #f3f8ff;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(2px);
}

.sound-toggle:hover {
  background: rgba(18, 39, 62, 0.92);
}

.sound-icon {
  display: inline-flex;
}

.sound-icon.off {
  display: none;
}

.sound-toggle.muted .sound-icon.on {
  display: none;
}

.sound-toggle.muted .sound-icon.off {
  display: inline-flex;
}


.overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  background: rgba(2, 8, 16, 0.74);
  text-align: center;
  padding: 20px;
}

.overlay.visible {
  display: flex;
}

.home-user-btn {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(141, 201, 246, 0.3);
  background: rgba(10, 24, 39, 0.92);
  color: #f4f8ff;
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.28);
  transition: transform 120ms ease, background 120ms ease;
}

.home-user-btn:hover {
  background: rgba(22, 42, 64, 0.95);
}

.home-user-btn:active {
  transform: scale(0.96);
}

.home-user-icon {
  display: inline-flex;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
}

.home-user-avatar {
  display: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  aspect-ratio: 1 / 1;
  border-radius: inherit;
  flex-shrink: 0;
}

.home-user-btn.logged .home-user-icon {
  display: none;
}

.home-user-btn.logged .home-user-avatar {
  display: block;
}

.poster-intro {
  width: min(88%, 620px);
  max-height: 54%;
  border-radius: 14px;
  overflow: hidden;
  box-shadow:
    0 20px 40px rgba(0, 0, 0, 0.42),
    0 0 30px rgba(81, 160, 224, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.poster-intro img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 100%;
  object-fit: contain;
}

.poster-gameover {
  display: none;
  width: min(84%, 500px);
  max-height: 52%;
  border-radius: 14px;
  overflow: hidden;
  box-shadow:
    0 20px 40px rgba(0, 0, 0, 0.46),
    0 0 32px rgba(255, 84, 84, 0.26);
  align-items: center;
  justify-content: center;
}

.poster-gameover img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 100%;
  object-fit: contain;
}

.overlay h2 {
  margin: 0;
  font-size: clamp(1.2rem, 3vw, 2rem);
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.55);
}

.overlay p {
  margin: 0;
  opacity: 0.92;
}

.overlay p:empty {
  display: none;
}

#startBtn {
  margin-top: 10px;
  border: none;
  background: linear-gradient(180deg, #fff0bc, #ffd15c 55%, #e5aa11);
  color: #271f06;
  font-weight: 700;
  font-size: clamp(1rem, 2.2vw, 1.25rem);
  border-radius: 999px;
  padding: 12px 36px;
  cursor: pointer;
  box-shadow:
    0 10px 22px rgba(242, 201, 76, 0.34),
    0 0 18px rgba(255, 212, 103, 0.62);
  animation: pulsePlay 1.1s ease-in-out infinite;
}

#startBtn:hover {
  filter: brightness(1.06);
}

#continueBtn {
  box-shadow:
    0 10px 22px rgba(242, 201, 76, 0.34),
    0 0 18px rgba(255, 212, 103, 0.62);
  animation: pulsePlay 1.1s ease-in-out infinite;
}

#continueBtn:hover {
  filter: brightness(1.06);
}

.intro-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  width: min(92%, 410px);
  align-items: stretch;
}

.intro-actions #startBtn,
.intro-actions #helpBtn {
  flex: 1;
  min-height: 48px;
  height: 48px;
  margin-top: 0;
  padding: 0 20px;
  font-size: clamp(1rem, 2vw, 1.12rem);
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.gameover-actions {
  display: none;
  margin-top: 10px;
  gap: 10px;
}

.action-btn {
  border: none;
  border-radius: 999px;
  padding: 10px 20px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 160ms ease, background 160ms ease, transform 120ms ease;
}

.action-btn.primary {
  color: #1d1300;
  background: linear-gradient(180deg, #ffe8a2, #f4bc28);
}

.action-btn.secondary {
  color: #e9f2ff;
  background: linear-gradient(180deg, #355677, #244460);
}

.action-btn.secondary:hover {
  filter: brightness(0.88);
}

.action-btn.secondary:active {
  transform: translateY(1px);
}

.overlay:not(.intro) .poster-intro {
  display: none;
}

.overlay.intro #overlayText {
  opacity: 0.86;
}

.overlay.intro .gameover-actions {
  display: none;
}

.overlay.gameover {
  background: rgba(20, 4, 6, 0.8);
}

.overlay.gameover .poster-gameover {
  display: flex;
}

.hud-best {
  background: var(--glass);
  border: 1px solid rgba(144, 201, 249, 0.24);
  height: 42px;
  padding: 0 12px;
  border-radius: 999px;
  backdrop-filter: blur(2px);
  display: inline-flex;
  align-items: center;
}

.overlay.gameover #overlayTitle {
  color: #ffd4d4;
  text-transform: lowercase;
}

.overlay.gameover #startBtn {
  display: none;
}

.overlay.gameover .intro-actions {
  display: none;
}

.overlay.gameover .gameover-actions {
  display: flex;
}

.help-panel {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(6, 14, 24, 0.84);
  z-index: 35;
  padding: 14px;
}

.help-panel.visible {
  display: flex;
}

.auth-panel {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(5, 12, 22, 0.86);
  z-index: 36;
  padding: 14px;
}

.auth-panel.visible {
  display: flex;
}

.leaderboard-panel {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(5, 12, 22, 0.86);
  z-index: 37;
  padding: 14px;
}

.leaderboard-panel.visible {
  display: flex;
}

.leaderboard-card {
  position: relative;
  width: min(94%, 560px);
  max-height: min(92%, 680px);
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(20, 42, 64, 0.97), rgba(10, 23, 38, 0.97));
  border-radius: 16px;
  border: 1px solid rgba(145, 202, 248, 0.25);
  box-shadow: 0 24px 44px rgba(0, 0, 0, 0.5);
  padding: 14px 14px 16px;
  text-align: right;
  overflow: hidden;
}

.leaderboard-title {
  margin: 0 0 8px;
  text-align: center;
}

.leaderboard-status {
  margin: 0 0 12px;
  text-align: center;
  opacity: 0.9;
}

.leaderboard-auth-hint {
  margin: -2px 0 12px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  color: #ffd978;
  font-weight: 700;
  opacity: 0.98;
  border: 1px solid rgba(255, 216, 114, 0.34);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 219, 129, 0.2), rgba(255, 197, 79, 0.1));
  box-shadow: inset 0 1px 0 rgba(255, 234, 176, 0.22);
}

.leaderboard-auth-hint[hidden] {
  display: none !important;
}

.leaderboard-auth-hint-icon {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.leaderboard-auth-hint-icon svg {
  width: 22px;
  height: 22px;
  display: block;
}

.leaderboard-list {
  flex: 1;
  min-height: 0;
  max-height: min(60vh, 460px);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 2px;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 42px 44px 1fr auto;
  gap: 10px;
  align-items: center;
  background: rgba(10, 22, 36, 0.72);
  border: 1px solid rgba(145, 202, 248, 0.18);
  border-radius: 12px;
  padding: 8px 10px;
}

.leaderboard-rank {
  color: #ffd978;
  font-weight: 700;
  text-align: center;
}

.leaderboard-avatar {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(151, 206, 249, 0.4);
  background: rgba(9, 20, 32, 0.9);
  display: grid;
  place-items: center;
  color: #dfeeff;
}

.leaderboard-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.leaderboard-avatar svg {
  width: 20px;
  height: 20px;
}

.leaderboard-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-score {
  font-weight: 700;
  color: #ffe6a3;
}

.leaderboard-more {
  margin-top: 10px;
  width: 100%;
  height: 44px;
  border: none;
  border-radius: 999px;
  color: #eef6ff;
  background: linear-gradient(180deg, #355677, #244460);
  font-weight: 700;
  cursor: pointer;
}

.leaderboard-more[hidden] {
  display: none;
}

.auth-card {
  position: relative;
  width: min(92%, 420px);
  background: linear-gradient(180deg, rgba(20, 42, 64, 0.97), rgba(10, 23, 38, 0.97));
  border-radius: 16px;
  border: 1px solid rgba(145, 202, 248, 0.25);
  box-shadow: 0 24px 44px rgba(0, 0, 0, 0.5);
  padding: 14px 14px 16px;
  text-align: right;
}

.auth-title {
  margin: 0 0 10px;
  text-align: center;
}

.auth-status {
  margin: 0 0 12px;
  opacity: 0.92;
  text-align: center;
  direction: rtl;
  unicode-bidi: plaintext;
  white-space: pre-line;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth-label {
  font-weight: 600;
}

.auth-input {
  width: 100%;
  border: 1px solid rgba(145, 202, 248, 0.28);
  background: rgba(9, 20, 34, 0.8);
  color: #f0f6ff;
  border-radius: 10px;
  height: 44px;
  padding: 0 12px;
  outline: none;
}

.auth-input:focus {
  border-color: rgba(162, 214, 255, 0.7);
  box-shadow: 0 0 0 3px rgba(121, 178, 224, 0.2);
}

.auth-submit,
.auth-logout {
  margin-top: 10px;
  border: none;
  border-radius: 999px;
  height: 44px;
  font-weight: 700;
  cursor: pointer;
}

.auth-submit {
  color: #1f1300;
  background: linear-gradient(180deg, #ffe8a8, #f2be2d);
}

.auth-logout {
  width: 100%;
  color: #eaf3ff;
  background: linear-gradient(180deg, #355677, #244460);
  display: none;
  transition: filter 160ms ease, background 160ms ease, transform 120ms ease;
}

.auth-logout:hover {
  filter: brightness(0.88);
}

.auth-logout:active {
  transform: translateY(1px);
}

.auth-card.logged-out .auth-logout {
  display: none;
}

.auth-card.logged-in .auth-form {
  display: none;
}

.auth-card.logged-in .auth-logout {
  display: block;
}

.help-card {
  position: relative;
  width: min(94%, 620px);
  max-height: min(92%, 620px);
  overflow: auto;
  background: linear-gradient(180deg, rgba(20, 42, 64, 0.97), rgba(10, 23, 38, 0.97));
  border-radius: 16px;
  border: 1px solid rgba(145, 202, 248, 0.25);
  padding: 12px 12px 14px;
  box-shadow: 0 24px 44px rgba(0, 0, 0, 0.5);
}

.help-title {
  margin: 0 0 10px;
  text-align: center;
  font-size: clamp(1.1rem, 2.5vw, 1.4rem);
}

.guide-item {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 12px;
  align-items: center;
  background: rgba(19, 36, 55, 0.66);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 10px;
}

.guide-item p {
  margin: 0;
  text-align: right;
}

.guide-preview {
  width: 132px;
  height: 100px;
  border-radius: 12px;
  background: rgba(12, 24, 38, 0.7);
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
}

.character-preview {
  background: rgba(8, 21, 34, 0.68);
}

.guide-character-wrap {
  position: relative;
  width: 66px;
  height: 84px;
  transform: rotate(-5deg);
  animation: guideCharacterFloat 1.25s infinite ease-in-out;
}

.guide-character-img {
  width: 66px;
  height: 84px;
  object-fit: contain;
  display: block;
}

.guide-char-flame {
  display: none;
}

.coin-preview {
  background: rgba(8, 26, 40, 0.75);
}

.guide-coin-glow {
  position: absolute;
  width: 76px;
  height: 76px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(255, 211, 91, 0.46) 0%, rgba(255, 211, 91, 0) 72%);
  animation: coinPulse 1.05s infinite ease-in-out;
}

.guide-coin-icon {
  width: 72px;
  height: 72px;
  filter: drop-shadow(0 0 5px rgba(255, 203, 74, 0.45));
  animation: coinSpin 0.9s infinite ease-in-out;
}

.missile-preview {
  background: rgba(8, 18, 32, 0.76);
}

.guide-missile-img {
  width: 118px;
  height: 68px;
  object-fit: contain;
  animation: missileFloat 0.65s infinite ease-in-out;
  z-index: 2;
}

.guide-missile-flame {
  display: none;
}

.guide-missile-smoke {
  display: none;
}

.guide-missile-smoke.smoke-1 {
  right: 108px;
  top: 53px;
  width: 11px;
  height: 11px;
}

.guide-missile-smoke.smoke-2 {
  right: 118px;
  top: 49px;
  width: 8px;
  height: 8px;
  animation-delay: 0.22s;
}

.revive-panel {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(6, 14, 24, 0.82);
  z-index: 15;
  padding: 16px;
}

.revive-panel.visible {
  display: flex;
}

.revive-card {
  position: relative;
  width: min(92%, 460px);
  background: linear-gradient(180deg, rgba(23, 43, 64, 0.95), rgba(12, 25, 40, 0.95));
  border-radius: 16px;
  border: 1px solid rgba(148, 203, 251, 0.25);
  padding: 14px 14px 16px;
  text-align: center;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.5);
}

.panel-close {
  position: sticky;
  top: 10px;
  left: 10px;
  width: 34px;
  height: 34px;
  margin-left: 0;
  margin-right: auto;
  margin-bottom: 8px;
  padding: 0;
  border: none;
  border-radius: 10px;
  color: #f7fbff;
  background: rgba(45, 73, 98, 0.85);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 8;
}

.panel-close:hover {
  background: rgba(62, 98, 131, 0.92);
}

.revive-img {
  width: min(100%, 300px);
  max-height: 220px;
  object-fit: contain;
  border-radius: 12px;
}

.revive-title {
  margin: 10px 0 6px;
  font-weight: 700;
}

.revive-meta {
  margin: 0 0 10px;
  opacity: 0.94;
}

.tap-btn {
  border: none;
  border-radius: 12px;
  width: 100%;
  position: relative;
  overflow: visible;
  padding: 12px 14px;
  font-weight: 700;
  color: #2c1b00;
  background: linear-gradient(180deg, #ffe7a5, #efbb2f);
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(242, 201, 76, 0.32);
}

.tap-btn:active {
  transform: scale(0.985);
}

.tap-btn:disabled {
  opacity: 0.75;
  cursor: default;
}

.tap-heart {
  position: absolute;
  left: 50%;
  bottom: 50%;
  z-index: 70;
  pointer-events: none;
  font-size: 1.35rem;
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
  line-height: 1;
  display: inline-block;
  text-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
  transform: translate(-50%, 6px) scale(0.72);
  opacity: 0;
  animation: tapHeartFloat 900ms cubic-bezier(0.2, 0.75, 0.25, 1) forwards;
}

.revive-hint {
  margin: 9px 0 0;
  min-height: 24px;
  font-weight: 600;
}

.resume-countdown {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: clamp(3rem, 10vw, 6rem);
  font-weight: 700;
  color: #fff6cf;
  text-shadow: 0 0 22px rgba(255, 230, 153, 0.65);
  background: rgba(5, 12, 21, 0.55);
  z-index: 20;
}

.resume-countdown.visible {
  display: flex;
}

@keyframes pulsePlay {
  0% {
    transform: scale(1);
    box-shadow:
      0 10px 22px rgba(242, 201, 76, 0.34),
      0 0 18px rgba(255, 212, 103, 0.55);
  }
  50% {
    transform: scale(1.08);
    box-shadow:
      0 14px 28px rgba(242, 201, 76, 0.44),
      0 0 32px rgba(255, 212, 103, 0.82);
  }
  100% {
    transform: scale(1);
    box-shadow:
      0 10px 22px rgba(242, 201, 76, 0.34),
      0 0 18px rgba(255, 212, 103, 0.55);
  }
}

@keyframes guideCharacterFloat {
  0% { transform: translateY(0) rotate(-5deg); }
  50% { transform: translateY(-6px) rotate(-4deg); }
  100% { transform: translateY(0) rotate(-5deg); }
}

@keyframes coinSpin {
  0% { transform: scaleX(0.82); }
  50% { transform: scaleX(1); }
  100% { transform: scaleX(0.82); }
}

@keyframes coinPulse {
  0% { transform: scale(0.96); opacity: 0.6; }
  50% { transform: scale(1.08); opacity: 0.88; }
  100% { transform: scale(0.96); opacity: 0.6; }
}

@keyframes missileFloat {
  0% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-2px) rotate(1deg); }
  100% { transform: translateY(0) rotate(-1deg); }
}

@keyframes missileFlame {
  from { transform: scaleX(0.84); opacity: 0.9; }
  to { transform: scaleX(1.12); opacity: 1; }
}

@keyframes smokeDrift {
  from { transform: translateX(0) translateY(0) scale(0.92); opacity: 0.62; }
  to { transform: translateX(-14px) translateY(-3px) scale(1.25); opacity: 0; }
}

@keyframes tapHeartFloat {
  0% {
    opacity: 0;
    transform: translate(-50%, 6px) scale(0.72);
  }
  16% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -106px) scale(1.2);
  }
}

@media (max-width: 640px) {
  html,
  body {
    overflow: hidden;
  }

  .page {
    min-height: 100dvh;
    padding: 0;
    width: 100vw;
    overflow: hidden;
  }

  .game-shell {
    width: 100vw;
    max-width: none;
    height: auto;
    border-radius: 0;
    border-width: 0;
    box-shadow: none;
  }

  .hud {
    top: 8px;
    left: 8px;
    right: 56px;
  }

  .hud div {
    height: 38px;
    padding: 0 10px;
  }

  .hud-home-btn {
    width: 38px;
    height: 38px;
  }

  .poster-intro {
    width: 88%;
    max-height: 48%;
  }

  .poster-gameover {
    width: 84%;
    max-height: 46%;
  }

  .intro-actions {
    flex-direction: row;
    width: 92%;
  }

  .intro-actions #startBtn,
  .intro-actions #helpBtn {
    width: auto;
    flex: 1;
  }

  .guide-item {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .guide-item p {
    text-align: center;
  }

  .guide-preview {
    width: 100%;
    max-width: 170px;
    margin: 0 auto;
  }

  #startBtn {
    padding: 10px 30px;
  }

  .sound-toggle {
    top: 8px;
    right: 8px;
    width: 38px;
    height: 38px;
  }

  .home-user-btn {
    width: 38px;
    height: 38px;
  }

  .revive-card {
    width: min(94%, 420px);
    max-height: calc(100% - 18px);
    overflow: hidden;
    padding-top: 14px;
  }

  .revive-img {
    width: min(68%, 170px);
    max-height: 100px;
  }

  .tap-btn {
    padding: 10px 12px;
    font-size: 0.95rem;
  }
}

@media (max-width: 900px) and (orientation: portrait) {
  html,
  body {
    overflow: hidden;
  }

  .page {
    min-height: 100dvh;
    width: 100vw;
    padding: 0;
    overflow: hidden;
  }

  .game-shell {
    position: fixed;
    top: 50%;
    left: 50%;
    width: calc(100vw * 16 / 9);
    height: 100vw;
    max-width: none;
    border-radius: 0;
    border-width: 0;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
    transform: translate(-50%, -50%) rotate(90deg);
    transform-origin: center center;
  }

  .hud {
    top: 10px;
    left: 10px;
    right: 60px;
  }

  .sound-toggle {
    top: 10px;
    right: 10px;
  }
}
