* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: none;
}

html, body {
  width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  background: #87ceeb;
  font-family: 'Nunito', 'Segoe UI', Tahoma, sans-serif;
}

html.ios-immersive-fullscreen,
html.ios-immersive-fullscreen body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: var(--app-height, 100dvh);
  min-height: var(--app-height, 100dvh);
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

html.ios-immersive-fullscreen #game-container,
html.ios-immersive-fullscreen #ui,
html.ios-immersive-fullscreen #touch-controls {
  height: var(--app-height, 100dvh);
}

#game-container {
  position: fixed;
  inset: 0;
}

#game-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

#ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

#hud.hidden {
  display: none;
}

#hud {
  position: absolute;
  top: 8px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 0;
  pointer-events: none;
}

.hud-left {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.hud-item {
  background: rgba(20, 20, 30, 0.65);
  color: #f0e6d0;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: clamp(14px, 2.5vw, 18px);
  font-weight: 800;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.hud-rings {
  gap: 8px;
  flex-shrink: 0;
  width: auto;
}

.hud-ring-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  perspective: 80px;
  flex-shrink: 0;
}

.ring-anim {
  display: block;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  transform-style: preserve-3d;
  animation: ring-tumble 2.4s linear infinite;
  will-change: transform;
  backface-visibility: hidden;
}

.ring-svg {
  display: block;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

@keyframes ring-tumble {
  0% { transform: rotateX(65deg) rotateZ(0deg); }
  100% { transform: rotateX(65deg) rotateZ(360deg); }
}

.hud-rings.collect-pop .hud-ring-icon {
  animation: ring-collect-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.hud-rings.collect-pop .ring-anim {
  animation: ring-collect-spin 0.45s ease-out;
}

@keyframes ring-collect-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.35); }
  100% { transform: scale(1); }
}

@keyframes ring-collect-spin {
  0% { transform: rotateX(65deg) rotateZ(0deg) scale(1); }
  50% { transform: rotateX(65deg) rotateZ(180deg) scale(1.2); }
  100% { transform: rotateX(65deg) rotateZ(360deg) scale(1); }
}

.hud-rings-text {
  min-width: 2.5em;
  color: #ffe566;
  text-shadow: 0 0 8px rgba(255, 204, 0, 0.35);
}

.hud-lives {
  gap: 3px;
  padding: 6px 4px;
  background: transparent;
  border: none;
  backdrop-filter: none;
  box-shadow: none;
}

.hud-heart-slot {
  position: relative;
  display: inline-block;
  width: 1.05em;
  height: 1.05em;
  font-size: 1.15em;
  line-height: 1;
  flex-shrink: 0;
  transform-origin: center center;
}

.hud-heart-slot.heart-slot-pop {
  animation: heart-slot-pop 0.32s cubic-bezier(0.34, 1.45, 0.64, 1);
}

@keyframes heart-slot-pop {
  0% { transform: scale(1); }
  42% { transform: scale(1.5); }
  100% { transform: scale(1); }
}

.hud-heart-outline,
.hud-heart-fill {
  position: absolute;
  inset: 0;
  display: block;
  text-align: center;
}

.hud-heart-outline {
  color: transparent;
  -webkit-text-stroke: 1.2px #9a9a9a;
  paint-order: stroke fill;
}

.hud-heart-fill-clip {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.hud-heart-fill {
  position: absolute;
  inset: 0;
  display: block;
  text-align: center;
  color: #ff5566;
  filter: drop-shadow(0 0 4px rgba(255, 60, 80, 0.5));
}

.hud-heart-slot[data-fill="0"] .hud-heart-fill {
  clip-path: inset(0 100% 0 0);
}

.hud-heart-slot[data-fill="0.5"] .hud-heart-fill {
  clip-path: inset(0 50% 0 0);
}

.hud-heart-slot[data-fill="1"] .hud-heart-fill {
  clip-path: none;
}

.hud-level {
  background: transparent;
  border: none;
  backdrop-filter: none;
  padding: 0;
  overflow: visible;
}

.level-name-fill {
  position: relative;
  display: inline-block;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: inherit;
  font-weight: inherit;
  color: #f0e6d0;
  background: rgba(20, 20, 30, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
  backdrop-filter: blur(4px);
}

.level-name-fill::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--path-progress, 0%);
  background: linear-gradient(90deg, rgba(74, 144, 217, 0.7), rgba(110, 185, 245, 0.55));
  z-index: 0;
  transition: width 0.12s linear;
  pointer-events: none;
}

