/* ==========================================================================
   DETEKTIF CERITA - PREMIUM STYLING & ANIMATION SYSTEM
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&family=Nunito:wght@600;700;800;900&family=Outfit:wght@500;600;700;800&display=swap');

:root {
  --font-game: 'Fredoka', 'Nunito', -apple-system, sans-serif;
  --font-title: 'Fredoka', 'Nunito', cursive, sans-serif;
  --font-main: 'Fredoka', 'Nunito', sans-serif;
  --font-ui: 'Fredoka', 'Nunito', sans-serif;
  
  --gold-primary: #f5b041;
  --gold-glow: #f39c12;
  --gold-light: #fef5e7;
  --wood-dark: #2c1810;
  --wood-warm: #4a2818;
  --wood-border: #8b5a2b;
  --parchment: #fdf6e2;
  
  --color-success: #2ecc71;
  --color-warning: #e67e22;
  --color-danger: #e74c3c;
  --color-info: #3498db;
  
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  box-sizing: border-box;
}

html, body {
  background: #090e17;
  background-image: 
    radial-gradient(circle at 50% 30%, rgba(30, 48, 80, 0.5) 0%, rgba(9, 14, 23, 0.95) 75%),
    radial-gradient(circle at 10% 90%, rgba(139, 90, 43, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 90% 90%, rgba(139, 90, 43, 0.15) 0%, transparent 40%);
  color: #fff;
  font-family: var(--font-main);
  overflow: hidden;
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  user-select: none;
  -webkit-user-select: none;
}

/* ==========================================================================
   AMBIENT BACKGROUND PARTICLES & VIGNETTE
   ========================================================================== */
#ambient-particles-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 1;
  opacity: 0.75;
}

.screen-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.8), inset 0 0 180px rgba(5, 10, 20, 0.6);
}

/* ==========================================================================
   CANVAS CONTAINER
   ========================================================================== */
#c2canvasdiv {
  position: absolute !important;
  z-index: 10;
  box-shadow: 
    0 15px 40px rgba(0, 0, 0, 0.6),
    0 0 0 2px rgba(245, 176, 65, 0.25),
    0 0 35px rgba(243, 156, 18, 0.15);
  border-radius: 6px;
  overflow: visible;
  transition: box-shadow 0.4s ease;
}

#c2canvas {
  border-radius: 6px;
  display: block;
}

/* ==========================================================================
   THEMATIC WOODEN HUD (RESPONSIVE & PROPORTIONAL ON ALL SCREENS)
   ========================================================================== */
/* Bottom Left Corner: Player Badge */
.game-hud-player {
  position: absolute;
  bottom: 16px;
  left: 18px;
  z-index: 90;
  pointer-events: auto;
  transition: all 0.3s var(--ease-spring);
  animation: fadeInUp 0.4s var(--ease-spring) both;
}

/* Bottom Right Corner: Papan Skor & Fullscreen Actions */
.game-hud-actions {
  position: absolute;
  bottom: 16px;
  right: 18px;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  transition: all 0.3s var(--ease-spring);
  animation: fadeInUp 0.4s var(--ease-spring) both;
}

/* On gameplay missions, scoreboard button is completely hidden as per user request */
.game-hud-actions.hud-no-scoreboard #hud-btn-lb {
  display: none !important;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Wooden Badge for Player Name (Desktop base) */
.hud-wood-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px 6px 8px;
  background: linear-gradient(180deg, #b86820 0%, #873e0e 50%, #562405 100%);
  border: 3px solid #ffcc66;
  border-radius: 999px;
  box-shadow: 
    0 4px 0 #331504,
    0 8px 18px rgba(0, 0, 0, 0.45),
    inset 0 2px 2px rgba(255, 255, 255, 0.4),
    inset 0 -2px 2px rgba(0, 0, 0, 0.3);
  font-family: var(--font-game);
  user-select: none;
  transition: all 0.25s var(--ease-spring);
}

.hud-badge-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: radial-gradient(circle, #fde047 30%, #d97706 100%);
  border: 2px solid #fffdf0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
  flex-shrink: 0;
  transition: all 0.25s ease;
}

.hud-badge-info {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.hud-badge-label {
  font-size: 11px;
  font-weight: 700;
  color: #fed7aa;
  letter-spacing: 0.8px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  transition: font-size 0.25s ease;
}

.hud-badge-name {
  font-size: 16px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 0.5px;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.85);
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.25s ease;
}

/* Wooden Buttons for Actions (Desktop base) */
.hud-wood-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 16px 6px 8px;
  background: linear-gradient(180deg, #c77428 0%, #944610 50%, #632a07 100%);
  border: 3px solid #ffcc66;
  border-radius: 999px;
  color: #fffaf0;
  font-family: var(--font-game);
  font-weight: 700;
  font-size: 15px;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.7);
  box-shadow: 
    0 4px 0 #331504,
    0 7px 16px rgba(0, 0, 0, 0.45),
    inset 0 2px 2px rgba(255, 255, 255, 0.4),
    inset 0 -2px 2px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: all 0.2s var(--ease-spring);
  white-space: nowrap;
}

.hud-wood-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-2px);
  box-shadow: 
    0 6px 0 #331504,
    0 10px 20px rgba(0, 0, 0, 0.5),
    inset 0 2px 2px rgba(255, 255, 255, 0.5);
}

.hud-wood-btn:active {
  transform: translateY(3px);
  box-shadow: 
    0 1px 0 #331504,
    0 3px 6px rgba(0, 0, 0, 0.4);
}

.hud-icon-bubble {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #4a1d06;
  border: 2px solid #f3a852;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
  transition: all 0.25s ease;
}

.hud-btn-text {
  font-family: var(--font-game);
  letter-spacing: 0.5px;
  transition: font-size 0.25s ease;
}

.hud-btn-fs {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  transition: all 0.25s ease;
}

.hud-fs-icon {
  font-size: 16px;
  transition: font-size 0.25s ease;
}

/* ==========================================================================
   RESPONSIVE HUD ADAPTATIONS (MOBILE HP & TABLETS)
   ========================================================================== */

