:root {
  --mario-red: #e52521;
  --mario-red-dark: #9e110e;
  --mario-blue: #049cd8;
  --mario-yellow: #fbd000;
  --mario-gold-dark: #b86e00;
  --mario-green: #43b047;
  --mario-green-dark: #196b1d;
  --ink: #241911;
  --success: #22a847;
  --danger: #e52521;
}

* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #120d0a;
  font-family: "DM Sans", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.display-title {
  font-family: "Work Sans", system-ui, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* =====================================================
   FULL-VIEWPORT 2D GAME CABINET (AUTO-LANDSCAPE MOBILE)
   ===================================================== */
.game-viewport {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--vw-px, 100vw);
  height: var(--vh-px, 100vh);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateZ(0);
}

body.force-landscape-rotate .game-viewport {
  top: 0;
  left: var(--vw-px, 100vw);
  width: var(--vh-px, 100vh);
  height: var(--vw-px, 100vw);
  transform-origin: 0 0;
  transform: rotate(90deg);
}

#mario-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
  cursor: pointer;
}

/* =====================================================
   TRANSLUCENT TOP-RIGHT COIN COUNTER & DASHBOARD TOGGLE
   ===================================================== */
.top-right-hud-cluster {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 32;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.top-right-coin-hud {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.28);
  border: 1.5px solid rgba(251, 208, 0, 0.42);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.75);
}

.top-right-dashboard-btn {
  pointer-events: auto;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.32);
  border: 1.5px solid rgba(251, 208, 0, 0.48);
  color: #fbd000;
  font-size: 1rem;
  font-weight: 900;
  display: grid;
  place-items: center;
  cursor: pointer;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
  transition: background 0.18s ease, transform 0.14s ease, border-color 0.18s ease;
}

.top-right-dashboard-btn:hover {
  background: rgba(28, 20, 15, 0.78);
  border-color: #fbd000;
  transform: scale(1.06);
}

/* =====================================================
   TOP FLOATING ARCADE HUD (HIDDEN BY DEFAULT, TOGGLEABLE)
   ===================================================== */
.arcade-hud {
  position: relative;
  z-index: 25;
  margin: 10px 14px 0 14px;
  background: linear-gradient(180deg, rgba(28, 20, 15, 0.94) 0%, rgba(48, 34, 24, 0.94) 100%);
  border: 3px solid #fbd000;
  border-radius: 18px;
  padding: 8px 14px;
  color: #ffffff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45), inset 0 2px 0 rgba(255, 255, 255, 0.18);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  backdrop-filter: blur(6px);
}

.arcade-hud.hidden {
  display: none !important;
}

.hud-player-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: 1.5px solid rgba(251, 208, 0, 0.55);
  border-radius: 12px;
  padding: 4px 10px;
}