.flying-heart {
  position: fixed;
  z-index: 200;
  pointer-events: none;
  font-size: clamp(22px, 4vw, 32px);
  color: #ff5566;
  filter: drop-shadow(0 0 10px rgba(255, 60, 90, 0.85));
  transform: translate(-50%, -50%);
  will-change: left, top, transform, opacity;
}

.flying-heart-landed {
  transition: transform 0.12s ease-out, opacity 0.12s ease-out;
  transform: translate(-50%, -50%) scale(1.35) !important;
  opacity: 0 !important;
}

.falling-heart-loss {
  position: fixed;
  z-index: 200;
  pointer-events: none;
  transform: translate(-50%, -50%);
  will-change: transform, opacity;
}

.falling-heart-loss-slot {
  position: relative;
  display: block;
  width: 1.05em;
  height: 1.05em;
  line-height: 1;
}

.falling-heart-loss[data-piece="right"] .falling-heart-loss-slot {
  clip-path: inset(0 0 0 50%);
}

.falling-heart-loss[data-piece="left"] .falling-heart-loss-slot {
  clip-path: inset(0 50% 0 0);
}

.falling-heart-loss.falling-heart-loss-animate {
  animation: heart-fall-loss 0.68s cubic-bezier(0.33, 0, 0.67, 1) forwards;
}

.falling-heart-loss[data-piece="right"].falling-heart-loss-animate {
  animation-name: heart-fall-loss-right;
}

.falling-heart-loss[data-piece="left"].falling-heart-loss-animate {
  animation-name: heart-fall-loss-left;
}

@keyframes heart-fall-loss {
  0% {
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, calc(-50% + 52px)) scale(0.78) rotate(14deg);
    opacity: 0;
  }
}

@keyframes heart-fall-loss-right {
  0% {
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translate(calc(-50% + 4px), calc(-50% + 48px)) scale(0.78) rotate(18deg);
    opacity: 0;
  }
}

@keyframes heart-fall-loss-left {
  0% {
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translate(calc(-50% - 4px), calc(-50% + 48px)) scale(0.78) rotate(-18deg);
    opacity: 0;
  }
}

.hud-icon-btn {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  background: rgba(20, 20, 30, 0.72);
  color: #f0e6d0;
  border: 2px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(6px);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.3);
  transition: transform 0.12s, background 0.12s, box-shadow 0.12s;
}

.hud-icon-btn svg {
  width: 22px;
  height: 22px;
}

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

.hud-pause-btn {
  flex-shrink: 0;
}

.fullscreen-btn {
  position: fixed;
  top: max(8px, env(safe-area-inset-top, 8px));
  right: max(12px, env(safe-area-inset-right, 12px));
  z-index: 20;
  pointer-events: auto;
}

.fullscreen-btn.hidden {
  display: none;
}

.fullscreen-btn .icon-exit {
  display: none;
}

.fullscreen-btn.is-fullscreen .icon-enter {
  display: none;
}

.fullscreen-btn.is-fullscreen .icon-exit {
  display: block;
}

.fullscreen-btn:hover {
  background: rgba(40, 40, 55, 0.85);
  border-color: rgba(255, 220, 100, 0.35);
  color: #ffe566;
}

#hud:not(.hidden) {
  right: 68px;
}

.hud-pause-btn:hover,
.pause-action-btn:hover {
  background: rgba(40, 40, 55, 0.85);
  border-color: rgba(255, 220, 100, 0.35);
  color: #ffe566;
}

/* ——— Pause & confirm overlays ——— */
.pause-overlay,
.confirm-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