/* 1. TABLET / MEDIUM SCREENS (width <= 1024px) */
@media (max-width: 1024px) {
  .game-hud-player {
    bottom: 12px;
    left: 14px;
  }
  .game-hud-actions {
    bottom: 12px;
    right: 14px;
    gap: 7px;
  }
  .hud-wood-badge {
    gap: 8px;
    padding: 5px 13px 5px 7px;
    border-width: 2.5px;
  }
  .hud-badge-avatar {
    width: 28px;
    height: 28px;
    font-size: 15px;
  }
  .hud-badge-label {
    font-size: 10px;
  }
  .hud-badge-name {
    font-size: 14px;
    max-width: 110px;
  }
  .hud-wood-btn {
    gap: 7px;
    padding: 5px 13px 5px 7px;
    border-width: 2.5px;
    font-size: 13.5px;
  }
  .hud-icon-bubble {
    width: 27px;
    height: 27px;
    font-size: 14px;
  }
  .hud-btn-fs {
    width: 35px;
    height: 35px;
  }
  .hud-fs-icon {
    font-size: 15px;
  }
}

/* ==========================================================================
   PORTRAIT / VERTICAL LETTERBOX MODE (ALWAYS ACTIVE WHEN CANVAS HAS LETTERBOX)
   KUNCI UTAMA:
   Pada layar HP vertikal atau layar dengan letterbox vertikal, canvas game hanya
   berukuran ~200px di tengah layar. Tombol dipindahkan ke RUANG KOSONG DI BAWAH
   CANVAS (top: calc(100% + 12px)) sehingga 100% TIDAK PERNAH MENUTUPI / MEMBLOCK
   elemen game di dalam board, teka-teki, maupun bidak kartu drop-zone.
   ========================================================================== */

/* 1. Explicit JS-managed Portrait & Letterbox classes (Maximum Specificity) */
#c2canvasdiv.hud-portrait .game-hud-player,
body.hud-portrait #c2canvasdiv .game-hud-player {
  bottom: auto !important;
  top: calc(100% + 12px) !important;
  left: 8px !important;
}

#c2canvasdiv.hud-portrait .game-hud-actions,
body.hud-portrait #c2canvasdiv .game-hud-actions {
  bottom: auto !important;
  top: calc(100% + 12px) !important;
  right: 8px !important;
  gap: 6px !important;
}

#c2canvasdiv.hud-portrait .hud-wood-badge,
body.hud-portrait #c2canvasdiv .hud-wood-badge {
  gap: 6px !important;
  padding: 4px 10px 4px 6px !important;
  border-width: 2px !important;
  box-shadow: 
    0 3px 0 #331504,
    0 5px 12px rgba(0, 0, 0, 0.4),
    inset 0 1px 2px rgba(255, 255, 255, 0.4) !important;
}

#c2canvasdiv.hud-portrait .hud-badge-avatar,
body.hud-portrait #c2canvasdiv .hud-badge-avatar {
  width: 25px !important;
  height: 25px !important;
  font-size: 13px !important;
  border-width: 1.5px !important;
}

#c2canvasdiv.hud-portrait .hud-badge-label,
body.hud-portrait #c2canvasdiv .hud-badge-label {
  font-size: 8px !important;
  letter-spacing: 0.5px !important;
}

#c2canvasdiv.hud-portrait .hud-badge-name,
body.hud-portrait #c2canvasdiv .hud-badge-name {
  font-size: 12px !important;
  max-width: 85px !important;
  letter-spacing: 0.3px !important;
}

#c2canvasdiv.hud-portrait .hud-wood-btn,
body.hud-portrait #c2canvasdiv .hud-wood-btn {
  gap: 6px !important;
  padding: 4px 10px 4px 6px !important;
  border-width: 2px !important;
  font-size: 12px !important;
  box-shadow: 
    0 3px 0 #331504,
    0 5px 12px rgba(0, 0, 0, 0.4),
    inset 0 1px 2px rgba(255, 255, 255, 0.4) !important;
}

#c2canvasdiv.hud-portrait .hud-icon-bubble,
body.hud-portrait #c2canvasdiv .hud-icon-bubble {
  width: 25px !important;
  height: 25px !important;
  font-size: 13px !important;
  border-width: 1.5px !important;
}

#c2canvasdiv.hud-portrait .hud-btn-fs,
body.hud-portrait #c2canvasdiv .hud-btn-fs {
  width: 33px !important;
  height: 33px !important;
  border-width: 2px !important;
}

#c2canvasdiv.hud-portrait .hud-fs-icon,
body.hud-portrait #c2canvasdiv .hud-fs-icon {
  font-size: 13px !important;
}

/* 2. Pure CSS Media Queries for Portrait (Fallback & Immediate Render) */
@media (orientation: portrait), (max-aspect-ratio: 1/1), (max-width: 600px) and (max-aspect-ratio: 4/3) {
  .game-hud-player {
    bottom: auto !important;
    top: calc(100% + 12px) !important;
    left: 8px !important;
  }

  .game-hud-actions {
    bottom: auto !important;
    top: calc(100% + 12px) !important;
    right: 8px !important;
    gap: 6px !important;
  }

  .hud-wood-badge {
    gap: 6px !important;
    padding: 4px 10px 4px 6px !important;
    border-width: 2px !important;
    box-shadow: 
      0 3px 0 #331504,
      0 5px 12px rgba(0, 0, 0, 0.4),
      inset 0 1px 2px rgba(255, 255, 255, 0.4) !important;
  }

  .hud-badge-avatar {
    width: 25px !important;
    height: 25px !important;
    font-size: 13px !important;
    border-width: 1.5px !important;
  }

  .hud-badge-label {
    font-size: 8px !important;
    letter-spacing: 0.5px !important;
  }

  .hud-badge-name {
    font-size: 12px !important;
    max-width: 85px !important;
    letter-spacing: 0.3px !important;
  }

  .hud-wood-btn {
    gap: 6px !important;
    padding: 4px 10px 4px 6px !important;
    border-width: 2px !important;
    font-size: 12px !important;
    box-shadow: 
      0 3px 0 #331504,
      0 5px 12px rgba(0, 0, 0, 0.4),
      inset 0 1px 2px rgba(255, 255, 255, 0.4) !important;
  }

  .hud-icon-bubble {
    width: 25px !important;
    height: 25px !important;
    font-size: 13px !important;
    border-width: 1.5px !important;
  }

  .hud-btn-fs {
    width: 33px !important;
    height: 33px !important;
    border-width: 2px !important;
  }

  .hud-fs-icon {
    font-size: 13px !important;
  }
}

