/* =============================================================================
   משפחת כאוס ברחוב — global styles (mobile-first, RTL)
   ============================================================================= */

:root {
  --font: "Rubik", "Assistant", system-ui, sans-serif;
  --color-sky-top: #7ec8ff;
  --color-sky-mid: #ffd29d;
  --color-sky-bot: #ff8b6a;
  --color-street: #2e294bff;
  --color-card: rgba(255, 255, 255, 0.92);
  --color-surface-elevated: rgba(255, 252, 255, 0.98);
  --color-ink: #1f1b2dff;
  --color-ink-muted: #4b3d58;
  --color-mint: #4fe3c2;
  --color-coral: #ff6b4a;
  --color-grape: #9b5de5;
  --color-accent-warm: #ff7a52;
  --glass-border: rgba(255, 255, 255, 0.58);
  --glass-highlight: linear-gradient(145deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0));
  --shadow-soft: 0 22px 56px rgba(18, 10, 35, 0.26), 0 4px 16px rgba(25, 15, 40, 0.12);
  --shadow-btn: 0 10px 0 rgba(0, 0, 0, 0.14);
  --shadow-btn-inner: inset 0 1px 0 rgba(255, 255, 255, 0.35);
  --radius: 22px;
  --radius-sm: 16px;
  --touch-bar-bg: linear-gradient(180deg, rgba(12, 8, 22, 0.92), rgba(8, 5, 16, 0.97));
  --touch-bar-edge: rgba(255, 255, 255, 0.12);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --vh: 100vh;
}
/* מובייל: dvh כשיש; svh (יציב יותר) דורס — פחות קפיצות כשסרגל הדפדפן נע */
@supports (height: 100dvh) {
  :root {
    --vh: 100dvh;
  }
}
@supports (height: 100svh) {
  :root {
    --vh: 100svh;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  height: -webkit-fill-available;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  min-height: var(--vh);
  background: #120b18;
  color: var(--color-ink);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
}

button,
label {
  font-family: inherit;
  cursor: pointer;
  border: none;
  touch-action: manipulation;
}

.app {
  min-height: 100%;
  min-height: var(--vh);
  position: relative;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

/* Game / menus: no accidental text selection on touch */
#app,
.screen {
  -webkit-user-select: none;
  user-select: none;
}

/* חייבים לנצח את #app — אחרת iOS/Safari מפסיקים פוקוס בשדה שם אחרי לחיצה */
#app #go-record-name,
#app .overlay input[type='text'],
#app .overlay input[type='search'],
#app .overlay textarea {
  -webkit-user-select: text !important;
  user-select: text !important;
  touch-action: auto;
}

.setup-inner input[type="file"],
.upload-tile {
  -webkit-user-select: auto;
  user-select: auto;
}

@media (prefers-reduced-motion: reduce) {
  .screen--anim,
  .menu-bg,
  .menu-content,
  .btn--pulse,
  .loading-blob,
  .loading-sil,
  .rotate-hint__icon,
  .card--glass::before {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
}

.screen--anim {
  transition: opacity 0.24s ease, transform 0.24s ease, visibility 0.24s;
}

/* Landscape guard */
.rotate-hint {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 30% 20%, #2a1b3d, #0e0814 70%);
  color: #fff;
  text-align: center;
}

.rotate-hint__card {
  max-width: 420px;
  padding: 28px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.rotate-hint__title {
  margin: 0 0 10px;
  font-weight: 900;
  font-size: 1.35rem;
}

.rotate-hint__sub {
  margin: 0;
  opacity: 0.9;
  line-height: 1.5;
}

.rotate-hint__icon {
  margin-top: 18px;
  font-size: 3rem;
  animation: bob 1.2s ease-in-out infinite;
}

@media screen and (orientation: landscape) and (max-height: 520px) {
  .rotate-hint {
    display: flex;
  }
  #app {
    visibility: hidden;
    pointer-events: none;
  }
}

/* Screens */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  min-height: var(--vh);
  width: 100%;
  max-width: 100vw;
  padding: calc(16px + var(--safe-t)) calc(16px + var(--safe-r)) calc(16px + var(--safe-b))
    calc(16px + var(--safe-l));
}

.is-hidden {
  display: none !important;
}

/* Allow fade transitions on main screens (overrides display:none above) */
.screen.screen--anim.is-hidden {
  display: flex !important;
  opacity: 0 !important;
  visibility: hidden;
  pointer-events: none !important;
  transform: translateY(10px) scale(0.98);
}

.screen.screen--anim:not(.is-hidden) {
  opacity: 1;
  visibility: visible;
  transform: translateZ(0);
}

/* Loading */
.screen--loading {
  background: linear-gradient(165deg, var(--color-sky-top), var(--color-sky-mid) 55%, var(--color-sky-bot));
  overflow: hidden;
}

.loading-blob {
  position: absolute;
  width: 120vw;
  height: 120vw;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.6), transparent 55%),
    radial-gradient(circle at 70% 60%, rgba(155, 93, 229, 0.35), transparent 50%);
  filter: blur(2px);
  animation: drift 9s ease-in-out infinite;
  opacity: 0.9;
}