.pause-overlay {
  background: rgba(20, 20, 30, 0.55);
  backdrop-filter: blur(4px);
  z-index: 25;
}

.confirm-overlay {
  background: rgba(10, 10, 18, 0.65);
  backdrop-filter: blur(6px);
  z-index: 30;
}

.pause-overlay.hidden,
.confirm-overlay.hidden {
  display: none;
}

.pause-panel {
  display: flex;
  gap: 20px;
  padding: 24px 32px;
  background: rgba(20, 20, 30, 0.82);
  border: 2px solid rgba(255, 220, 100, 0.2);
  border-radius: 28px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  animation: pause-panel-in 0.25s cubic-bezier(0.34, 1.4, 0.64, 1);
}

@keyframes pause-panel-in {
  from { opacity: 0; transform: scale(0.85) translateY(-12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.pause-action-btn {
  width: 56px;
  height: 56px;
  background: linear-gradient(180deg, rgba(60, 60, 80, 0.9) 0%, rgba(30, 30, 45, 0.95) 100%);
}

.pause-action-btn svg {
  width: 28px;
  height: 28px;
}

#btn-resume.pause-action-btn {
  background: linear-gradient(180deg, #7ee05a 0%, #3cb82e 55%, #2a9a22 100%);
  color: #fff;
  border-color: #1e7a18;
  box-shadow: 0 4px 0 #1e7a18, 0 6px 16px rgba(0, 80, 0, 0.35);
}

#btn-resume.pause-action-btn:active {
  box-shadow: 0 1px 0 #1e7a18;
  transform: translateY(3px) scale(0.95);
}

#btn-pause-restart.pause-action-btn {
  color: #ffe566;
  border-color: rgba(255, 204, 0, 0.35);
}

#btn-pause-exit.pause-action-btn {
  color: #ff8877;
  border-color: rgba(255, 100, 80, 0.35);
}

.confirm-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 28px 36px;
  max-width: min(360px, 85vw);
  background: rgba(20, 20, 30, 0.9);
  border: 2px solid rgba(255, 220, 100, 0.25);
  border-radius: 24px;
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.5);
  animation: pause-panel-in 0.22s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.confirm-message {
  font-size: clamp(16px, 3vw, 20px);
  font-weight: 800;
  color: #f0e6d0;
  text-align: center;
  line-height: 1.4;
  margin: 0;
}

.confirm-actions {
  display: flex;
  gap: 16px;
}

.confirm-btn {
  width: 52px;
  height: 52px;
}

.confirm-yes {
  background: linear-gradient(180deg, #7ee05a 0%, #3cb82e 100%);
  color: #fff;
  border-color: #1e7a18;
}

.confirm-no {
  background: linear-gradient(180deg, #ff8877 0%, #e05544 100%);
  color: #fff;
  border-color: #b03028;
}

.confirm-btn svg {
  width: 26px;
  height: 26px;
}

/* ——— Casual menu ——— */
.menu-overlay.hidden {
  display: none;
}

.menu-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 15;
}

.menu-overlay .menu-logo-wrap,
.menu-overlay .speech-bubble,
.menu-overlay .menu-buttons,
.menu-overlay .map-panel,
.menu-overlay .map-actions,
.menu-overlay button {
  pointer-events: auto;
}

.menu-sky-deco {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    transparent 0%,
    transparent 38%,
    rgba(135, 206, 235, 0.25) 52%,
    rgba(200, 220, 180, 0.4) 100%
  );
  pointer-events: none;
}

.menu-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  padding: clamp(16px, 4vw, 48px) clamp(20px, 6vw, 80px);
  padding-left: 42%;
}

.menu-logo-wrap {
  position: relative;
  margin-bottom: 20px;
  align-self: flex-end;
}

.menu-title {
  font-size: clamp(32px, 7vw, 56px);
  font-weight: 900;
  color: #fff;
  text-shadow:
    0 3px 0 #e85d2a,
    0 6px 0 #c44a1a,
    0 8px 20px rgba(0, 0, 0, 0.35);
  letter-spacing: 0.02em;
  line-height: 1.1;
  text-align: right;
}