/* 3. MOBILE LANDSCAPE (HP MODE MIRING / LAYAR PENUH)
   Saat HP dimiringkan horizontal, canvas memenuhi layar.
   Tombol tetap di dalam sudut canvas, tetapi dengan ukuran kompak & proporsional.
*/
@media (orientation: landscape) and (max-height: 560px),
       (orientation: landscape) and (max-width: 860px) {
  #c2canvasdiv.hud-landscape .game-hud-player,
  body.hud-landscape #c2canvasdiv .game-hud-player {
    bottom: 8px !important;
    top: auto !important;
    left: 10px !important;
  }

  #c2canvasdiv.hud-landscape .game-hud-actions,
  body.hud-landscape #c2canvasdiv .game-hud-actions {
    bottom: 8px !important;
    top: auto !important;
    right: 10px !important;
    gap: 5px !important;
  }

  #c2canvasdiv.hud-landscape .hud-wood-badge,
  body.hud-landscape #c2canvasdiv .hud-wood-badge {
    gap: 5px !important;
    padding: 3px 9px 3px 5px !important;
    border-width: 2px !important;
    box-shadow: 
      0 2px 0 #331504,
      0 4px 8px rgba(0, 0, 0, 0.4),
      inset 0 1px 1px rgba(255, 255, 255, 0.4) !important;
  }

  #c2canvasdiv.hud-landscape .hud-badge-avatar,
  body.hud-landscape #c2canvasdiv .hud-badge-avatar {
    width: 22px !important;
    height: 22px !important;
    font-size: 11px !important;
    border-width: 1.5px !important;
  }

  #c2canvasdiv.hud-landscape .hud-badge-label,
  body.hud-landscape #c2canvasdiv .hud-badge-label {
    font-size: 8px !important;
    letter-spacing: 0.4px !important;
  }

  #c2canvasdiv.hud-landscape .hud-badge-name,
  body.hud-landscape #c2canvasdiv .hud-badge-name {
    font-size: 11px !important;
    max-width: 75px !important;
  }

  #c2canvasdiv.hud-landscape .hud-wood-btn,
  body.hud-landscape #c2canvasdiv .hud-wood-btn {
    gap: 5px !important;
    padding: 3px 9px 3px 5px !important;
    border-width: 2px !important;
    font-size: 11px !important;
    box-shadow: 
      0 2px 0 #331504,
      0 4px 8px rgba(0, 0, 0, 0.4),
      inset 0 1px 1px rgba(255, 255, 255, 0.4) !important;
  }

  #c2canvasdiv.hud-landscape .hud-icon-bubble,
  body.hud-landscape #c2canvasdiv .hud-icon-bubble {
    width: 22px !important;
    height: 22px !important;
    font-size: 11px !important;
    border-width: 1.5px !important;
  }

  #c2canvasdiv.hud-landscape .hud-btn-fs,
  body.hud-landscape #c2canvasdiv .hud-btn-fs {
    width: 28px !important;
    height: 28px !important;
    border-width: 2px !important;
  }

  #c2canvasdiv.hud-landscape .hud-fs-icon,
  body.hud-landscape #c2canvasdiv .hud-fs-icon {
    font-size: 12px !important;
  }
}

/* 4. EXTRA SMALL PHONES (width <= 360px portrait) */
@media (orientation: portrait) and (max-width: 360px) {
  .hud-badge-name {
    max-width: 65px !important;
    font-size: 11px !important;
  }
  .hud-wood-btn {
    font-size: 11px !important;
    padding: 3px 8px 3px 4px !important;
  }
  .hud-btn-fs {
    width: 29px !important;
    height: 29px !important;
  }
}

/* ==========================================================================
   NAME INPUT ENHANCEMENT & GATING
   Seamless integration inside the pre-drawn parchment capsule (no awkward box!)
   ========================================================================== */
#c2canvasdiv input[type="text"],
#c2canvasdiv input {
  box-sizing: border-box !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
  text-align: left !important;
  font-family: var(--font-game), 'Fredoka', 'Nunito', cursive, sans-serif !important;
  font-weight: 800 !important;
  font-size: clamp(20px, 2.7vw, 40px) !important;
  line-height: normal !important;
  padding: 4px 18px 4px clamp(14px, 1.8vw, 24px) !important;
  border-radius: 999px !important;
  letter-spacing: 1.5px !important;
  color: #3b1d08 !important;
  caret-color: #8b5a2b !important;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.7) !important;
  transition: color 0.2s ease, text-shadow 0.2s ease !important;
}

#c2canvasdiv input::placeholder {
  color: rgba(120, 65, 25, 0.45) !important;
  font-family: var(--font-game), 'Fredoka', 'Nunito', cursive, sans-serif !important;
  font-size: 0.85em !important;
  font-weight: 600 !important;
  font-style: italic !important;
  letter-spacing: 0.5px !important;
}

@media (max-width: 900px) {
  #c2canvasdiv input[type="text"],
  #c2canvasdiv input {
    font-size: clamp(16px, 2.4vw, 24px) !important;
    padding: 3px 12px 3px clamp(10px, 1.5vw, 16px) !important;
  }
}

@media (orientation: portrait), (max-width: 600px) {
  #c2canvasdiv input[type="text"],
  #c2canvasdiv input {
    font-size: clamp(13px, 3.6vw, 18px) !important;
    padding: 2px 8px 2px 10px !important;
    letter-spacing: 0.5px !important;
  }
}

@media (orientation: portrait) and (max-width: 380px) {
  #c2canvasdiv input[type="text"],
  #c2canvasdiv input {
    font-size: 12px !important;
    padding: 1px 4px !important;
  }
}

#c2canvasdiv input:focus {
  outline: none !important;
  background: transparent !important;
  box-shadow: none !important;
  transform: none !important;
}

.input-invalid-shake {
  animation: inputShake 0.6s cubic-bezier(0.36, 0.07, 0.19, 0.97) both !important;
  color: #c0392b !important;
  text-shadow: 0 0 14px rgba(231, 76, 60, 0.7) !important;
}