.loading-blob--2 {
  width: 90vw;
  height: 90vw;
  top: 10%;
  left: -20%;
  animation-duration: 12s;
  animation-direction: reverse;
}

.loading-stage {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 92vw;
}

.loading-title {
  margin: 0 0 8px;
  font-weight: 900;
  font-size: clamp(1.5rem, 5.5vw, 2.1rem);
  color: #fff;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.12), 0 18px 45px rgba(0, 0, 0, 0.18);
}

.loading-sub {
  margin: 0 0 18px;
  color: rgba(255, 255, 255, 0.95);
  font-weight: 700;
}

.loading-family {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 18px;
}

.loading-sil {
  width: 28px;
  height: 38px;
  border-radius: 30px 30px 18px 18px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 0 rgba(0, 0, 0, 0.08);
  animation: bob 0.9s ease-in-out infinite;
}

.loading-sil:nth-child(2) { animation-delay: 0.1s; height: 34px; }
.loading-sil:nth-child(3) { animation-delay: 0.2s; height: 36px; }
.loading-sil:nth-child(4) { animation-delay: 0.3s; height: 32px; }
.loading-sil:nth-child(5) { animation-delay: 0.4s; height: 35px; }

.loading-bar {
  width: min(360px, 88vw);
  height: 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.15);
  overflow: hidden;
  margin: 0 auto;
}

.loading-bar__fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #fff2a8, #fff, #c8fff1);
  transition: width 0.35s ease;
}

/* Menu */
.screen--menu {
  background: #0f0818;
}

.menu-bg {
  position: absolute;
  inset: -20%;
  background: conic-gradient(from 210deg at 60% 40%, #ff8b6a, #ffd29d 35%, #7ec8ff 60%, #9b5de5 85%, #ff8b6a);
  filter: blur(20px);
  opacity: 0.85;
  will-change: transform;
  transform: translateZ(0);
  animation: bgspin 22s linear infinite;
}

.menu-content {
  position: relative;
  z-index: 1;
  width: min(460px, 92vw);
  padding: 26px 22px 22px;
  text-align: center;
}

.menu-title {
  margin: 0 0 6px;
  font-weight: 900;
  font-size: clamp(1.6rem, 5.5vw, 2.2rem);
  color: #2a1733;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.65);
}

.menu-tagline {
  margin: 0 0 16px;
  color: #4b3a56;
  font-weight: 700;
}

.menu-best {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(155, 93, 229, 0.12);
  border: 1px solid rgba(155, 93, 229, 0.25);
  font-weight: 800;
  margin-bottom: 16px;
}

.menu-foot {
  margin: 14px 0 8px;
  color: #5b4a63;
  font-size: 0.9rem;
  font-weight: 600;
}

/* Card */
.card {
  position: relative;
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.card--glass {
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.99), rgba(248, 244, 255, 0.94));
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-soft), 0 0 0 1px rgba(155, 93, 229, 0.06) inset;
  overflow: hidden;
}

.card--glass::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--glass-highlight);
  pointer-events: none;
  opacity: 0.85;
}

.card--glass > * {
  position: relative;
  z-index: 1;
}