.mario-emblem {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #e52521;
  border: 2px solid #ffffff;
  color: #ffffff;
  font-family: "Work Sans", sans-serif;
  font-weight: 900;
  font-size: 0.9rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.hud-name-input {
  background: transparent;
  border: none;
  color: #ffffff;
  font-family: "Work Sans", sans-serif;
  font-weight: 800;
  font-size: 0.88rem;
  width: 145px;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}

.hud-name-input::placeholder {
  color: rgba(255, 243, 176, 0.65);
}

/* World Pills inside HUD */
.world-nav-pills {
  display: flex;
  align-items: center;
  gap: 5px;
}

.world-pill {
  padding: 5px 11px;
  border-radius: 10px;
  font-family: "Work Sans", sans-serif;
  font-weight: 900;
  font-size: 0.78rem;
  border: 2px solid #8c5600;
  border-bottom-width: 4px;
  background: linear-gradient(180deg, #ffe066 0%, #f5b800 100%);
  color: #3b2100;
  cursor: pointer;
  transition: transform 0.12s ease;
}

.world-pill.current {
  background: linear-gradient(180deg, #ff4b47 0%, #c91915 100%);
  color: #ffffff;
  border-color: #6e0806;
  box-shadow: 0 0 0 2px #fbd000;
}

.world-pill.passed:not(.current) {
  background: linear-gradient(180deg, #5ce662 0%, #2ca831 100%);
  color: #073309;
  border-color: #125214;
}

.world-pill:disabled {
  opacity: 0.45;
  filter: grayscale(0.5);
  cursor: not-allowed;
}

.world-pill:not(:disabled):hover {
  transform: translateY(-2px);
}

/* Spinning Gold Coin Icon */
.coin-icon-spin {
  display: inline-block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff9b0, #fbd000 55%, #c87c00 100%);
  border: 2px solid #ffffff;
  box-shadow: 0 0 8px #fbd000;
  position: relative;
  animation: coin-gleam 1.3s ease-in-out infinite;
  vertical-align: middle;
  flex-shrink: 0;
}

.coin-icon-spin::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 4px;
  bottom: 4px;
  width: 3px;
  transform: translateX(-50%);
  background: #9c5a00;
  border-radius: 2px;
}

@keyframes coin-gleam {
  0%, 100% { transform: scaleX(1); }
  50% { transform: scaleX(0.6); }
}

.coin-counter-bump {
  animation: hud-coin-bump 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes hud-coin-bump {
  0% { transform: scale(1); }
  45% { transform: scale(1.38); color: #fbd000; }
  100% { transform: scale(1); }
}

.hud-util-btn {
  padding: 5px 10px;
  border-radius: 10px;
  font-weight: 800;
  font-size: 0.75rem;
  border: 2px solid rgba(255,255,255,0.28);
  background: rgba(255,255,255,0.12);
  color: #fff3b0;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease;
}

.hud-util-btn:hover {
  background: rgba(251, 208, 0, 0.25);
  transform: translateY(-1px);
}

/* =====================================================
   IN-GAME BANNER / STATUS TOAST (HIDDEN BY DEFAULT, TOGGLEABLE)
   ===================================================== */
.ingame-toast {
  position: relative;
  z-index: 20;
  margin: 8px auto 0 auto;
  max-width: 780px;
  background: rgba(28, 20, 15, 0.85);
  border: 2px solid #fbd000;
  border-radius: 999px;
  padding: 6px 20px;
  color: #fff8dc;
  font-weight: 800;
  font-size: 0.84rem;
  text-align: center;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
  backdrop-filter: blur(4px);
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.ingame-toast.hidden {
  display: none !important;
}

/* =====================================================
   IN-GAME FLOATING JIGSAW PUZZLE HUD (DUNIA 1-1 TO 1-4)
   Appears directly in the sky when Mario hits a [?] Block!
   ===================================================== */
.ingame-puzzle-hud {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 35;
  width: min(94vw, 720px);
  background: linear-gradient(180deg, rgba(255, 253, 245, 0.97) 0%, rgba(255, 245, 214, 0.97) 100%);
  border: 4px solid #e09c00;
  border-bottom-width: 7px;
  border-bottom-color: #8c5600;
  border-radius: 26px;
  padding: 16px 20px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.5), 0 0 0 3px #ffffff inset;
  animation: pop-from-block 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes pop-from-block {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(25px) scale(0.86);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

.jigsaw-assembly {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  align-items: stretch;
  gap: 14px;
  position: relative;
  min-height: 82px;
  transition: gap 0.26s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.jigsaw-assembly.snapped {
  gap: 0px;
}

.piece-d {
  position: relative;
  background: linear-gradient(135deg, #ffe066 0%, #f5b800 100%);
  border: 3px solid #9c5a00;
  border-radius: 16px;
  padding: 12px 24px 12px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  z-index: 1;
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.6);
}

.piece-d::after {
  content: "";
  position: absolute;
  right: -3px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 28px;
  background: #fff9e6;
  border-top-left-radius: 16px;
  border-bottom-left-radius: 16px;
  border-left: 3px solid #9c5a00;
  border-top: 3px solid #9c5a00;
  border-bottom: 3px solid #9c5a00;
  z-index: 2;
  transition: opacity 0.2s ease;
}

.jigsaw-assembly.snapped .piece-d {
  border-top-right-radius: 4px;
  border-bottom-right-radius: 4px;
  border-right-width: 1px;
}

.jigsaw-assembly.snapped .piece-d::after {
  opacity: 0;
}

.piece-t-slot {
  position: relative;
  border: 3px dashed #b57c1e;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.85);
  padding: 12px 14px 12px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  z-index: 3;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.piece-t-slot::before {
  content: "";
  position: absolute;
  left: -15px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 26px;
  border-top-left-radius: 14px;
  border-bottom-left-radius: 14px;
  background: #fffdf7;
  border-left: 3px dashed #b57c1e;
  border-top: 3px dashed #b57c1e;
  border-bottom: 3px dashed #b57c1e;
}

.piece-t-slot.filled {
  border-style: solid;
}

.jigsaw-assembly.snapped .piece-t-slot.filled {
  border-top-left-radius: 4px;
  border-bottom-left-radius: 4px;
}

.piece-t-slot.filled::before {
  border-style: solid;
  border-color: inherit;
  background: inherit;
  left: -15px;
}

.t-puzzle-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px 8px 18px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 0.85rem;
  cursor: pointer;
  border: 2px solid rgba(0, 0, 0, 0.2);
  border-bottom-width: 4px;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.12);
  transition: transform 0.14s ease, box-shadow 0.14s ease;
  margin-left: 6px;
}

.t-puzzle-chip::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 16px;
  background: inherit;
  border-radius: 50%;
  border-left: 2px solid rgba(0, 0, 0, 0.25);
  border-top: 2px solid rgba(0, 0, 0, 0.18);
  border-bottom: 2px solid rgba(0, 0, 0, 0.18);
}

.t-puzzle-chip:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.2);
}

/* =====================================================
   ON-SCREEN ARCADE TOUCH CONTROLS (BOTTOM CORNERS)
   ===================================================== */
.onscreen-controls {
  position: fixed;
  bottom: 16px;
  left: 18px;
  right: 18px;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.dpad-group, .action-group {
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

.arcade-ctrl-btn {
  background: linear-gradient(180deg, rgba(251, 208, 0, 0.92) 0%, rgba(224, 156, 0, 0.92) 100%);
  color: #3b2100;
  border: 2px solid #fff3b0;
  border-bottom-width: 4px;
  border-bottom-color: #7c4800;
  border-radius: 12px;
  padding: 7px 14px;
  font-family: "Work Sans", sans-serif;
  font-weight: 900;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.3);
  transition: transform 0.08s ease;
}

.arcade-ctrl-btn:active {
  transform: translateY(2px);
  border-bottom-width: 2px;
}

.arcade-ctrl-btn.jump {
  background: linear-gradient(180deg, rgba(229, 37, 33, 0.95) 0%, rgba(179, 18, 15, 0.95) 100%);
  color: #ffffff;
  border-color: #ff9e9c;
  border-bottom-color: #6b0806;
  padding: 8px 16px;
}

/* =====================================================
   START SCREEN FORM CARD (NAMA PEMAIN + BUTANG KEMAS)
   ===================================================== */
.start-form-card {
  background: #fff8dc;
  border: 2px solid #e6c687;
  border-radius: 18px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.start-name-input {
  width: 100%;
  border-radius: 12px;
  border: 2px solid #c88a28;
  background: #ffffff;
  padding: 10px 14px;
  font-size: 0.92rem;
  font-weight: 800;
  color: #241911;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.start-name-input:focus {
  border-color: #e52521;
  box-shadow: 0 0 0 3px rgba(229, 37, 33, 0.15);
}

.start-form-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.start-bgm-btn,
.start-play-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  white-space: nowrap;
}

.start-bgm-btn {
  min-width: 150px;
  padding: 9px 16px;
  font-size: 0.74rem;
  background: #1e293b;
  color: #fde047;
  border: none;
  border-bottom: 3px solid #0f172a;
}

.start-bgm-btn:hover {
  background: #334155;
}

.start-bgm-btn.is-muted {
  background: #7f1d1d;
  color: #ffffff;
  border-bottom-color: #450a0a;
}

.start-bgm-btn.is-muted:hover {
  background: #991b1b;
}

.start-play-btn {
  min-width: 190px;
  padding: 10px 22px;
  font-size: 0.88rem;
  background: #43b047;
  color: #ffffff;
  border: none;
  border-bottom: 4px solid #1b5e20;
  box-shadow: 0 4px 10px rgba(27, 94, 32, 0.25);
}

.start-play-btn:hover {
  background: #2e8f32;
}

.start-bgm-btn:active,
.start-play-btn:active {
  transform: translateY(2px);
}

@media (max-width: 480px) {
  .start-bgm-btn,
  .start-play-btn {
    flex: 1 1 100%;
  }
}

/* =====================================================
   FLOATING GOLD COIN POPUP ANIMATION (+1 SYILING EMAS)
   ===================================================== */
.floating-coin-reward {
  position: fixed;
  z-index: 99;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #fff59d 0%, #fbd000 60%, #e09c00 100%);
  color: #3b2100;
  border: 3px solid #ffffff;
  border-radius: 999px;
  padding: 8px 18px;
  font-family: "Work Sans", sans-serif;
  font-weight: 900;
  font-size: 1.05rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  animation: coin-float-up 1.15s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes coin-float-up {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(0.5); }
  25% { opacity: 1; transform: translate(-50%, -28px) scale(1.15); }
  80% { opacity: 1; transform: translate(-50%, -65px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -95px) scale(0.85); }
}

/* =====================================================
   MODALS: GUIDE [?] MODAL & VICTORY CERTIFICATE OVERLAY
   ===================================================== */
.fullscreen-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(15, 10, 6, 0.72);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}

.shake {
  animation: shake 0.4s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-9px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(5px); }
}

/* Certificate Styling */
.certificate {
  background: linear-gradient(145deg, #fffdf6, #fff7df);
  border: 10px double #c89b3c;
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.3);
  position: relative;
}

.certificate-rule {
  height: 2px;
  background: linear-gradient(90deg, transparent, #c89b3c, transparent);
}

.certificate-value {
  color: #7a4b20;
}

@media print {
  body * {
    visibility: hidden !important;
  }
  #certificate,
  #certificate * {
    visibility: visible !important;
  }
  #certificate {
    position: fixed;
    inset: 0;
    width: 100%;
    height: auto;
    margin: 0;
    box-shadow: none;
    border: 10px double #c89b3c !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  @page {
    size: A4 landscape;
    margin: 10mm;
  }
}

body.printing-certificate #completion {
  display: flex !important;
}

/* =====================================================
   10-SECOND PREMIUM BLACK-STAGE SUPER MARIO INTRO
   ===================================================== */
.netflix-splash-overlay {
  position: fixed;
  inset: 0;
  z-index: 250;
  background: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  transition: opacity 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}

.netflix-splash-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.netflix-splash-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
}