@keyframes inputShake {
  10%, 90% { transform: translate3d(-4px, 0, 0); }
  20%, 80% { transform: translate3d(6px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-6px, 0, 0); }
  40%, 60% { transform: translate3d(6px, 0, 0); }
}

/* ==========================================================================
   PROMINENT GAME MODAL ALERT SYSTEM (BAGUS & KELIHATAN)
   ========================================================================== */
.game-alert-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 12, 22, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 10000;
  display: none !important;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none !important;
  transition: opacity 0.3s ease;
}

.game-alert-modal-backdrop.active {
  display: flex !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

.game-alert-modal-backdrop:not(.active) *,
.detective-modal-backdrop:not(.active) * {
  pointer-events: none !important;
}

.game-alert-modal-card {
  position: relative;
  width: 100%;
  max-width: 520px;
  background: linear-gradient(180deg, #fffcf4 0%, #faedd3 100%);
  border: 4.5px solid #8b5a2b;
  border-radius: 26px;
  box-shadow: 
    0 25px 65px rgba(0, 0, 0, 0.8),
    0 0 0 3px #f7d28b,
    0 0 35px rgba(245, 176, 65, 0.35);
  padding: 32px 28px 26px;
  text-align: center;
  color: #3e1f0b;
  transform: translateY(25px) scale(0.9);
  transition: transform 0.4s var(--ease-spring);
}

.game-alert-modal-backdrop.active .game-alert-modal-card {
  transform: translateY(0) scale(1);
}

.alert-modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid #8b5a2b;
  background: #fdf6e2;
  color: #8b5a2b;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.alert-modal-close:hover {
  background: #e74c3c;
  border-color: #c0392b;
  color: #fff;
  transform: scale(1.1);
}

.alert-modal-badge-wrapper {
  margin-top: -54px;
  margin-bottom: 12px;
  display: flex;
  justify-content: center;
}

.alert-modal-badge {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f5b041, #d35400);
  border: 4px solid #fff;
  box-shadow: 0 8px 20px rgba(0,0,0,0.35), 0 0 15px rgba(243,156,18,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  animation: badgeBounce 1.2s infinite alternate var(--ease-spring);
}

@keyframes badgeBounce {
  0% { transform: translateY(0) scale(1); }
  100% { transform: translateY(-6px) scale(1.08); }
}

.alert-modal-title {
  font-family: var(--font-title);
  font-size: 24px;
  font-weight: 900;
  color: #5c2c0e;
  margin: 0 0 8px 0;
  letter-spacing: 0.5px;
}

.alert-modal-divider {
  width: 70px;
  height: 3.5px;
  background: linear-gradient(90deg, transparent, #d49b4d, transparent);
  margin: 0 auto 16px;
  border-radius: 999px;
}

.alert-modal-content {
  font-family: var(--font-main);
  font-size: 16px;
  line-height: 1.5;
  color: #4a2818;
  margin-bottom: 24px;
}

.alert-highlight {
  font-size: 18px;
  font-weight: 800;
  color: #c0392b;
  margin-bottom: 10px;
  background: rgba(231, 76, 60, 0.08);
  padding: 10px 14px;
  border-radius: 12px;
  border: 1.5px dashed rgba(231, 76, 60, 0.4);
}

.alert-hint {
  font-size: 14px;
  font-weight: 600;
  color: #6d4224;
}

.alert-modal-footer {
  display: flex;
  justify-content: center;
}

@media (max-width: 600px), (orientation: portrait) {
  .game-alert-modal-backdrop {
    padding: 14px !important;
  }
  .game-alert-modal-card {
    padding: 24px 16px 18px !important;
    max-width: 94% !important;
    border-radius: 20px !important;
    border-width: 3.5px !important;
  }
  .alert-modal-badge {
    width: 60px !important;
    height: 60px !important;
    font-size: 26px !important;
  }
  .alert-modal-badge-wrapper {
    margin-top: -44px !important;
    margin-bottom: 8px !important;
  }
  .alert-modal-title {
    font-size: 18px !important;
    margin-bottom: 6px !important;
  }
  .alert-modal-divider {
    margin-bottom: 12px !important;
  }
  .alert-modal-content {
    margin-bottom: 18px !important;
  }
  .alert-highlight {
    font-size: 14px !important;
    padding: 8px 10px !important;
    margin-bottom: 8px !important;
  }
  .alert-hint {
    font-size: 12px !important;
    line-height: 1.4 !important;
  }
  .alert-modal-btn {
    font-size: 13px !important;
    padding: 8px 16px !important;
  }
}

/* ==========================================================================
   HASIL AKHIR (END GAME RESULT) DOM OVERLAY - MATCHES SCREENSHOT 2
   ========================================================================== */
.hasil-akhir-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
  opacity: 0;
  animation: fadeIn 0.5s 0.15s forwards var(--ease-smooth);
}

@keyframes fadeIn {
  to { opacity: 1; }
}

/* 1. Top Scalloped Box - Player Name */
.result-slot-name {
  position: absolute;
  top: 28.2%;
  left: 24.5%;
  width: 58.0%;
  height: 14.5%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  animation: slotPop 0.5s 0.15s var(--ease-spring) both;
}

.result-player-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 1.0vw, 14px);
  font-family: var(--font-game);
}

.title-prefix {
  font-family: var(--font-game);
  font-size: clamp(14px, calc(var(--game-ch, 720px) * 0.032), 30px);
  font-weight: 700;
  color: #7d441c;
  letter-spacing: 1.5px;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.9);
}

.title-name {
  font-family: var(--font-game);
  font-size: clamp(22px, calc(var(--game-ch, 720px) * 0.052), 48px);
  font-weight: 800;
  color: #2b1103;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  text-shadow: 0 2px 4px rgba(255, 255, 255, 0.95);
}

/* 2. Header Labels on Beige Ribbons */
.result-card-banner {
  position: absolute;
  top: 53.8%;
  height: 5.0%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-game);
  font-size: clamp(9px, calc(var(--game-ch, 720px) * 0.021), 18px);
  font-weight: 700;
  color: #4a240c;
  text-align: center;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.9);
  pointer-events: none;
  white-space: nowrap !important;
  line-height: 1 !important;
}

.result-banner-clock {
  left: 27.5%;
  width: 15.3%;
  animation: slotPop 0.5s 0.2s var(--ease-spring) both;
}