.card--solid {
  background: var(--color-surface-elevated);
  border: 1px solid rgba(155, 93, 229, 0.12);
  box-shadow: var(--shadow-soft);
}

/* Buttons */
.btn {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 16px 18px;
  border-radius: 16px;
  font-weight: 900;
  font-size: clamp(1rem, 4vw, 1.1rem);
  text-align: center;
  transition: transform 0.08s ease, box-shadow 0.12s ease, filter 0.12s ease;
  margin-top: 10px;
  box-shadow: var(--shadow-btn);
  touch-action: manipulation;
}

.btn:active {
  transform: translateY(3px) scale(0.98);
  filter: brightness(0.97);
}

.btn--primary {
  background: linear-gradient(180deg, var(--color-accent-warm), #ff4d52);
  color: #fff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
  box-shadow: var(--shadow-btn), var(--shadow-btn-inner);
}

.btn--secondary {
  background: linear-gradient(180deg, #efe8ff, #d4c8ff);
  color: #2e2342;
  box-shadow: var(--shadow-btn), inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.btn--ghost {
  background: transparent;
  box-shadow: none;
  color: #3b2f52;
  margin-top: 4px;
}

.btn--wide {
  margin-top: 18px;
}

.btn--pulse {
  animation: btnpulse 2.4s ease-in-out infinite;
}

@keyframes btnpulse {
  0%,
  100% {
    transform: translateZ(0);
  }
  50% {
    transform: translateY(-2px) scale(1.01);
  }
}

.btn--menu-extra {
  margin-top: 0;
  margin-bottom: 4px;
  min-height: 44px;
  padding: 11px 14px;
  font-size: 0.98rem;
  font-weight: 800;
}

.go-btn-lb {
  margin-top: 4px;
  margin-bottom: 2px;
  min-height: 44px;
  padding: 11px 14px;
  font-weight: 900;
  font-size: 1rem;
  color: #3b2f52;
  border: 1px solid rgba(90, 70, 110, 0.25);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.55);
}

.go-record-block {
  margin: 14px 0 8px;
  padding: 12px 12px 14px;
  border-radius: 14px;
  background: rgba(255, 240, 210, 0.55);
  border: 1px solid rgba(255, 160, 90, 0.4);
}

.go-record-hint {
  margin: 0 0 8px;
  font-weight: 800;
  font-size: 0.92rem;
  color: #4a3040;
}

.go-record-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border-radius: 12px;
  border: 2px solid rgba(120, 80, 160, 0.35);
  font-family: inherit;
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 10px;
  background: rgba(255, 255, 255, 0.95);
  position: relative;
  z-index: 2;
  pointer-events: auto;
  touch-action: auto;
  -webkit-user-select: text;
  user-select: text;
}

.go-record-actions {
  display: flex;
  flex-direction: row;
  gap: 8px;
  align-items: stretch;
}

.go-record-actions .btn {
  flex: 1;
  margin-top: 0;
}

.btn--compact {
  min-height: 44px;
  padding: 12px 10px;
  font-size: 0.95rem;
}

.overlay--leaderboard {
  z-index: 920;
  align-items: flex-end;
  justify-content: center;
  padding: calc(24px + var(--safe-t)) calc(22px + var(--safe-r)) calc(16px + var(--safe-b))
    calc(22px + var(--safe-l));
}

.overlay-card--lb {
  max-height: min(72vh, 480px);
  display: flex;
  flex-direction: column;
  text-align: center;
}

.leaderboard-list {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  max-height: min(46vh, 300px);
  overflow-y: auto;
  text-align: right;
  direction: rtl;
  flex: 1;
  min-height: 0;
}

.leaderboard-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 10px;
  margin-bottom: 5px;
  background: rgba(155, 93, 229, 0.1);
  font-weight: 800;
  font-size: 0.98rem;
  border: 1px solid transparent;
}

.leaderboard-row--gold {
  background: linear-gradient(135deg, rgba(255, 232, 160, 0.55), rgba(255, 200, 80, 0.28));
  border-color: rgba(212, 175, 55, 0.55);
  box-shadow: 0 2px 12px rgba(200, 150, 40, 0.2);
}