.menu-title-shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,0.35) 50%, transparent 70%);
  animation: title-shine 4s ease-in-out infinite;
  pointer-events: none;
}

@keyframes title-shine {
  0%, 100% { opacity: 0; transform: translateX(-30%); }
  50% { opacity: 1; transform: translateX(30%); }
}

.game-dialogs-layer {
  position: fixed;
  inset: 0;
  z-index: 12;
  pointer-events: none;
  overflow: hidden;
}

.game-dialog {
  position: fixed;
  left: 0;
  top: 0;
  margin: 0;
  border: none;
  padding: 0;
  background: none;
  transform-origin: center bottom;
  filter: drop-shadow(0 6px 18px rgba(60, 80, 100, 0.22));
}

.game-dialog.hidden {
  display: none;
}

.game-dialog__panel {
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  background: rgba(210, 218, 228, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.52);
  box-shadow:
    0 8px 28px rgba(70, 90, 110, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 -1px 0 rgba(120, 140, 160, 0.12);
  -webkit-backdrop-filter: blur(14px) saturate(1.25);
  backdrop-filter: blur(14px) saturate(1.25);
}

.game-dialog__panel::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.38) 0%,
    rgba(255, 255, 255, 0.08) 42%,
    rgba(180, 195, 210, 0.06) 100%
  );
  pointer-events: none;
}

.game-dialog__text {
  position: relative;
  margin: 0;
  padding: 10px 16px 12px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.42;
  color: #243040;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.65);
}

.game-dialog__text.typing::after {
  content: '|';
  margin-left: 1px;
  color: rgba(70, 100, 130, 0.85);
  animation: typing-cursor 0.75s step-end infinite;
}