.result-banner-speedo {
  left: 45.7%;
  width: 15.4%;
  animation: slotPop 0.5s 0.3s var(--ease-spring) both;
}

.result-banner-medal {
  left: 64.0%;
  width: 15.4%;
  animation: slotPop 0.5s 0.4s var(--ease-spring) both;
}

/* 3. Inner Values inside Pre-Drawn Colored Boxes */
.result-card-val {
  position: absolute;
  top: 58.8%;
  height: 8.8%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
  font-family: var(--font-game);
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

.result-val-clock {
  left: 27.0%;
  width: 16.3%;
  flex-direction: column;
  animation: slotPop 0.5s 0.25s var(--ease-spring) both;
}

.result-time-num {
  font-family: var(--font-game);
  font-size: clamp(16px, calc(var(--game-ch, 720px) * 0.045), 40px);
  font-weight: 800;
  color: #1e1309;
  line-height: 1;
  letter-spacing: 0.5px;
}

.result-time-unit {
  font-family: var(--font-game);
  font-size: clamp(9px, calc(var(--game-ch, 720px) * 0.019), 16px);
  font-weight: 700;
  color: #6d4224;
  line-height: 1;
  margin-top: 2px;
}

.result-val-speedo {
  left: 45.2%;
  width: 16.4%;
  animation: slotPop 0.5s 0.35s var(--ease-spring) both;
}

.result-category-text {
  font-family: var(--font-game);
  font-size: clamp(13px, calc(var(--game-ch, 720px) * 0.034), 30px);
  font-weight: 800;
  color: #2a1204;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.7);
  letter-spacing: 0.3px;
  white-space: nowrap;
  line-height: 1;
}

.result-val-medal {
  left: 63.5%;
  width: 16.4%;
  animation: slotPop 0.5s 0.45s var(--ease-spring) both;
}

.result-predicate-text {
  font-family: var(--font-game);
  font-size: clamp(12px, calc(var(--game-ch, 720px) * 0.030), 26px);
  font-weight: 800;
  color: #073b22;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.7);
  letter-spacing: 0.2px;
  white-space: nowrap;
  line-height: 1;
}

@keyframes slotPop {
  0% { transform: translateY(18px) scale(0.85); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

/* Media queries moved below base button classes for proper CSS cascade */

/* Fullscreen Fit to Screen (Maintain 16:9 Letterbox without stretching) */
:fullscreen {
  background-color: #000000 !important;
}
:-webkit-full-screen {
  background-color: #000000 !important;
}
:fullscreen body {
  background-color: #000000 !important;
  width: 100vw !important;
  height: 100vh !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
}
:-webkit-full-screen body {
  background-color: #000000 !important;
  width: 100vw !important;
  height: 100vh !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
}

/* Simulated Fullscreen Fallback */
body.fullscreen-simulated {
  background-color: #000000 !important;
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 999999 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
}

/* 4. Bottom Wooden Action Buttons - Resting cleanly on the desk table */
.result-wood-actions {
  position: absolute;
  top: 84.5%;
  left: 53.5%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  pointer-events: auto;
  animation: slideUpFade 0.5s 0.55s var(--ease-spring) both;
}

.wood-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 7px 18px 7px 10px;
  background: linear-gradient(180deg, #c77428 0%, #944610 50%, #632a07 100%);
  border: 3.5px solid #ffcc66;
  border-radius: 999px;
  color: #fffaf0;
  font-family: var(--font-game);
  font-weight: 700;
  font-size: clamp(13px, 1.2vw, 18px);
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.7);
  box-shadow: 
    0 5px 0 #331504,
    0 8px 18px rgba(0, 0, 0, 0.5),
    inset 0 2px 2px rgba(255, 255, 255, 0.4),
    inset 0 -2px 2px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: all 0.2s var(--ease-spring);
  pointer-events: auto;
  white-space: nowrap;
}

.wood-action-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-3px);
  box-shadow: 
    0 9px 0 #331504,
    0 14px 24px rgba(0, 0, 0, 0.55),
    inset 0 2px 2px rgba(255, 255, 255, 0.5);
}

.wood-action-btn:active {
  transform: translateY(4px);
  box-shadow: 
    0 2px 0 #331504,
    0 4px 8px rgba(0, 0, 0, 0.4);
}

.wood-icon-bubble {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #4a1d06;
  border: 2px solid #f3a852;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
}

.wood-text {
  font-family: var(--font-game);
  letter-spacing: 0.5px;
}

@keyframes slideUpFade {
  0% { transform: translate(-50%, 25px); opacity: 0; }
  100% { transform: translate(-50%, 0); opacity: 1; }
}

/* Responsive Adaptations for Endscreen on Tablets and Mobile Phones */
@media (max-width: 900px) {
  .result-player-title {
    gap: 6px;
  }
  .result-card-banner {
    white-space: nowrap !important;
    line-height: 1 !important;
  }
  .result-time-num,
  .result-time-unit,
  .result-category-text,
  .result-predicate-text {
    line-height: 1 !important;
  }
  .result-wood-actions {
    top: 84.0% !important;
    left: 53.5% !important;
    transform: translateX(-50%) !important;
    gap: clamp(4px, 1.0vw, 8px) !important;
    max-width: 96% !important;
  }
  .wood-action-btn {
    padding: 4px 10px 4px 6px !important;
    font-size: clamp(9px, calc(var(--game-ch, 720px) * 0.021), 13px) !important;
    border-width: 2px !important;
  }
  .wood-icon-bubble {
    width: 20px !important;
    height: 20px !important;
    font-size: 11px !important;
  }
}

@media (max-width: 600px), (orientation: portrait) {
  .result-player-title {
    gap: 4px;
  }
  .result-card-banner {
    white-space: nowrap !important;
    line-height: 1 !important;
  }
  .result-time-num,
  .result-time-unit,
  .result-category-text,
  .result-predicate-text {
    line-height: 1 !important;
  }
  .result-wood-actions {
    top: 84.5% !important;
    left: 53.5% !important;
    transform: translateX(-50%) !important;
    gap: 4px !important;
    width: max-content !important;
    max-width: 98% !important;
  }
  .wood-action-btn {
    padding: 3px 7px 3px 4px !important;
    font-size: clamp(8px, calc(var(--game-ch, 720px) * 0.020), 11px) !important;
    border-width: 1.5px !important;
    gap: 3px !important;
  }
  .wood-icon-bubble {
    width: 16px !important;
    height: 16px !important;
    font-size: 9px !important;
    border-width: 1px !important;
  }
  .wood-text {
    white-space: nowrap !important;
  }
}