.leaderboard-row--silver {
  background: linear-gradient(135deg, rgba(240, 245, 250, 0.85), rgba(180, 190, 205, 0.4));
  border-color: rgba(140, 150, 165, 0.45);
  box-shadow: 0 2px 10px rgba(100, 110, 130, 0.12);
}

.leaderboard-row--bronze {
  background: linear-gradient(135deg, rgba(255, 210, 175, 0.5), rgba(205, 145, 105, 0.28));
  border-color: rgba(160, 100, 65, 0.45);
  box-shadow: 0 2px 10px rgba(140, 80, 50, 0.15);
}

.leaderboard-rank-wrap {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  min-width: 3.4rem;
}

.leaderboard-medal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.15));
}

.leaderboard-rank {
  color: #6a5578;
  min-width: 1.5rem;
  flex-shrink: 0;
}

.leaderboard-row--gold .leaderboard-rank {
  color: #7a5a10;
  font-weight: 900;
}

.leaderboard-row--silver .leaderboard-rank {
  color: #4a5568;
  font-weight: 900;
}

.leaderboard-row--bronze .leaderboard-rank {
  color: #6b3f28;
  font-weight: 900;
}

.leaderboard-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-score {
  color: #c9186a;
  flex-shrink: 0;
}

.leaderboard-empty {
  margin: 8px 0 16px;
  font-weight: 700;
  color: #5b4a63;
  font-size: 0.95rem;
}

/* Setup */
.screen--setup {
  background: linear-gradient(165deg, #dbf6ff, #ffe3fb 45%, #fff2d6);
  overflow-y: auto;
  justify-content: flex-start;
}

.setup-inner {
  width: min(520px, 94vw);
  margin: 10px auto 24px;
  padding: 20px 16px 22px;
}

.setup-title {
  margin: 0 0 8px;
  text-align: center;
  font-weight: 900;
  font-size: 1.45rem;
}

.setup-hint {
  margin: 0 0 16px;
  text-align: center;
  color: #4b3a56;
  font-weight: 600;
  font-size: 0.95rem;
}

.upload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(152px, 1fr));
  gap: 12px;
}

@media (max-width: 360px) {
  .upload-grid {
    grid-template-columns: 1fr;
  }
}

.upload-tile {
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
}

.upload-tile__label {
  font-weight: 900;
  color: #2a1733;
  font-size: 0.98rem;
}

.upload-tile__drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border-radius: 16px;
  border: 3px dashed rgba(155, 93, 229, 0.45);
  background: rgba(255, 255, 255, 0.75);
  min-height: 200px;
  transition: border-color 0.15s ease, transform 0.12s ease;
}

.upload-tile:active .upload-tile__drop {
  transform: scale(0.99);
  border-color: var(--color-grape);
}

.upload-tile__ok {
  display: none;
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  width: 28px;
  height: 28px;
  line-height: 28px;
  text-align: center;
  border-radius: 50%;
  background: #2ecc71;
  color: #fff;
  font-weight: 900;
  font-size: 16px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.upload-tile__drop--has-file .upload-tile__ok {
  display: block;
}

.upload-tile__drop--drag {
  border-color: var(--color-grape) !important;
  background: rgba(155, 93, 229, 0.15) !important;
  transform: scale(1.02);
}

.upload-tile__drop canvas {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  box-shadow: 0 14px 30px rgba(30, 10, 50, 0.2);
}

.upload-tile__cta {
  font-size: 0.85rem;
  font-weight: 800;
  color: #5c4a70;
  text-align: center;
}

/* Game */
.screen--game {
  padding: 0;
  background: #000;
  height: 100%;
  height: var(--vh);
  max-height: var(--vh);
}

/* סיום משחק: הקנבס והפס תחתון עדיין תופסים מגע/פוקוס — נשבית שכבה (גיבוי ל־inert ב-JS) */
#app.state-game-over .screen--game #game-canvas,
#app.state-game-over .screen--game #touch-bar,
#app.state-game-over .screen--game #btn-pause-open,
#app.state-game-over .screen--game #game-hud,
#app.state-game-over .screen--game #banner-event {
  pointer-events: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.game-hud {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 40;
  padding: calc(6px + var(--safe-t)) calc(10px + var(--safe-r)) 4px calc(10px + var(--safe-l));
  pointer-events: none;
  direction: rtl;
  font-family: var(--font);
  max-width: 100vw;
}

.game-hud__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.game-hud__row--main {
  align-items: center;
}

.game-hud__stat {
  flex: 1;
  min-width: 0;
  background: rgba(12, 8, 20, 0.48);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  padding: 6px 10px;
  text-align: right;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}

/* ניקוד — בלי «חלון» כבד: טקסט צף עם צל קריא */
.game-hud__stat--primary {
  flex: 0 1 auto;
  max-width: min(72vw, 18rem);
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}

.game-hud__sub {
  margin: 1px 0 0;
  font-size: 0.65rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.88);
  line-height: 1.3;
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.6),
    0 0 12px rgba(0, 0, 0, 0.35);
}