/* =====================================================
   SKIP INTRO BUTTON & MOBILE AUTO-LANDSCAPE ADAPTATIONS
   ===================================================== */
.skip-intro-btn {
  position: absolute;
  bottom: 20px;
  right: 22px;
  z-index: 15;
  background: rgba(24, 24, 27, 0.85);
  color: #fbd000;
  border: 2px solid #fbd000;
  border-radius: 999px;
  padding: 8px 18px;
  font-family: "Work Sans", sans-serif;
  font-weight: 900;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  transition: transform 0.14s ease, background 0.14s ease;
}

.skip-intro-btn:hover,
.skip-intro-btn:active {
  background: #e52521;
  color: #ffffff;
  transform: scale(1.05);
}

.arcade-ctrl-btn {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.fullscreen-modal > div {
  max-height: 92% !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.ingame-puzzle-hud {
  max-height: calc(100% - 20px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

/* Padanan Kompak Automatik untuk Skrin Telefon Landskap */
body.mobile-landscape-ui .ingame-puzzle-hud {
  top: 6px;
  width: min(94%, 660px);
  padding: 8px 12px;
  border-radius: 18px;
  border-width: 3px;
  border-bottom-width: 5px;
  max-height: calc(100% - 12px);
}

body.mobile-landscape-ui .jigsaw-assembly {
  min-height: 50px;
  gap: 8px;
  margin-bottom: 6px !important;
}

body.mobile-landscape-ui .piece-d,
body.mobile-landscape-ui .piece-t-slot {
  padding: 6px 14px;
  border-radius: 12px;
}

body.mobile-landscape-ui #hud-term-d {
  font-size: 0.92rem !important;
}

body.mobile-landscape-ui .t-puzzle-chip {
  padding: 4px 9px 4px 13px;
  font-size: 0.72rem;
  border-radius: 9px;
}

body.mobile-landscape-ui .onscreen-controls {
  bottom: 10px;
  left: 14px;
  right: 14px;
}

body.mobile-landscape-ui .arcade-ctrl-btn {
  padding: 10px 16px;
  font-size: 0.82rem;
  border-radius: 14px;
}

body.mobile-landscape-ui .arcade-ctrl-btn.jump {
  padding: 11px 18px;
}

body.mobile-landscape-ui #start-screen-modal > div {
  padding: 10px 14px !important;
  border-radius: 20px !important;
}

body.mobile-landscape-ui #start-screen-title {
  font-size: 1.05rem !important;
  margin-top: 4px !important;
}

body.mobile-landscape-ui #start-screen-modal .aspect-video {
  max-height: 125px;
  margin-top: 6px !important;
}