/* ==========================================================================
   MODAL WINDOWS (LEADERBOARD & CERTIFICATE)
   ========================================================================== */
.detective-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 10, 18, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 10000;
  display: none !important;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none !important;
  transition: opacity 0.3s var(--ease-smooth);
}

.detective-modal-backdrop.active {
  display: flex !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

.detective-modal-card {
  background: #141e33;
  background-image: 
    radial-gradient(circle at 50% 0%, rgba(245, 176, 65, 0.15) 0%, transparent 60%),
    linear-gradient(180deg, #18263f 0%, #0d1524 100%);
  border: 3.5px solid #ffcc66;
  border-radius: 24px;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 
    0 25px 60px rgba(0, 0, 0, 0.9),
    0 0 35px rgba(245, 176, 65, 0.2);
  transform: translateY(30px) scale(0.95);
  transition: transform 0.4s var(--ease-spring);
  overflow: hidden;
  font-family: var(--font-game) !important;
}

.detective-modal-backdrop.active .detective-modal-card {
  transform: translateY(0) scale(1);
}

/* Custom Confirmation Modal for Leaderboard Clear */
.confirm-clear-backdrop {
  z-index: 20000 !important;
  background: rgba(5, 10, 18, 0.88) !important;
}

.confirm-modal-card {
  max-width: 440px !important;
  text-align: center;
  padding: 30px 24px 26px !important;
  border: 4px solid #f59e0b !important;
  box-shadow: 
    0 25px 60px rgba(0, 0, 0, 0.95),
    0 0 40px rgba(245, 158, 11, 0.35) !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
}

.confirm-modal-icon {
  font-size: 52px;
  margin-bottom: 12px;
  line-height: 1;
  animation: pulseIcon 1.2s infinite ease-in-out;
}

@keyframes pulseIcon {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

.confirm-modal-title {
  font-family: var(--font-game) !important;
  font-size: clamp(20px, 2.2vw, 26px) !important;
  font-weight: 800 !important;
  color: #ffeedd !important;
  margin: 0 0 12px !important;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6) !important;
}

.confirm-modal-desc {
  font-family: 'Inter', system-ui, sans-serif !important;
  font-size: 14.5px !important;
  color: #cbd5e1 !important;
  line-height: 1.55 !important;
  margin: 0 0 24px !important;
}

.confirm-modal-actions {
  display: flex !important;
  gap: 14px !important;
  justify-content: center !important;
  width: 100% !important;
}

.confirm-btn {
  font-family: var(--font-game) !important;
  font-size: 15px !important;
  font-weight: 700 !important;
  padding: 10px 24px !important;
  border-radius: 999px !important;
  cursor: pointer !important;
  border: none !important;
  transition: all 0.2s var(--ease-spring) !important;
  box-shadow: 0 4px 10px rgba(0,0,0,0.4) !important;
  letter-spacing: 0.5px !important;
}

.confirm-btn-cancel {
  background: #334155 !important;
  color: #e2e8f0 !important;
  border: 2px solid #64748b !important;
}

.confirm-btn-cancel:hover {
  background: #475569 !important;
  transform: translateY(-2px) !important;
}

.confirm-btn-danger {
  background: linear-gradient(180deg, #ef4444 0%, #b91c1c 100%) !important;
  color: #ffffff !important;
  border: 2.5px solid #fca5a5 !important;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.4) !important;
}

.confirm-btn-danger:hover {
  filter: brightness(1.15) !important;
  transform: translateY(-2px) !important;
}

/* Detective Name Input on 'identitas pengguna' */
.c2-input-name {
  font-family: var(--font-game), cursive, sans-serif !important;
  font-weight: 800 !important;
  font-size: clamp(28px, 3.8vw, 52px) !important;
  color: #3a1c07 !important;
  caret-color: #8b5a2b !important;
  letter-spacing: 1.5px !important;
}

@media (max-width: 600px), (orientation: portrait) {
  .c2-input-name {
    font-size: clamp(22px, 5.0vw, 30px) !important;
  }
}

/* Leaderboard Clear History Button & Row */
.lb-clear-row {
  margin-top: 24px;
  text-align: center;
  display: flex;
  justify-content: center;
}

.btn-clear-history {
  background: rgba(239, 68, 68, 0.12) !important;
  border: 1.5px solid rgba(239, 68, 68, 0.35) !important;
  border-radius: 999px !important;
  padding: 8px 22px !important;
  color: #fca5a5 !important;
  font-size: 13.5px !important;
  font-weight: 700 !important;
  cursor: pointer !important;
  transition: all 0.2s var(--ease-spring) !important;
  font-family: var(--font-game) !important;
  letter-spacing: 0.5px !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
}

.btn-clear-history:hover {
  background: rgba(239, 68, 68, 0.25) !important;
  border-color: #ef4444 !important;
  color: #ffffff !important;
  transform: translateY(-2px) !important;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.4) !important;
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 2px solid rgba(245, 176, 65, 0.25);
  background: rgba(10, 16, 28, 0.4);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-family: var(--font-game) !important;
  font-size: 26px;
  font-weight: 700;
  color: var(--gold-light);
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  letter-spacing: 0.5px;
}

.modal-close-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  transition: all 0.2s ease;
}

.modal-close-btn:hover {
  background: rgba(231, 76, 60, 0.3);
  border-color: #e74c3c;
  color: #fff;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

/* Leaderboard List */
.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  transition: all 0.2s ease;
  font-family: var(--font-game) !important;
}

.leaderboard-item:hover {
  background: rgba(245, 176, 65, 0.12);
  border-color: rgba(245, 176, 65, 0.4);
  transform: translateX(4px);
}

.leaderboard-item.rank-1 {
  background: linear-gradient(90deg, rgba(245, 176, 65, 0.25), rgba(245, 176, 65, 0.06));
  border-color: rgba(245, 176, 65, 0.6);
}

.leaderboard-item.rank-2 {
  background: linear-gradient(90deg, rgba(148, 163, 184, 0.25), rgba(148, 163, 184, 0.06));
  border-color: rgba(148, 163, 184, 0.5);
}

.leaderboard-item.rank-3 {
  background: linear-gradient(90deg, rgba(205, 127, 50, 0.25), rgba(205, 127, 50, 0.06));
  border-color: rgba(205, 127, 50, 0.5);
}

.lb-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.lb-rank {
  font-family: var(--font-game) !important;
  font-size: 24px;
  font-weight: 700;
  width: 36px;
  text-align: center;
}

.lb-name {
  font-family: var(--font-game) !important;
  font-weight: 700;
  font-size: 22px;
  color: #fff;
  letter-spacing: 0.5px;
}

.lb-meta {
  font-family: var(--font-game) !important;
  font-size: 14px;
  color: #cbd5e1;
  margin-top: 2px;
}

.lb-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.lb-time {
  font-family: var(--font-game) !important;
  font-weight: 700;
  font-size: 24px;
  color: #4ade80;
  letter-spacing: 0.5px;
  text-shadow: 0 0 12px rgba(74, 222, 128, 0.35);
}

.lb-badge {
  font-family: var(--font-game) !important;
  font-size: 14px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(245, 176, 65, 0.2);
  color: #fcd34d;
  border: 1.5px solid rgba(245, 176, 65, 0.4);
}

/* ==========================================================================
   A4 LANDSCAPE DETECTIVE CERTIFICATE (PIAGAM INVESTIGASI RESMI)
   Proportion: A4 Landscape (297mm x 210mm, ratio ~1.414 : 1)
   ========================================================================== */
#certificate-modal .detective-modal-card {
  max-width: 980px;
  background: #111a2e;
}