.game-hud__sub-muted {
  font-weight: 600;
  color: rgba(255, 255, 255, 0.55);
}

.game-hud__combo-tag {
  font-weight: 800;
  color: #ffd166;
}

.game-hud__lbl {
  display: block;
  font-size: 0.6rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.82);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-shadow:
    0 1px 3px rgba(0, 0, 0, 0.55),
    0 0 10px rgba(0, 0, 0, 0.3);
}

.game-hud__val {
  display: block;
  font-size: clamp(1.35rem, 5.2vw, 1.75rem);
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.02em;
  line-height: 1.1;
  text-shadow:
    0 2px 4px rgba(0, 0, 0, 0.45),
    0 1px 0 rgba(0, 0, 0, 0.2);
}

/* מד כוח — צ'יפ קטן בצד (RTL), לא פס ענק על כל המסך */
.game-hud__row.game-hud__power {
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  margin-bottom: 0;
  margin-inline-end: auto;
  display: inline-flex;
  width: fit-content;
  max-width: min(280px, 88vw);
  padding: 4px 10px 5px;
  background: rgba(10, 8, 20, 0.62);
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.28);
}

.game-hud__legend {
  display: none; /* הסברי ירוק/אדום/קפיצה — מוסתרים (גם דסקטופ) כדי לא לכסות משחק */
  margin: 6px 0 0;
  text-align: right;
  max-width: 100%;
}

.game-hud__legend-row {
  margin: 0 0 4px;
  font-size: clamp(0.62rem, 2.6vw, 0.74rem);
  font-weight: 600;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.88);
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.55),
    0 0 10px rgba(0, 0, 0, 0.25);
}

.game-hud__legend-row:last-child {
  margin-bottom: 0;
}

.game-hud__legend-row strong {
  font-weight: 800;
  color: #fff;
}

.game-hud__legend-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px 2px;
  border-radius: 999px;
  font-size: 0.68em;
  font-weight: 900;
  letter-spacing: 0.04em;
  vertical-align: middle;
}

.game-hud__legend-tag--good {
  color: #0a2e1c;
  background: linear-gradient(160deg, #9ef5c6, #4ad588 85%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset;
}

.game-hud__legend-tag--bad {
  color: #fff;
  background: linear-gradient(160deg, #ff8a95, #e04858 90%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25) inset;
}

.game-hud__power-info {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex-shrink: 0;
}

.game-hud__power-info .game-hud__lbl {
  font-size: 0.52rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  color: rgba(255, 240, 210, 0.92);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.game-hud__hearts-wrap {
  flex-shrink: 0;
  padding: 3px 10px 4px;
  border-radius: 999px;
  background: rgba(6, 4, 12, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.game-hud__next-power {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.1em;
  min-height: 1.1em;
  padding: 0 2px;
  font-size: 0.92rem;
  line-height: 1;
  border-radius: 6px;
  background: transparent;
  border: none;
  box-shadow: none;
  filter: none;
}

.game-hud__meter {
  flex: 0 0 auto;
  width: clamp(88px, 28vw, 148px);
  height: 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
}

.game-hud__meter-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffe566, #f59e0b 55%, #ea580c);
  box-shadow: 0 0 6px rgba(255, 190, 60, 0.35);
  transition: width 0.12s ease;
}

.game-hud__meter--ready {
  border-color: rgba(255, 210, 120, 0.55);
  box-shadow:
    0 0 0 1px rgba(255, 200, 70, 0.45),
    inset 0 1px 2px rgba(0, 0, 0, 0.4);
  animation: meterpulse 1.1s ease-in-out infinite;
}

@keyframes meterpulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.88;
  }
}

.game-hud__pct {
  font-weight: 900;
  font-size: 0.95rem;
  color: #fff;
  min-width: 2.5rem;
  text-align: center;
}

.game-hud__hearts {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  margin-top: 2px;
}

.game-hud__hearts-row {
  font-size: 1.1rem;
  letter-spacing: 0.12em;
  color: #ff8ba4;
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.45),
    0 0 8px rgba(0, 0, 0, 0.2);
}

.game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  max-height: var(--vh);
  touch-action: none;
  -ms-touch-action: none;
}