.game-dialog--speech {
  max-width: min(260px, 68vw);
  transform: translate(-50%, calc(-100% - 8px));
  animation: dialog-unfold 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.game-dialog--speech.game-dialog--replay {
  animation: dialog-unfold 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes dialog-unfold {
  from {
    opacity: 0;
    transform: translate(-50%, calc(-100% - 8px)) scaleY(0.35) scaleX(0.88);
  }
  to {
    opacity: 1;
    transform: translate(-50%, calc(-100% - 8px)) scaleY(1) scaleX(1);
  }
}

.game-dialog--path {
  width: min(260px, 68vw);
  transform: translate(-50%, -50%) scale(0.32);
  transition: transform 0.42s cubic-bezier(0.22, 1, 0.36, 1), filter 0.35s ease;
}

.game-dialog--path.game-dialog--compact .game-dialog__text {
  opacity: 0;
  height: 0;
  padding: 0;
  overflow: hidden;
}

.game-dialog--path.game-dialog--compact .game-dialog__panel {
  border-radius: 50%;
  min-width: 14px;
  min-height: 14px;
}

.game-dialog--path.game-dialog--expanded {
  transform: translate(-50%, calc(-100% - 6px)) scale(1);
  filter: drop-shadow(0 8px 22px rgba(60, 80, 100, 0.28));
}

.game-dialog--path.game-dialog--expanded .game-dialog__panel {
  animation: dialog-unfold 0.48s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.game-dialog--path.game-dialog--expanded .game-dialog__text {
  opacity: 1;
  height: auto;
  padding: 10px 16px 12px;
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .game-dialog__panel {
    background: rgba(210, 218, 228, 0.82);
  }
}

.speech-bubble {
  position: relative;
  max-width: min(420px, 52vw);
  background: #fff;
  border: 4px solid #5a9fd4;
  border-radius: 24px;
  padding: 18px 22px;
  margin-bottom: 28px;
  box-shadow: 0 8px 24px rgba(0, 60, 120, 0.2);
  animation: bubble-pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.speech-bubble p {
  font-size: clamp(15px, 2.4vw, 19px);
  font-weight: 700;
  color: #3a4a5a;
  line-height: 1.45;
  margin: 0;
}

.speech-bubble p.typing::after {
  content: '|';
  margin-left: 1px;
  color: #5a9fd4;
  animation: typing-cursor 0.75s step-end infinite;
}

@keyframes typing-cursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.speech-bubble--replay {
  animation: bubble-pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes bubble-pop {
  from { opacity: 0; transform: scale(0.85) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.btn-play {
  background: linear-gradient(180deg, #7ee05a 0%, #3cb82e 55%, #2a9a22 100%);
  color: #fff;
  border: none;
  border-bottom: 5px solid #1e7a18;
  padding: 16px 44px;
  font-family: inherit;
  font-size: clamp(18px, 3.2vw, 24px);
  font-weight: 800;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 6px 0 #1e7a18, 0 10px 24px rgba(0, 80, 0, 0.3);
  transition: transform 0.1s, box-shadow 0.1s;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.btn-play-icon {
  font-size: 0.85em;
}

.btn-play:active,
.btn-bounce:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #1e7a18, 0 4px 12px rgba(0, 80, 0, 0.25);
}

.btn-bounce {
  animation: btn-float 2.5s ease-in-out infinite;
}

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

.btn-bounce:active {
  animation: none;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  align-self: center;
}

.btn-exit {
  min-width: 140px;
}

.map-level-desc {
  font-size: clamp(13px, 2.2vw, 15px);
  font-weight: 700;
  color: #4a6080;
  line-height: 1.45;
  margin: 8px 0 0;
  min-height: 2.8em;
  text-align: left;
}

.map-level-desc.typing::after {
  content: '|';
  margin-left: 1px;
  color: #5a9fd4;
  animation: typing-cursor 0.75s step-end infinite;
}

#map-level-meta {
  font-size: clamp(14px, 2.2vw, 17px);
  font-weight: 700;
  color: #3a4a5a;
  line-height: 1.5;
  text-align: center;
}

.btn-secondary {
  background: linear-gradient(180deg, #fff 0%, #e8eef4 100%);
  color: #4a6080;
  border: 3px solid #b8c8d8;
  border-bottom-width: 4px;
  padding: 12px 28px;
  font-family: inherit;
  font-size: clamp(15px, 2.5vw, 18px);
  font-weight: 800;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 40, 80, 0.12);
  transition: transform 0.1s;
}

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

.map-overlay {
  background: transparent;
}

.map-panel {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  background: rgba(255, 255, 255, 0.92);
  border: 3px solid #5a9fd4;
  border-radius: 20px;
  padding: 12px 24px;
  box-shadow: 0 6px 20px rgba(0, 60, 120, 0.18);
  pointer-events: none;
}

.map-panel-top {
  top: 12px;
  margin-top: 8px;
}

.map-panel-bottom {
  bottom: 88px;
  min-width: min(320px, 80vw);
  font-size: clamp(14px, 2.2vw, 17px);
  font-weight: 700;
  color: #3a4a5a;
  line-height: 1.5;
}

.map-title {
  font-size: clamp(20px, 4vw, 28px);
  font-weight: 900;
  color: #2a6aaa;
  margin: 0;
}

.map-subtitle {
  font-size: clamp(12px, 2vw, 15px);
  font-weight: 700;
  color: #6a8098;
  margin: 4px 0 0;
}

.map-actions {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 16px;
  align-items: center;
}

.map-level-label {
  pointer-events: none;
}

.map-label-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid #5a9fd4;
  border-radius: 12px;
  padding: 4px 10px;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 12px;
  color: #2a5080;
  box-shadow: 0 3px 10px rgba(0, 40, 80, 0.2);
  white-space: nowrap;
  transition: transform 0.15s, border-color 0.15s;
}

.map-label-inner.current {
  border-color: #ffb020;
  background: #fff8e8;
}

.map-label-inner.selected {
  border-color: #ff6b4a;
  transform: scale(1.1);
  box-shadow: 0 4px 14px rgba(255, 80, 40, 0.35);
}

.map-label-inner.locked {
  opacity: 0.65;
  border-color: #aaa;
  color: #888;
}

.map-label-num {
  font-size: 14px;
  line-height: 1;
}

.map-label-rings {
  font-size: 11px;
  color: #e8a000;
}

.map-label-path {
  font-size: 10px;
  color: #5a9fd4;
  line-height: 1;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(30, 30, 40, 0.85);
  backdrop-filter: blur(8px);
  pointer-events: auto;
  text-align: center;
  padding: 24px;
}

.overlay.hidden {
  display: none;
}

.overlay h1 {
  font-size: clamp(28px, 6vw, 48px);
  color: #e8dcc8;
  margin-bottom: 12px;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}

.overlay h2 {
  font-size: clamp(24px, 5vw, 36px);
  color: #e8dcc8;
  margin-bottom: 16px;
}

.subtitle {
  color: #a09888;
  font-size: clamp(14px, 2.5vw, 18px);
  margin-bottom: 24px;
  max-width: 480px;
}

.controls-hint {
  color: #888;
  font-size: clamp(12px, 2vw, 15px);
  margin-bottom: 28px;
  line-height: 1.8;
}

.btn-primary {
  background: linear-gradient(180deg, #c9a84c, #8b6914);
  color: #fff;
  border: none;
  padding: 14px 48px;
  font-size: clamp(16px, 3vw, 20px);
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  transition: transform 0.1s;
}

.btn-primary:active {
  transform: scale(0.95);
}

.overlay-actions {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 8px;
}

#touch-controls {
  position: fixed;
  bottom: 10px;
  left: 0;
  right: 0;
  display: none;
  pointer-events: none;
  z-index: 20;
}

#touch-controls.visible {
  display: block;
}

.roblox-joystick {
  position: absolute;
  bottom: 12px;
  width: 72px;
  height: 72px;
  pointer-events: auto;
  touch-action: none;
}

#joystick-left {
  left: 16px;
}

.roblox-jump-btn {
  position: absolute;
  bottom: 12px;
  right: 16px;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.15);
  color: rgba(255, 255, 255, 0.85);
  pointer-events: auto;
  touch-action: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.1s, transform 0.1s;
}

.roblox-jump-btn .jump-icon {
  width: 36px;
  height: 36px;
}

.roblox-jump-btn:active,
.roblox-jump-btn.active {
  background: rgba(255, 255, 255, 0.32);
  transform: scale(0.92);
  color: #fff;
}

.joystick-base {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  border: 2px solid rgba(255, 255, 255, 0.28);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.15);
}

.joystick-stick {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  border: 1.5px solid rgba(255, 255, 255, 0.7);
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  transition: background 0.1s;
}

.roblox-joystick.active .joystick-stick {
  background: rgba(255, 255, 255, 0.75);
}

.roblox-joystick.active .joystick-base {
  background: rgba(255, 255, 255, 0.24);
}


@media (max-width: 768px), (max-height: 520px) {
  .menu-content {
    align-items: center;
    justify-content: flex-end;
    padding: 12px 16px max(20px, env(safe-area-inset-bottom, 16px));
    padding-left: 16px;
    padding-top: max(12px, env(safe-area-inset-top, 12px));
  }

  .menu-logo-wrap {
    align-self: center;
    margin-bottom: 12px;
  }

  .menu-title {
    text-align: center;
    font-size: clamp(22px, 7.5vw, 40px);
  }

  .speech-bubble {
    max-width: min(360px, 92vw);
    padding: 12px 16px;
    margin-bottom: 14px;
    align-self: center;
  }

  .speech-bubble p {
    font-size: clamp(13px, 3.6vw, 17px);
  }

  .game-dialog--speech,
  .game-dialog--path {
    max-width: min(300px, 88vw);
    width: min(300px, 88vw);
  }

  .game-dialog__text {
    font-size: clamp(12px, 3.2vw, 14px);
    padding: 10px 14px 12px;
  }

  .btn-play {
    padding: 12px 32px;
    font-size: clamp(16px, 4.2vw, 20px);
    align-self: center;
  }

  .map-panel {
    padding: 8px 14px;
    border-radius: 16px;
    max-width: calc(100vw - 24px);
  }

  .map-panel-top {
    top: max(6px, env(safe-area-inset-top, 6px));
    margin-top: 0;
  }

  .map-panel-bottom {
    bottom: 72px;
    min-width: unset;
    width: calc(100vw - 32px);
    max-width: 360px;
    font-size: clamp(12px, 3.2vw, 15px);
    padding: 8px 14px;
  }

  .map-title {
    font-size: clamp(16px, 4.5vw, 22px);
  }

  .map-subtitle {
    font-size: clamp(11px, 2.8vw, 13px);
    margin-top: 2px;
  }

  .map-actions {
    bottom: max(10px, env(safe-area-inset-bottom, 10px));
    gap: 10px;
    width: calc(100vw - 24px);
    max-width: 360px;
    justify-content: center;
  }

  .map-actions .btn-play {
    padding: 10px 24px;
    font-size: clamp(14px, 3.8vw, 18px);
  }

  .map-actions .btn-secondary {
    padding: 10px 18px;
    font-size: clamp(13px, 3.5vw, 16px);
  }

  .map-level-desc {
    font-size: clamp(12px, 3.2vw, 14px);
    min-height: 3.2em;
  }

  .menu-buttons {
    gap: 10px;
  }

  .btn-exit {
    padding: 10px 24px;
    font-size: clamp(13px, 3.5vw, 16px);
  }

  .map-label-inner {
    font-size: 10px;
    padding: 3px 7px;
    border-radius: 10px;
  }

  .map-label-num {
    font-size: 12px;
  }

  .map-label-rings {
    font-size: 9px;
  }

  .map-label-path {
    font-size: 8px;
  }
}

@media (orientation: portrait) and (max-width: 768px) {
  .menu-content {
    justify-content: flex-end;
    padding-bottom: max(16px, env(safe-area-inset-bottom, 16px));
  }

  .menu-content {
    background: linear-gradient(
      180deg,
      transparent 0%,
      transparent 35%,
      rgba(135, 206, 235, 0.15) 55%,
      rgba(255, 255, 255, 0.55) 100%
    );
  }
}

@media (min-width: 480px) {
  .roblox-joystick {
    width: 80px;
    height: 80px;
  }

  .joystick-stick {
    width: 32px;
    height: 32px;
  }

  .roblox-jump-btn {
    width: 80px;
    height: 80px;
  }

  .roblox-jump-btn .jump-icon {
    width: 40px;
    height: 40px;
  }
}

html.needs-landscape #game-container,
html.needs-landscape #ui,
html.needs-landscape #touch-controls {
  visibility: hidden;
}

.orientation-overlay {
  position: fixed;
  inset: 0;
  z-index: 20000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(165deg, #1a1a2e 0%, #2d3a4a 55%, #1a2530 100%);
  color: #e8dcc8;
  text-align: center;
  padding: max(24px, env(safe-area-inset-top, 24px)) max(24px, env(safe-area-inset-right, 24px)) max(24px, env(safe-area-inset-bottom, 24px)) max(24px, env(safe-area-inset-left, 24px));
}

.orientation-overlay.hidden {
  display: none;
}

.orientation-content {
  max-width: 320px;
}

.orientation-phone {
  width: 52px;
  height: 88px;
  border: 3px solid rgba(232, 220, 200, 0.45);
  border-radius: 10px;
  margin: 0 auto 28px;
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.25);
  animation: orientation-rotate 2.2s ease-in-out infinite;
}

.orientation-phone::after {
  content: '';
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(232, 220, 200, 0.35);
  margin: 8px auto 0;
}

@keyframes orientation-rotate {
  0%, 25% { transform: rotate(0deg); }
  45%, 70% { transform: rotate(90deg); }
  100% { transform: rotate(90deg); }
}

.orientation-title {
  font-size: clamp(20px, 5vw, 28px);
  font-weight: 800;
  margin-bottom: 10px;
}

.orientation-subtitle {
  font-size: clamp(14px, 3.5vw, 18px);
  font-weight: 600;
  opacity: 0.85;
  line-height: 1.4;
}

html.needs-landscape #orientation-screen {
  display: flex;
}