#certificate-modal .modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  align-items: center;
}

.cert-card-a4 {
  position: relative;
  width: 100%;
  max-width: 920px;
  aspect-ratio: 297 / 210;
  background: #fdfaf2;
  background-image: 
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.9) 0%, rgba(253, 246, 226, 0.95) 75%),
    repeating-linear-gradient(45deg, rgba(180, 115, 45, 0.02) 0px, rgba(180, 115, 45, 0.02) 2px, transparent 2px, transparent 8px);
  border: 7px solid #4a2818;
  border-radius: 12px;
  box-shadow: 
    0 15px 45px rgba(0, 0, 0, 0.6),
    inset 0 0 0 2px #d4af37,
    inset 0 0 35px rgba(212, 175, 55, 0.15);
  padding: 14px;
  color: #2c1810;
  text-align: center;
  box-sizing: border-box;
  overflow: hidden;
  user-select: text;
}

/* Corner Ornaments */
.cert-corner-ornament {
  position: absolute;
  font-size: 20px;
  color: #b45309;
  line-height: 1;
  pointer-events: none;
  z-index: 5;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.15));
}
.cert-corner-tl { top: 18px; left: 18px; }
.cert-corner-tr { top: 18px; right: 18px; }
.cert-corner-bl { bottom: 18px; left: 18px; }
.cert-corner-br { bottom: 18px; right: 18px; }

/* Inner Ornate Frame */
.cert-inner-frame {
  position: relative;
  width: 100%;
  height: 100%;
  border: 2px dashed #b45309;
  border-radius: 8px;
  padding: 14px 24px 12px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* Institution Header - Hidden as requested by user */
.cert-header-institution {
  display: none !important;
}

.cert-badge-crest {
  font-size: 26px;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.2));
}

.cert-inst-text {
  text-align: center;
  line-height: 1.25;
}

.cert-inst-kemen {
  font-family: var(--font-game);
  font-size: clamp(9px, 1.0vw, 11px);
  font-weight: 700;
  letter-spacing: 1.2px;
  color: #78350f;
  text-transform: uppercase;
}

.cert-inst-bbgtk {
  font-family: var(--font-game);
  font-size: clamp(10px, 1.15vw, 13px);
  font-weight: 800;
  letter-spacing: 0.8px;
  color: #3b1d08;
  text-transform: uppercase;
}

.cert-inst-app {
  font-family: var(--font-game);
  font-size: clamp(8.5px, 0.95vw, 10.5px);
  color: #92400e;
  font-weight: 600;
}

/* Gold Divider */
.cert-gold-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 4px 0 2px;
}

.cert-divider-line {
  flex: 1;
  max-width: 220px;
  height: 1.5px;
  background: linear-gradient(90deg, transparent, #d4af37, transparent);
}

.cert-divider-diamond {
  color: #d4af37;
  font-size: 10px;
  letter-spacing: 3px;
}

/* Main Certificate Titles */
.cert-main-title {
  font-family: var(--font-game);
  font-size: clamp(22px, 2.7vw, 32px);
  font-weight: 800;
  letter-spacing: 2px;
  color: #4a1d06;
  text-transform: uppercase;
  line-height: 1.1;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.9);
}

.cert-honor-title {
  font-family: var(--font-game);
  font-size: clamp(11px, 1.3vw, 14.5px);
  font-weight: 700;
  color: #b45309;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-top: 1px;
}

/* Recipient Preamble & Name */
.cert-recipient-preamble {
  font-family: var(--font-game);
  font-size: clamp(10px, 1.1vw, 12.5px);
  color: #6b3510;
  margin-top: 2px;
}

.cert-recipient-name {
  font-family: var(--font-game);
  font-size: clamp(28px, 3.4vw, 42px);
  font-weight: 800;
  color: #1e3a8a;
  text-transform: uppercase;
  letter-spacing: 2px;
  line-height: 1.15;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
  margin-top: 2px;
}

.cert-name-underline {
  width: 220px;
  height: 3px;
  background: linear-gradient(90deg, transparent, #d4af37 20%, #d4af37 80%, transparent);
  margin: 1px auto 4px;
  border-radius: 999px;
}

/* Citation */
.cert-citation {
  font-family: var(--font-game);
  font-size: clamp(10.5px, 1.15vw, 13px);
  line-height: 1.35;
  color: #431f08;
  max-width: 680px;
  margin: 0 auto 6px;
}

/* Metric Matrix Row (3 plaques) */
.cert-matrix-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
}