.touch-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  pointer-events: auto;
  direction: ltr;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(4px, 1.4vw, 8px);
  padding: 6px calc(8px + var(--safe-r)) max(8px, calc(6px + var(--safe-b)))
    calc(8px + var(--safe-l));
  background: var(--touch-bar-bg);
  border-top: 1px solid var(--touch-bar-edge);
  box-shadow:
    0 -8px 32px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.touch-btn {
  position: relative;
  min-width: 0;
  min-height: max(48px, min(16vw, 68px));
  padding: 0;
  border: none;
  border-radius: clamp(14px, 3.8vw, 20px);
  color: #fff;
  font-weight: 900;
  letter-spacing: 0.02em;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s ease, box-shadow 0.12s ease, filter 0.12s ease;
  overflow: visible;
  isolation: isolate;
}

.touch-btn__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(2px, 0.8vw, 5px);
  width: 100%;
  height: 100%;
  min-height: inherit;
  padding: 5px 4px 6px;
  border-radius: inherit;
  position: relative;
  z-index: 1;
}

.touch-btn__icon-ring {
  display: flex;
  align-items: center;
  justify-content: center;
  width: clamp(32px, 9vw, 40px);
  height: clamp(32px, 9vw, 40px);
  border-radius: 50%;
  background: radial-gradient(
    circle at 30% 28%,
    rgba(255, 255, 255, 0.35) 0%,
    rgba(255, 255, 255, 0.06) 45%,
    rgba(0, 0, 0, 0.12) 100%
  );
  box-shadow:
    inset 0 2px 4px rgba(255, 255, 255, 0.35),
    inset 0 -3px 8px rgba(0, 0, 0, 0.18);
}

.touch-btn__glyph {
  font-size: clamp(1.28rem, 4.8vw, 1.65rem);
  line-height: 1;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.2));
}

.touch-btn__txt {
  font-size: clamp(0.62rem, 2.6vw, 0.78rem);
  line-height: 1.1;
  font-weight: 800;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  opacity: 0.98;
}

.touch-btn__inner::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.26) 0%, rgba(255, 255, 255, 0) 50%);
  pointer-events: none;
  z-index: 0;
}

.touch-btn__icon-ring,
.touch-btn__txt {
  position: relative;
  z-index: 1;
}

.touch-btn--dir .touch-btn__inner {
  background: linear-gradient(160deg, #5ed0ff 0%, #2185ff 45%, #0c52c4 100%);
  border: 1.5px solid rgba(255, 255, 255, 0.28);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.45) inset,
    0 -6px 14px rgba(0, 40, 120, 0.35) inset,
    0 14px 28px rgba(12, 60, 160, 0.45);
}

.touch-btn--jump .touch-btn__inner {
  background: linear-gradient(160deg, #b8ff9a 0%, #3ddb7a 42%, #0d9f5c 100%);
  border: 1.5px solid rgba(255, 255, 255, 0.32);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.5) inset,
    0 -6px 14px rgba(0, 90, 50, 0.28) inset,
    0 14px 28px rgba(20, 140, 80, 0.42);
}