body.mobile-landscape-ui .start-form-card {
  margin-top: 8px !important;
  padding: 8px 12px !important;
  gap: 8px !important;
}

body.mobile-landscape-ui .start-name-input {
  padding: 6px 10px !important;
  font-size: 0.84rem !important;
}

body.mobile-landscape-ui .start-bgm-btn,
body.mobile-landscape-ui .start-play-btn {
  padding: 7px 14px !important;
  font-size: 0.76rem !important;
  min-width: 130px !important;
  flex: 0 1 auto !important;
}

body.mobile-landscape-ui .arcade-hud {
  margin: 6px 10px 0 10px;
  padding: 6px 10px;
  gap: 6px;
  max-height: calc(100% - 14px);
  overflow-y: auto;
}

body.mobile-landscape-ui .ingame-toast {
  margin-top: 4px;
  padding: 3px 12px;
  font-size: 0.72rem;
  max-width: 78%;
}


/* =====================================================
   KEPUTUSAN HAKIM UTAMA: SKROL SENTUH, SAFE-AREA, D-PAD ERGONOMIK & AUDIO UI
   ===================================================== */
.top-right-hud-cluster {
  top: max(10px, env(safe-area-inset-top, 10px)) !important;
  right: max(12px, env(safe-area-inset-right, 12px)) !important;
  z-index: 32;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

/* Sorokkan sepenuhnya HUD Syiling Terapung kanan atas apabila Dashboard atau HUD Kuiz dibuka supaya TIADA pertindihan dengan Mod Guru & butang Pilih Dunia! */
body.dashboard-open .top-right-hud-cluster,
body.puzzle-hud-open .top-right-hud-cluster {
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

body.mobile-landscape-ui .top-right-coin-hud {
  padding: 4px 10px !important;
  gap: 5px !important;
}

body.mobile-landscape-ui #coin-count-text {
  font-size: 0.75rem !important;
}

body.mobile-landscape-ui .top-right-dashboard-btn {
  width: 32px !important;
  height: 32px !important;
  font-size: 0.88rem !important;
}

.arcade-hud {
  z-index: 60 !important;
  position: relative;
}

.world-pill {
  min-height: 32px;
  padding: 5px 12px !important;
  font-size: 0.8rem !important;
  pointer-events: auto !important;
}

body.teacher-mode-active .world-pill:not(.current) {
  border-color: #fde047 !important;
  box-shadow: 0 0 8px rgba(251, 208, 0, 0.55);
}

.top-right-dashboard-btn.is-muted {
  background: rgba(185, 28, 28, 0.85) !important;
  border-color: #fca5a5 !important;
  color: #ffffff !important;
}

/* Baiki .fullscreen-modal & .ingame-puzzle-hud supaya boleh diskrol pada semua orientasi (termasuk rotate 90deg) */
.fullscreen-modal {
  position: absolute !important;
  inset: 0 !important;
  align-items: flex-start !important;
  justify-content: center !important;
  padding: 12px !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch !important;
  overscroll-behavior: contain !important;
  touch-action: pan-x pan-y !important;
}

.fullscreen-modal > div {
  margin: auto 0 !important;
  max-height: none !important;
  overflow: visible !important;
  touch-action: pan-x pan-y !important;
}

.ingame-puzzle-hud,
.arcade-hud {
  max-height: calc(100% - 16px) !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch !important;
  overscroll-behavior: contain !important;
  touch-action: pan-x pan-y !important;
}

.fullscreen-modal *,
.ingame-puzzle-hud *,
.arcade-hud * {
  touch-action: pan-x pan-y;
}

/* Ergonomik Kawalan Sentuh Bawah (Thumb-Slide D-Pad, Safe-Area, Smart Action & Auto-Hide) */
.onscreen-controls {
  position: absolute !important;
  bottom: max(12px, env(safe-area-inset-bottom, 12px)) !important;
  left: max(18px, env(safe-area-inset-left, 18px)) !important;
  right: max(18px, env(safe-area-inset-right, 18px)) !important;
  z-index: 30;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

body.puzzle-hud-open .onscreen-controls,
body.world-1-5-active .onscreen-controls {
  opacity: 0 !important;
  pointer-events: none !important;
  transform: translateY(24px);
}

.dpad-group, .action-group {
  gap: 10px !important;
  padding: 5px !important;
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.26);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.arcade-ctrl-btn {
  min-width: 84px;
  min-height: 48px;
  padding: 10px 16px !important;
  font-size: 0.84rem !important;
  border-radius: 14px !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: none !important;
  user-select: none !important;
  -webkit-user-select: none !important;
}

.arcade-ctrl-btn:active,
.arcade-ctrl-btn.is-pressed {
  transform: translateY(3px) scale(0.96) !important;
  border-bottom-width: 2px !important;
  filter: brightness(1.12);
}

.arcade-ctrl-btn.jump {
  min-width: 104px;
  min-height: 50px;
  border-radius: 999px !important;
}

.arcade-ctrl-btn.smart-action {
  min-height: 48px;
  background: linear-gradient(180deg, #43b047 0%, #1b6d1f 100%) !important;
  color: #ffffff !important;
  border-color: #8ce99a !important;
  border-bottom-color: #0d3b10 !important;
  border-radius: 999px !important;
  box-shadow: 0 0 14px rgba(67, 176, 71, 0.55);
}