.cert-plaque {
  background: rgba(255, 255, 255, 0.92);
  border: 1.5px solid #d4af37;
  border-radius: 8px;
  padding: 6px 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.cert-plaque-icon {
  font-size: 16px;
  line-height: 1;
}

.cert-plaque-label {
  font-family: var(--font-game);
  font-size: clamp(8.5px, 0.95vw, 10.5px);
  font-weight: 700;
  letter-spacing: 0.8px;
  color: #78350f;
  text-transform: uppercase;
  margin-top: 2px;
}

.cert-plaque-val {
  font-family: var(--font-game);
  font-size: clamp(15px, 1.7vw, 21px);
  font-weight: 800;
  color: #1e3a8a;
  line-height: 1.1;
  margin-top: 2px;
}

.cert-plaque-sub {
  font-family: var(--font-game);
  font-size: clamp(8px, 0.85vw, 10px);
  font-weight: 600;
  color: #8c5a32;
  margin-top: 1px;
}

/* Stars Row */
.cert-stars-row {
  margin: 4px 0 2px;
  font-size: clamp(15px, 1.7vw, 20px);
  color: #eab308;
  letter-spacing: 4px;
  text-shadow: 0 1px 4px rgba(234, 179, 8, 0.4);
}

/* Footer Verification & Signatures */
.cert-footer-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  border-top: 1px dashed #b45309;
  padding-top: 8px;
  margin-top: 4px;
}

.cert-foot-left {
  text-align: left;
  line-height: 1.3;
}

.cert-foot-meta-title {
  font-family: var(--font-game);
  font-size: clamp(8.5px, 0.9vw, 10.5px);
  font-weight: 800;
  color: #78350f;
  letter-spacing: 0.5px;
}

.cert-foot-date,
.cert-foot-reg,
.cert-foot-inst {
  font-family: var(--font-game);
  font-size: clamp(8.5px, 0.9vw, 10.5px);
  color: #4a2818;
}

/* Center Medallion Seal */
.cert-gold-seal {
  position: relative;
  width: 58px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cert-seal-outer {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: radial-gradient(circle, #fde047 20%, #d97706 70%, #92400e 100%);
  border: 2px dashed #ffffff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25), inset 0 2px 4px rgba(255, 255, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
}

.cert-seal-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
  color: #fffdf0;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.cert-seal-star {
  font-size: 11px;
}

.cert-seal-text {
  font-family: var(--font-game);
  font-size: 6.5px;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin-top: 1px;
}

.cert-seal-year {
  font-family: var(--font-game);
  font-size: 6px;
  font-weight: 700;
  color: #fef08a;
  margin-top: 1px;
}

.cert-ribbon-tail {
  position: absolute;
  bottom: -10px;
  width: 14px;
  height: 24px;
  background: #b91c1c;
  z-index: 1;
}

.cert-ribbon-tail.left {
  left: 15px;
  transform: rotate(18deg);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 80%, 0 100%);
}

.cert-ribbon-tail.right {
  right: 15px;
  transform: rotate(-18deg);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 80%, 0 100%);
}

.cert-foot-right {
  text-align: right;
  line-height: 1.3;
}

.cert-foot-status-badge {
  display: inline-block;
  font-family: var(--font-game);
  font-size: clamp(8.5px, 0.9vw, 10.5px);
  font-weight: 800;
  color: #065f46;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  padding: 1px 6px;
  border-radius: 4px;
  margin-bottom: 2px;
}

.cert-foot-sign-role,
.cert-foot-sign-org {
  font-family: var(--font-game);
  font-size: clamp(8.5px, 0.9vw, 10.5px);
  color: #4a2818;
  font-weight: 600;
}

.cert-foot-hash {
  font-family: monospace;
  font-size: clamp(7.5px, 0.8vw, 9.5px);
  color: #92400e;
}

/* ==========================================================================
   PRINT SPECIFIC RULES (EXACT A4 LANDSCAPE FULL-PAGE)
   ========================================================================== */
@media print {
  @page {
    size: A4 landscape;
    margin: 0;
  }

  html, body {
    width: 297mm !important;
    height: 210mm !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    overflow: hidden !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* CRITICAL: Completely hide all non-certificate DOM trees using display: none so they DO NOT take up layout space */
  #c2canvasdiv,
  #c2canvas,
  canvas,
  .screen-vignette,
  .thematic-game-hud,
  .game-hud-player,
  .game-hud-actions,
  .hasil-akhir-overlay,
  .game-alert-modal-backdrop,
  #leaderboard-modal,
  #stage-wrapper,
  .preview-header,
  .test-controls,
  .modal-backdrop:not(#certificate-modal) {
    display: none !important;
  }

  /* Modal becomes the full document page */
  #certificate-modal {
    display: block !important;
    position: static !important;
    width: 297mm !important;
    height: 210mm !important;
    min-height: 210mm !important;
    max-width: 297mm !important;
    max-height: 210mm !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    box-shadow: none !important;
    border: none !important;
    overflow: hidden !important;
    opacity: 1 !important;
    visibility: visible !important;
  }

  .detective-modal-card {
    display: block !important;
    position: static !important;
    width: 297mm !important;
    height: 210mm !important;
    max-width: 297mm !important;
    max-height: 210mm !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    background: #fff !important;
    border-radius: 0 !important;
    transform: none !important;
    overflow: hidden !important;
    visibility: visible !important;
  }

  .modal-header,
  .modal-close-btn,
  #btn-print-cert {
    display: none !important;
  }

  .modal-body {
    padding: 0 !important;
    margin: 0 !important;
    width: 297mm !important;
    height: 210mm !important;
    overflow: hidden !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    visibility: visible !important;
  }

  .cert-card-a4 {
    width: 297mm !important;
    height: 210mm !important;
    max-width: 297mm !important;
    max-height: 210mm !important;
    aspect-ratio: auto !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 10mm 14mm !important;
    box-sizing: border-box !important;
    visibility: visible !important;
    page-break-inside: avoid !important;
    page-break-after: avoid !important;
    page-break-before: avoid !important;
  }

  .cert-inner-frame {
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    padding: 8mm 14mm !important;
    box-sizing: border-box !important;
  }

  .cert-header-institution {
    display: none !important;
  }
}