.touch-btn--power {
  z-index: 2;
  min-height: max(52px, min(17.5vw, 74px));
  box-shadow: 0 6px 22px rgba(180, 80, 0, 0.38);
}

.touch-btn--power .touch-btn__inner {
  background: linear-gradient(
    165deg,
    #fff9ed 0%,
    #ffd34f 22%,
    #f59e0b 55%,
    #c2410c 100%
  );
  border: 2px solid rgba(255, 248, 220, 0.65);
  box-shadow:
    0 2px 0 rgba(255, 255, 255, 0.55) inset,
    0 -6px 16px rgba(120, 40, 0, 0.35) inset,
    0 16px 32px rgba(180, 70, 10, 0.5);
  color: #1a0d04;
}

.touch-btn--power .touch-btn__glyph,
.touch-btn--power .touch-btn__txt {
  color: #1f0f06;
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.45),
    0 2px 4px rgba(0, 0, 0, 0.18);
}

.touch-btn--power .touch-btn__txt {
  font-weight: 900;
  letter-spacing: 0.05em;
}

.touch-btn--power .touch-btn__icon-ring {
  width: clamp(34px, 9.5vw, 44px);
  height: clamp(34px, 9.5vw, 44px);
  background: radial-gradient(
    circle at 32% 26%,
    rgba(255, 255, 255, 0.85) 0%,
    rgba(255, 214, 120, 0.45) 42%,
    rgba(120, 45, 0, 0.22) 100%
  );
  box-shadow:
    inset 0 2px 5px rgba(255, 255, 255, 0.55),
    inset 0 -4px 10px rgba(100, 40, 0, 0.25),
    0 0 0 1px rgba(180, 70, 0, 0.2);
}

.touch-btn--power.touch-btn--power-ready .touch-btn__inner {
  animation: power-btn-ready-glow 1.15s ease-in-out infinite;
}

@keyframes power-btn-ready-glow {
  0%,
  100% {
    opacity: 0.94;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.035);
  }
}

.touch-btn:active,
.touch-btn.touch-btn--pressed {
  transform: translateY(3px) scale(0.98);
  filter: brightness(1.05);
}

.touch-btn--dir:active .touch-btn__inner,
.touch-btn--dir.touch-btn--pressed .touch-btn__inner {
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.25) inset,
    0 -4px 10px rgba(0, 40, 120, 0.3) inset,
    0 8px 18px rgba(12, 60, 160, 0.38);
}

.touch-btn--jump:active .touch-btn__inner,
.touch-btn--jump.touch-btn--pressed .touch-btn__inner {
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.35) inset,
    0 -4px 10px rgba(0, 90, 50, 0.25) inset,
    0 8px 18px rgba(20, 140, 80, 0.35);
}

.touch-btn--power:active .touch-btn__inner,
.touch-btn--power.touch-btn--pressed .touch-btn__inner {
  animation: none;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.35) inset,
    0 -4px 12px rgba(120, 40, 0, 0.32) inset,
    0 8px 20px rgba(160, 60, 8, 0.42);
}

.touch-btn:focus {
  outline: none;
}

.touch-btn:focus-visible {
  outline: 3px solid rgba(155, 213, 255, 0.95);
  outline-offset: 3px;
}

.touch-btn--power:focus-visible {
  outline-color: rgba(255, 210, 130, 0.95);
}

@media (prefers-reduced-motion: reduce) {
  .touch-btn {
    transition: none;
  }

  .touch-btn--power.touch-btn--power-ready .touch-btn__inner {
    animation: none;
  }

  .game-hud__meter--ready {
    animation: none;
  }
}

