 

  #run_rescue_boy_game {
    display: block;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: #07070f;
  }
  #run_rescue_boy_ui {color:#fff;
    position: absolute;
    top: 0; left: 0; right: 0;
    pointer-events: none;
    z-index: 10;
  }
  #run_rescue_boy_score {
    position: absolute;
    top: 10px; left: 50%;
    transform: translateX(-50%);
    font-size: clamp(24px, 5.5vw, 34px);
    font-weight: 800;
    letter-spacing: 1px;
    text-shadow: 0 0 14px #4af, 0 2px 6px #000;
    white-space: nowrap;
  }
  #run_rescue_boy_high {
    position: absolute;
    top: 10px; right: 14px;
    font-size: clamp(15px, 3.6vw, 20px);
    opacity: 0.85;
    font-weight: 700;
    text-align: right;
  }
  /* 시간(s) — BEST 바로 아래 */
  #run_rescue_boy_time {
    position: absolute;
    top: 32px; right: 14px;
    font-size: clamp(15px, 3.6vw, 20px);
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #a5b4fc;
    text-shadow: 0 0 10px rgba(99,102,241,0.45), 0 2px 4px #000;
    white-space: nowrap;
    text-align: right;
  }
  #run_rescue_boy_dist {
    position: absolute;
    top: 44px; left: 50%;
    transform: translateX(-50%);
    font-size: clamp(15px, 3.5vw, 18px);
    opacity: 0.85;
    letter-spacing: 0.5px;
    font-weight: 700;
  }
  #run_rescue_boy_power_wrap {
    position: absolute;
    top: 52px; left: 14px;
    width: min(160px, 32vw);
    height: 16px;
    background: rgba(20,20,40,0.7);
    border: 1px solid rgba(100,140,200,0.5);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 0 8px rgba(0,0,0,0.4);
  }
  #run_rescue_boy_power_bar {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #e53e3e, #f6ad55, #48bb78);
    border-radius: 7px;
    transition: width 0.15s ease-out;
  }
  #run_rescue_boy_power_label {
    position: absolute;
    top: 50px; left: 14px;
    font-size: clamp(13px, 3.2vw, 16px);
    font-weight: 700;
    color: #cde;
    text-shadow: 0 1px 2px #000;
    pointer-events: none;
    transform: translateY(-100%);
    margin-top: -2px;
  }
  #run_rescue_boy_overlay {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(10,20,40,0.9) 0%, rgba(5,5,15,0.95) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20;
    pointer-events: auto;
    transition: opacity 0.3s;
  }
  #run_rescue_boy_overlay.hidden {
    opacity: 0;
    pointer-events: none !important;
    visibility: hidden;
  }
  #run_rescue_boy_overlay.hidden button,
  #run_rescue_boy_overlay.hidden * {
    pointer-events: none !important;
  }
  #gametitle {
    font-size: clamp(32px, 8vw, 56px);
    font-weight: 900;
    margin-bottom: 6px;
    background: linear-gradient(90deg, #5cf, #a8f, #fc6);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 8px rgba(80,160,255,0.4));
  }
  .sub {
    font-size: clamp(13px, 3.2vw, 16px);
    color: #fff;
    opacity: 1;
    margin-bottom: 26px;
    letter-spacing: 1px;
  }
  #run_rescue_boy_root button {
    pointer-events: auto;
    background: linear-gradient(135deg, #1a8a4a, #2ac);
    border: none;
    color: #fff;
    font-size: clamp(17px, 4vw, 22px);
    font-weight: 800;
    padding: 14px 48px;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 6px 24px rgba(40,180,255,0.4), inset 0 1px 0 rgba(255,255,255,0.2);
    transition: transform 0.12s, box-shadow 0.12s;
    letter-spacing: 1px;
  }
  #run_rescue_boy_root button:hover { transform: scale(1.06); box-shadow: 0 8px 28px rgba(40,180,255,0.55); }
  #run_rescue_boy_root button:active { transform: scale(0.96); }
  .hint {
    margin-top: 28px;
    font-size: clamp(12px, 2.8vw, 14px);
    color: #fff;
    opacity: 1;
    text-align: center;
    line-height: 1.6;
  }
  #run_rescue_boy_gameover_msg {
    font-size: clamp(15px, 3.5vw, 18px);
    margin-bottom: 10px;
    color: #faa;
    font-weight: 600;
  }
  #run_rescue_boy_clear_overlay {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(10,30,60,0.55) 0%, rgba(5,5,20,0.85) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 25;
    pointer-events: auto;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s;
  }
  #run_rescue_boy_clear_overlay.active {
    opacity: 1;
    visibility: visible;
  }
  #run_rescue_boy_clear_title {
    font-size: clamp(36px, 10vw, 72px);
    font-weight: 900;
    letter-spacing: 4px;
    background: linear-gradient(90deg, #fde68a, #fbbf24, #f472b6, #a78bfa, #60a5fa, #fde68a);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: clearShimmer 2.5s linear infinite, clearPop 0.9s ease-out;
    filter: drop-shadow(0 4px 20px rgba(251,191,36,0.5));
    margin-bottom: 12px;
    text-align: center;
  }
  #run_rescue_boy_clear_sub {
    font-size: clamp(18px, 4.5vw, 32px);
    font-weight: 800;
    letter-spacing: 3px;
    color: #fef3c7;
    text-shadow: 0 0 18px rgba(253,224,71,0.7), 0 2px 8px #000;
    animation: clearSubIn 1.2s ease-out 0.3s both, clearPulse 1.6s ease-in-out 1.2s infinite;
    margin-bottom: 28px;
    text-align: center;
  }
  @keyframes clearShimmer {
    0% { background-position: 0% center; }
    100% { background-position: 200% center; }
  }
  @keyframes clearPop {
    0% { transform: scale(0.4); opacity: 0; }
    60% { transform: scale(1.12); opacity: 1; }
    100% { transform: scale(1); }
  }
  @keyframes clearSubIn {
    0% { transform: translateY(24px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
  }
  @keyframes clearPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.06); opacity: 0.88; }
  }
  #run_rescue_boy_clear_overlay button {
    margin-top: 8px;
  }

  /* ===== Mobile / touch controls ===== */
  #run_rescue_boy_touch_controls {
    position: absolute;
    inset: 0;
    z-index: 15;
    pointer-events: none;
    display: none;
  }
  #run_rescue_boy_touch_controls.visible {
    display: block;
  }
  .touch-zone {
    position: absolute;
    pointer-events: auto;
    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
  }
  #run_rescue_boy_pad_left {
    left: max(6px, env(safe-area-inset-left));
    bottom: max(10px, env(safe-area-inset-bottom));
    width: min(186px, 46vw);
    height: min(186px, 46vw);
  }
  #run_rescue_boy_pad_right {
    right: max(8px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
    width: min(100px, 24vw);
    height: min(100px, 24vw);
  }
  .dpad {
    position: relative;
    width: 100%;
    height: 100%;
  }
  .dpad-btn {
    position: absolute;
    width: 30%;
    height: 30%;
    border-radius: 12px;
    background: rgba(30, 50, 90, 0.45);
    border: 2px solid rgba(120, 170, 255, 0.45);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(200, 220, 255, 0.9);
    font-size: clamp(12px, 3.5vw, 18px);
    font-weight: 800;
  }
  .dpad-btn.active {
    background: rgba(60, 120, 220, 0.7);
    border-color: rgba(160, 210, 255, 0.9);
    transform: scale(0.96);
  }
  .dpad-btn.up { top: 2%; left: 35%; }
  .dpad-btn.down { bottom: 2%; left: 35%; }
  .dpad-btn.left { left: 2%; top: 35%; }
  .dpad-btn.right { right: 2%; top: 35%; }
  .dpad-btn.up-left { top: 2%; left: 2%; }
  .dpad-btn.up-right { top: 2%; right: 2%; }
  .dpad-btn.down-left { bottom: 2%; left: 2%; }
  .dpad-btn.down-right { bottom: 2%; right: 2%; }
  #run_rescue_boy_btn_jump {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(30, 140, 90, 0.5);
    border: 3px solid rgba(100, 230, 180, 0.55);
    box-shadow: 0 4px 18px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.15);
    color: #e8fff4;
    font-size: clamp(14px, 3.8vw, 18px);
    font-weight: 900;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  #run_rescue_boy_btn_jump.active {
    background: rgba(40, 200, 120, 0.75);
    border-color: #9ff;
    transform: scale(0.94);
  }
  @media (pointer: fine) and (min-width: 900px) {
    /* Prefer hide on large desktop with mouse; still allow if forced visible */
    #run_rescue_boy_touch_controls:not(.force-show) { display: none !important; }
  }

  /* Narrow mobile: keep top UI from overlapping */
  @media (max-width: 420px) {
    #run_rescue_boy_score {
      font-size: clamp(20px, 5.2vw, 28px);
      top: 8px;
    }
    #run_rescue_boy_high {
      top: 8px;
      right: 8px;
      font-size: clamp(13px, 3.4vw, 16px);
      max-width: 30vw;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    #run_rescue_boy_time {
      top: 28px;
      right: 8px;
      left: auto;
      transform: none;
      font-size: clamp(13px, 3.4vw, 16px);
    }
    #run_rescue_boy_dist {
      top: 40px;
      font-size: clamp(13px, 3.4vw, 16px);
    }
    #run_rescue_boy_power_wrap {
      top: 48px;
      left: 8px;
      width: min(110px, 28vw); /* shorter so it doesn't overlap m */
      height: 14px;
    }
    #run_rescue_boy_power_label {
      top: 46px;
      left: 8px;
      font-size: clamp(12px, 3vw, 14px);
    }
    #run_rescue_boy_pad_left {
      width: min(170px, 48vw);
      height: min(170px, 48vw);
    }
    #run_rescue_boy_pad_right {
      width: min(88px, 22vw);
      height: min(88px, 22vw);
    }
  }

  /* ===== Memory mini-game overlay ===== */
  #run_rescue_boy_mini_overlay {
    position: absolute;
    inset: 0;
    background: rgba(5, 8, 20, 0.72);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 30;
    pointer-events: none;
    opacity: 0;
    transform: scale(0.82);
    transition: opacity 0.45s ease, transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  }
  #run_rescue_boy_mini_overlay.active {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
  }
  #run_rescue_boy_mini_overlay.closing {
    opacity: 0;
    transform: scale(0.82);
    pointer-events: none;
  }
  #run_rescue_boy_mini_title {
    font-size: clamp(18px, 4vw, 24px);
    font-weight: 800;
    margin-bottom: 6px;
    color: #f6e05e;
    text-shadow: 0 0 12px rgba(246,224,94,0.5);
  }
  #run_rescue_boy_mini_timer {
    font-size: clamp(16px, 3.5vw, 20px);
    font-weight: 700;
    margin-bottom: 14px;
    color: #90cdf4;
  }
  #run_rescue_boy_mini_timer.warn { color: #fc8181; animation: pulse 0.5s infinite; }
  @keyframes pulse { 50% { opacity: 0.5; } }
  #run_rescue_boy_card_grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    max-width: min(360px, 90vw);
    width: 90vw;
  }
  #run_rescue_boy_card_grid.size-3 {
    grid-template-columns: repeat(3, 1fr);
    max-width: min(300px, 80vw);
  }
  .card.blank {
    visibility: hidden;
    pointer-events: none;
  }
  .card {
    aspect-ratio: 1;
    border-radius: 10px;
    cursor: pointer;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.35s;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  .card.flipped { transform: rotateY(180deg); }
  .card.matched {
    opacity: 0.78;
    pointer-events: none;
    transform: none !important;
    cursor: default;
  }
  /* when matched, hide the ? back and show only the symbol face flat */
  .card.matched .card-back {
    display: none;
  }
  .card.matched .card-front {
    transform: none;
    backface-visibility: visible;
    opacity: 1;
    background: linear-gradient(145deg, #2d3748, #1a202c);
    border: 2px solid #68d391;
  }
  .card-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(29px, 7.8vw, 42px); /* 1.3x larger icons */
    font-weight: 800;
  }
  .card-back {
    background: linear-gradient(145deg, #2b6cb0, #1a365d);
    border: 2px solid #63b3ed;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  }
  .card-back::after { content: '?'; color: #bee3f8; }
  .card-front {
    background: linear-gradient(145deg, #2d3748, #1a202c);
    border: 2px solid #a0aec0;
    transform: rotateY(180deg);
  }
  #run_rescue_boy_mini_result {
    margin-top: 16px;
    font-size: 16px;
    font-weight: 700;
    min-height: 24px;
    color: #9ae6b4;
  }
  #run_rescue_boy_reward_anim {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: clamp(28px, 6vw, 42px);
    font-weight: 900;
    color: #f6e05e;
    text-shadow: 0 0 20px rgba(246,224,94,0.8);
    opacity: 0;
    pointer-events: none;
    z-index: 40;
    transition: opacity 0.2s, transform 0.2s;
  }
  #run_rescue_boy_reward_anim.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.15);
  }