.btn-pause-fab {
  position: fixed;
  top: calc(54px + var(--safe-t));
  left: calc(10px + var(--safe-l));
  z-index: 45;
  min-width: 44px;
  min-height: 44px;
  width: 44px;
  height: 44px;
  touch-action: manipulation;
  border-radius: 12px;
  font-weight: 900;
  letter-spacing: 1px;
  color: #fff;
  background: rgba(15, 10, 24, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
}

.btn-pause-fab:active {
  transform: scale(0.96);
}

.banner-event {
  position: fixed;
  top: calc(88px + var(--safe-t));
  left: 50%;
  transform: translateX(-50%);
  z-index: 24;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: #2a1733;
  font-weight: 800;
  font-size: clamp(0.78rem, 3.2vw, 0.92rem);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
  max-width: 92vw;
  text-align: center;
  border: 1px solid rgba(90, 70, 110, 0.2);
  transform-origin: center top;
}

.banner-event:not(.is-hidden) {
  animation: bannerEventPop 0.32s ease-out;
}

@keyframes bannerEventPop {
  from {
    opacity: 0;
    transform: translateX(-50%) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .banner-event:not(.is-hidden) {
    animation: none;
  }
}

/* Overlays */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(22px + var(--safe-t)) calc(22px + var(--safe-r)) calc(22px + var(--safe-b))
    calc(22px + var(--safe-l));
  background: rgba(8, 4, 14, 0.92);
  overscroll-behavior: contain;
}

.overlay-card {
  width: min(420px, 94vw);
  padding: 22px 18px 18px;
  text-align: center;
}

.overlay-title {
  margin: 0 0 12px;
  font-weight: 900;
  font-size: 1.6rem;
}

.go-score-line,
.go-best-line {
  margin: 6px 0;
  font-weight: 800;
  font-size: 1.1rem;
}

.go-new {
  margin: 12px 0 14px;
  font-weight: 900;
  color: #c9186a;
}

.overlay-card--party {
  border: 3px solid rgba(255, 210, 120, 0.8);
}

@keyframes drift {
  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }
  50% {
    transform: translate(6%, -4%) scale(1.08);
  }
}

@keyframes bgspin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

/* =============================================================================
   מובייל — מסכים צרים, notch, גבהים קיצוניים
   ============================================================================= */

@media (max-width: 380px) {
  .game-hud {
    padding: calc(4px + var(--safe-t)) calc(6px + var(--safe-r)) 3px calc(6px + var(--safe-l));
  }

  .game-hud__stat--primary {
    max-width: min(82vw, 17rem);
  }

  .game-hud__val {
    font-size: clamp(1.12rem, 5.8vw, 1.55rem);
  }

  .game-hud__sub {
    font-size: 0.6rem;
  }

  .btn-pause-fab {
    top: calc(50px + var(--safe-t));
    left: calc(6px + var(--safe-l));
    min-width: 40px;
    min-height: 40px;
    width: 40px;
    height: 40px;
  }

  .banner-event {
    top: calc(82px + var(--safe-t));
    font-size: clamp(0.7rem, 3.4vw, 0.86rem);
    padding: 6px 10px;
    max-width: 96vw;
  }
}

@media (max-width: 340px) {
  .game-hud__row--main {
    gap: 4px;
  }

  .game-hud__hearts-wrap {
    padding: 2px 6px 3px;
  }

  .game-hud__power-info .game-hud__lbl {
    font-size: clamp(0.56rem, 2.2vw, 0.66rem);
  }

  .touch-bar {
    gap: 3px;
    padding: 5px calc(5px + var(--safe-r)) max(6px, calc(5px + var(--safe-b))) calc(5px + var(--safe-l));
  }

  .touch-btn {
    min-height: max(44px, min(19vw, 62px));
  }

  .touch-btn__txt {
    font-size: clamp(0.5rem, 2.3vw, 0.66rem);
  }
}

/* רוחב מאוד צר: רק אייקונים על הכפתורים כדי לשמור אזור משחק */
@media (max-width: 300px) {
  .touch-btn__txt {
    display: none;
  }

  .touch-btn__inner {
    gap: 0;
    padding: 8px 3px;
  }

  .touch-btn__glyph {
    font-size: clamp(1.35rem, 6.5vw, 1.62rem);
  }
}

/* לפני מסך הסיבוב: גובה נמוך — מקצרים HUD */
@media (max-height: 520px) and (orientation: landscape) {
  .game-hud {
    padding-top: calc(2px + var(--safe-t));
  }

  .btn-pause-fab {
    top: calc(52px + var(--safe-t));
  }

  .banner-event {
    top: calc(82px + var(--safe-t));
  }
}
