* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  overflow: hidden;
  background: #1a1410;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: #ffffff;
  user-select: none;
}

canvas {
  display: block;
}

/* HUD ringkas di pojok kiri atas */
#hud {
  position: fixed;
  top: 10px;
  left: 10px;
  width: 180px;
  background: rgba(15, 23, 42, 0.68);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 6px 9px 7px;
  backdrop-filter: blur(6px);
  pointer-events: none;
  font-size: 11px;
}

#hud .hud-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-weight: 700;
}

#hud .level-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #38bdf8;
}

#hud .timer {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  color: #f8fafc;
}

#hud .timer.warning {
  color: #f87171;
}

#hud .chaos-row {
  margin-top: 2px;
  display: flex;
  align-items: baseline;
  gap: 4px;
}

#hud .chaos-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #94a3b8;
}

#hud .chaos-value {
  font-size: 14px;
  font-weight: 700;
  color: #facc15;
}

#hud .chaos-target-text {
  font-size: 10px;
  color: #cbd5e1;
}

/* Chaos Meter: 0..200% target, garis target di 100%, bintang di 100/150/200% */
#hud .chaos-meter {
  position: relative;
  margin: 3px 5px 10px 0;
  height: 6px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
}

#hud .chaos-fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: linear-gradient(90deg, #f59e0b, #ef4444);
  transition: width 0.25s ease;
}

#hud .chaos-target {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  margin-left: -1px;
  background: #f8fafc;
}

#hud .chaos-star {
  position: absolute;
  top: 5px;
  transform: translateX(-50%);
  font-size: 9px;
  color: #475569;
  transition: color 0.2s ease, transform 0.2s ease;
}

#hud .chaos-star.reached {
  color: #facc15;
  transform: translateX(-50%) scale(1.3);
}

#hud .combo-status {
  display: none;
  font-size: 10px;
  font-weight: 700;
  color: #f472b6;
}

#hud .combo-status.active {
  display: block;
}

#hud .status-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

#hud .lives-hearts {
  font-size: 10px;
  letter-spacing: 0;
  white-space: nowrap;
}

#hud .stamina-bar {
  flex: 1;
  height: 5px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
  overflow: hidden;
}

#hud .stamina-fill {
  height: 100%;
  width: 100%;
  background: #4ade80;
  transition: background 0.2s ease;
}

#hud .stamina-fill.exhausted {
  background: #f87171;
}

#hud .meow-status {
  min-width: 24px;
  text-align: right;
  font-size: 10px;
  font-weight: 700;
  color: #fbbf24;
  font-variant-numeric: tabular-nums;
}

#hud .meow-status.cooldown {
  color: #64748b;
}

/* Petunjuk & layar bantuan (H) */
#help-hint {
  position: fixed;
  left: 10px;
  bottom: 10px;
  padding: 3px 7px;
  font-size: 11px;
  color: #cbd5e1;
  background: rgba(15, 23, 42, 0.55);
  border-radius: 5px;
  pointer-events: none;
}

#help-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 8;
}

#help-overlay.active {
  display: flex;
}

#help-overlay .help-panel {
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 16px 22px;
  max-width: 420px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

#help-overlay h2 {
  font-size: 16px;
  margin-bottom: 8px;
  color: #facc15;
}

#help-overlay table {
  border-collapse: collapse;
  font-size: 13px;
  color: #e2e8f0;
}

#help-overlay td {
  padding: 3px 10px 3px 0;
  vertical-align: middle;
}

#help-overlay td:first-child {
  white-space: nowrap;
  color: #cbd5e1;
}

#help-overlay kbd {
  display: inline-block;
  min-width: 18px;
  margin-right: 2px;
  padding: 1px 5px;
  font: 11px/1.4 Consolas, 'Courier New', monospace;
  text-align: center;
  color: #0f172a;
  background: #e2e8f0;
  border-radius: 3px;
}

#help-overlay .help-goal {
  margin-top: 10px;
  font-size: 12px;
  color: #cbd5e1;
}

#help-overlay .help-timer {
  margin-top: 8px;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
}

#help-overlay .help-timer-fill {
  height: 100%;
  width: 0%;
  background: #38bdf8;
}

/* Layar hasil akhir level */
#results {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(10, 15, 28, 0.75);
  backdrop-filter: blur(5px);
  z-index: 10;
}

#results.active,
#pause.active {
  display: flex;
}

#pause {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(10, 15, 28, 0.6);
  backdrop-filter: blur(4px);
  z-index: 11;
}

.modal {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  padding: 28px 36px;
  text-align: center;
  min-width: 280px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
}

.modal h1 {
  font-size: 28px;
  color: #f87171;
  margin-bottom: 8px;
}

.modal h1.won {
  color: #4ade80;
}

.modal .results-reason {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #94a3b8;
}

.modal .results-stars {
  font-size: 34px;
  letter-spacing: 6px;
  color: #facc15;
  margin-bottom: 8px;
}

.modal .results-stars.none {
  color: #475569;
}

.modal .results-message {
  font-style: italic;
  color: #cbd5e1;
  margin-bottom: 14px;
}

.modal p {
  font-size: 16px;
  margin: 8px 0;
  color: #e2e8f0;
}

.modal span {
  font-weight: 700;
  color: #facc15;
}

/* Prompt interaksi (E) */
#interact-prompt {
  position: fixed;
  left: 50%;
  bottom: 15%;
  transform: translateX(-50%);
  padding: 8px 16px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(250, 204, 21, 0.6);
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  color: #facc15;
  display: none;
  pointer-events: none;
}

#interact-prompt.active {
  display: block;
}

/* Panel overlay debug developer (F3) */
#debug-panel {
  position: fixed;
  bottom: 16px;
  right: 16px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.65);
  border-radius: 6px;
  font: 12px/1.5 Consolas, 'Courier New', monospace;
  color: #a7f3d0;
  white-space: pre;
  display: none;
  pointer-events: none;
}

#debug-panel.active {
  display: block;
}

/* Teks melayang (+40, COMBO x1.5) */
#float-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.float-text {
  position: absolute;
  left: 0;
  top: 0;
  font-weight: 800;
  white-space: nowrap;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  will-change: transform, opacity;
}

.float-text.chaos {
  font-size: 26px;
  color: #facc15;
}

.float-text.combo {
  font-size: 18px;
  color: #f472b6;
  letter-spacing: 1px;
}

/* Indikator ?/! dan meter curiga di atas kepala pemilik */
#owner-indicator {
  position: fixed;
  left: 0;
  top: 0;
  display: none;
  text-align: center;
  pointer-events: none;
  will-change: transform;
}

#owner-indicator .oi-icon {
  font-size: 34px;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7);
}

#owner-indicator .oi-icon.curious {
  color: #facc15;
}

#owner-indicator .oi-icon.alarm {
  color: #ef4444;
  animation: oi-pulse 0.4s ease-in-out infinite alternate;
}

@keyframes oi-pulse {
  from { transform: scale(1); }
  to { transform: scale(1.25); }
}

#owner-indicator .oi-bar {
  width: 56px;
  height: 6px;
  margin: 4px auto 0;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 3px;
  overflow: hidden;
}

#owner-indicator .oi-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #facc15, #ef4444);
}

#owner-indicator .oi-debug {
  display: none;
  margin-top: 4px;
  padding: 2px 6px;
  background: rgba(0, 0, 0, 0.65);
  border-radius: 4px;
  font: 11px/1.4 Consolas, 'Courier New', monospace;
  color: #a7f3d0;
  white-space: nowrap;
}

/* Efek layar KETAHUAN */
#game-canvas {
  transition: none;
}

#vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 35%, rgba(0, 0, 0, 0.95) 100%);
  z-index: 5;
}

#caught-text {
  position: fixed;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%) scale(0);
  font-size: 84px;
  font-weight: 900;
  letter-spacing: 4px;
  color: #ef4444;
  text-shadow: 0 0 2px #000, 0 6px 0 #7f1d1d, 0 10px 30px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  opacity: 0;
  z-index: 6;
}

#caught-text.active {
  opacity: 1;
  animation: caught-thump 0.55s cubic-bezier(0.2, 1.6, 0.4, 1) forwards;
}

@keyframes caught-thump {
  0% { transform: translate(-50%, -50%) scale(2.6); opacity: 0; }
  45% { transform: translate(-50%, -50%) scale(0.92); opacity: 1; }
  70% { transform: translate(-50%, -50%) scale(1.06); }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

#fade-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  z-index: 7;
}

/* Ikon mata status persembunyian (HUD) */
#hud .hide-eye {
  position: relative;
  display: inline-block;
  width: 16px;
  height: 9px;
  border-radius: 50%;
  border: 1.5px solid transparent;
  overflow: hidden;
  flex: none;
}

#hud .hide-eye::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: currentColor;
}

#hud .hide-eye::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 0;
  background: #334155;
}

#hud .hide-eye.closed,
#hud .hide-eye.half,
#hud .hide-eye.open {
  border-color: currentColor;
}

#hud .hide-eye.closed {
  color: #4ade80;
}

#hud .hide-eye.closed::after {
  height: 100%; /* kelopak tertutup */
}

#hud .hide-eye.half {
  color: #facc15;
}

#hud .hide-eye.half::after {
  height: 50%;
}

#hud .hide-eye.open {
  color: #ef4444;
}

/* Teks melayang tingkah kucing */
.float-text.heart {
  font-size: 18px;
  color: #f472b6;
}

.float-text.zzz {
  font-size: 15px;
  font-style: italic;
  color: #bfdbfe;
}

/* Zoomies (catnip): tepi layar berpelangi tipis */
#zoomies-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 4;
  border: 10px solid transparent;
  border-image: linear-gradient(90deg, #f87171, #facc15, #4ade80, #38bdf8, #a78bfa, #f472b6) 1;
  filter: blur(3px);
  animation: zoomies-hue 0.8s linear infinite;
}

#zoomies-overlay.active {
  opacity: 0.75;
}

@keyframes zoomies-hue {
  from { filter: blur(3px) hue-rotate(0deg); }
  to { filter: blur(3px) hue-rotate(360deg); }
}

/* Tanda bulan kecil di pojok ikon mata saat kucing di area gelap */
#hud .dark-moon {
  display: none;
  margin-left: -7px;
  font-size: 10px;
  line-height: 1;
  color: #c7d2fe;
  text-shadow: 0 0 4px rgba(129, 140, 248, 0.9);
  transform: translateY(-6px);
  flex: none;
}

#hud .dark-moon.active {
  display: inline-block;
}

/* ---------- Tombol umum ---------- */
.btn {
  display: block;
  padding: 10px 22px;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  color: #f8fafc;
  background: rgba(51, 65, 85, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 9px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
}

.btn:hover:not(:disabled) {
  background: rgba(71, 85, 105, 0.95);
  transform: translateY(-1px);
}

.btn.primary {
  color: #0f172a;
  background: #facc15;
  border-color: #facc15;
}

.btn.primary:hover:not(:disabled) {
  background: #fde047;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.big {
  font-size: 20px;
  padding: 12px 22px;
}

.btn small {
  display: block;
  font-size: 12px;
  font-weight: 600;
  opacity: 0.75;
}

.btn-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 20px;
}

.btn-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.modal .results-level,
.modal .pause-level {
  font-size: 14px;
  color: #cbd5e1;
  margin: 2px 0 10px;
}

.modal .pause-title {
  color: #f8fafc;
}

.modal .pause-hint {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 14px;
}

/* ---------- Mode: elemen permainan disembunyikan di lobi ---------- */
body.mode-lobby #hud,
body.mode-lobby #help-hint,
body.mode-lobby #interact-prompt,
body.mode-lobby #owner-indicator,
body.mode-lobby #float-layer,
body.mode-lobby #meeting-badge,
body.mode-lobby #debug-panel {
  display: none !important;
}

/* ---------- Lobi ---------- */
#lobby {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 9;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(15, 10, 6, 0.72) 0%, rgba(15, 10, 6, 0.35) 38%, rgba(15, 10, 6, 0) 60%);
}

#lobby.active {
  display: block;
}

#lobby .bank-chip {
  position: absolute;
  top: 14px;
  right: 16px;
  padding: 7px 14px;
  font-size: 13px;
  color: #e2e8f0;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(250, 204, 21, 0.45);
  border-radius: 999px;
}

#lobby .bank-chip b {
  color: #facc15;
  font-size: 16px;
  margin-left: 6px;
}

.lobby-panel {
  position: absolute;
  left: 6vw;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  flex-direction: column;
  gap: 10px;
  width: 280px;
  pointer-events: auto;
}

.lobby-panel.active {
  display: flex;
}

.lobby-panel.wide {
  width: min(720px, 88vw);
  max-height: 86vh;
  overflow-y: auto;
  padding: 20px 22px;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
}

.lobby-panel h2 {
  font-size: 22px;
  color: #facc15;
  margin-bottom: 4px;
}

.game-title {
  font-size: 44px;
  line-height: 1;
  color: #facc15;
  text-shadow: 0 3px 0 #92400e, 0 6px 18px rgba(0, 0, 0, 0.5);
}

.game-tagline {
  color: #e2e8f0;
  margin-bottom: 14px;
}

.level-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.level-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px;
  text-align: left;
  font: inherit;
  color: #f8fafc;
  background: rgba(51, 65, 85, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 11px;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.level-card:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: #facc15;
}

.level-card.locked {
  opacity: 0.55;
  cursor: not-allowed;
}

.level-card .lc-num {
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #94a3b8;
}

.level-card .lc-name {
  font-size: 18px;
  font-weight: 800;
}

.level-card .lc-desc {
  font-size: 13px;
  color: #cbd5e1;
}

.level-card .lc-meta {
  font-size: 12px;
  color: #94a3b8;
}

.level-card .lc-stars {
  font-size: 20px;
  letter-spacing: 3px;
  color: #facc15;
}

.level-card .lc-stars.none {
  color: #64748b;
}

.level-card .lc-lock {
  font-size: 12px;
  color: #fca5a5;
}

.howto-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.howto-body td {
  padding: 5px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.howto-body kbd {
  display: inline-block;
  min-width: 22px;
  padding: 2px 6px;
  margin-right: 3px;
  font-family: inherit;
  font-size: 12px;
  color: #0f172a;
  background: #e2e8f0;
  border-radius: 4px;
  text-align: center;
}

.howto-body .help-goal {
  margin-top: 12px;
  color: #cbd5e1;
  font-size: 14px;
}

/* ---------- Indikator rapat video (Level 2) ---------- */
#meeting-badge {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #fff;
  background: rgba(185, 28, 28, 0.9);
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  z-index: 6;
}

#meeting-badge.active {
  display: flex;
}

#meeting-badge .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #fff;
  animation: meeting-blink 1s ease-in-out infinite;
}

@keyframes meeting-blink {
  50% {
    opacity: 0.2;
  }
}

/* ---------- Kustomisasi & Pengaturan ---------- */
.lobby-panel.side {
  width: min(360px, 90vw);
  max-height: 90vh;
  overflow-y: auto;
  padding: 18px 18px 16px;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
}

.panel-bank {
  font-size: 13px;
  color: #cbd5e1;
}

.panel-bank b {
  color: #facc15;
}

.tabs {
  display: flex;
  gap: 6px;
}

.tab,
.seg-btn {
  flex: 1;
  padding: 7px 10px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  color: #cbd5e1;
  background: rgba(51, 65, 85, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  cursor: pointer;
}

.tab.active,
.seg-btn.active {
  color: #0f172a;
  background: #facc15;
  border-color: #facc15;
}

.item-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.item-card {
  display: grid;
  grid-template-columns: 26px 1fr;
  grid-template-rows: auto auto;
  column-gap: 8px;
  align-items: center;
  padding: 8px;
  text-align: left;
  font: inherit;
  color: #f8fafc;
  background: rgba(51, 65, 85, 0.85);
  border: 2px solid transparent;
  border-radius: 9px;
  cursor: pointer;
}

.item-card.focus {
  border-color: #facc15;
}

.item-card.locked .item-label {
  color: #cbd5e1;
}

.item-card .swatch {
  grid-row: 1 / 3;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
}

.item-card .swatch.tabby {
  background-image: repeating-linear-gradient(90deg, transparent 0 4px, var(--pat) 4px 7px) !important;
}

.item-card .swatch.calico {
  background-image: radial-gradient(circle at 30% 35%, var(--pat) 0 6px, transparent 7px),
    radial-gradient(circle at 70% 70%, var(--pat2) 0 6px, transparent 7px) !important;
}

.item-label {
  font-size: 13px;
  font-weight: 700;
}

.item-price {
  font-size: 11px;
  color: #facc15;
}

.item-card.locked .item-price {
  color: #fca5a5;
}

.item-detail {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 38px;
  font-size: 13px;
  color: #cbd5e1;
}

.item-detail b {
  font-size: 15px;
  color: #f8fafc;
}

.setting {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: #e2e8f0;
}

.setting b {
  color: #facc15;
  margin-left: 4px;
}

.setting.check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.setting input[type='range'] {
  width: 100%;
  accent-color: #facc15;
}

.setting input[type='checkbox'] {
  width: 16px;
  height: 16px;
  accent-color: #facc15;
}

.seg {
  display: flex;
  gap: 6px;
}

.btn.danger {
  color: #fff;
  background: #b91c1c;
  border-color: #b91c1c;
}

.btn.danger:hover:not(:disabled) {
  background: #dc2626;
}

.confirm {
  display: none;
  padding: 12px;
  font-size: 13px;
  color: #fecaca;
  background: rgba(127, 29, 29, 0.55);
  border: 1px solid #ef4444;
  border-radius: 10px;
}

.confirm.active {
  display: block;
}

.confirm .btn-row {
  margin-top: 10px;
}

/* Penghitung FPS (Pengaturan → Tampilkan FPS) */
#fps-counter {
  position: fixed;
  top: 8px;
  right: 10px;
  display: none;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 700;
  color: #86efac;
  background: rgba(15, 23, 42, 0.7);
  border-radius: 6px;
  pointer-events: none;
  z-index: 20;
}

body.show-fps #fps-counter {
  display: block;
}

body.show-fps.mode-lobby #fps-counter {
  top: 54px;
}

/* ---------- Latihan (tutorial) ---------- */
#tutorial-box {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  flex-direction: column;
  gap: 4px;
  width: min(460px, 86vw);
  padding: 10px 14px 12px;
  background: rgba(15, 23, 42, 0.86);
  border: 1px solid rgba(250, 204, 21, 0.55);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  z-index: 7;
}

#tutorial-box.active {
  display: flex;
}

#tutorial-box .tb-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #94a3b8;
}

#tutorial-box .tb-skip {
  padding: 2px 8px;
  font: inherit;
  font-size: 11px;
  color: #cbd5e1;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
}

#tutorial-box b {
  font-size: 17px;
  color: #facc15;
}

#tutorial-box p {
  font-size: 14px;
  color: #e2e8f0;
}

#tutorial-done {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(10, 15, 28, 0.7);
  backdrop-filter: blur(4px);
  z-index: 10;
}

#tutorial-done.active {
  display: flex;
}

#pause-skip {
  display: none;
}

body.mode-tutorial #pause-skip {
  display: block;
}

/* Latihan: tanpa timer & target */
body.mode-tutorial #timer-text,
body.mode-tutorial .chaos-row,
body.mode-tutorial #chaos-meter,
body.mode-lobby #tutorial-box {
  display: none !important;
}

.btn-row.left {
  justify-content: flex-start;
}

.level-card .lc-done {
  font-size: 13px;
  color: #4ade80;
}

/* ---------- Petir (Level 3): hitung mundur ke guntur ---------- */
#storm-badge {
  position: fixed;
  top: 12px;
  right: 14px;
  display: none;
  padding: 5px 12px;
  font-size: 15px;
  font-weight: 800;
  color: #fde047;
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid rgba(253, 224, 71, 0.5);
  border-radius: 999px;
  pointer-events: none;
  z-index: 6;
}

#storm-badge.active {
  display: block;
}

#storm-badge.thunder {
  color: #0f172a;
  background: #fde047;
  animation: meeting-blink 0.5s ease-in-out infinite;
}

body.mode-lobby #storm-badge {
  display: none !important;
}

/* ---------- Malam (Level 4): meter terbangun Zzz → mata terbuka ---------- */
#wake-badge {
  --wake: 0;
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(147, 197, 253, 0.45);
  border-radius: 999px;
  pointer-events: none;
  z-index: 6;
}

#wake-badge.active {
  display: flex;
}

#wake-badge .zzz {
  font-size: 15px;
  font-weight: 800;
  font-style: italic;
  color: #93c5fd;
  opacity: calc(1 - var(--wake));
}

#wake-badge .eye-open {
  font-size: 16px;
  opacity: var(--wake);
}

#wake-badge .wake-bar {
  width: 70px;
  height: 6px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
  overflow: hidden;
}

#wake-badge .wake-fill {
  display: block;
  height: 100%;
  width: calc(var(--wake) * 100%);
  background: linear-gradient(90deg, #60a5fa, #f87171);
}

#wake-badge.awake {
  border-color: #f87171;
  animation: meeting-blink 1s ease-in-out infinite;
}

body.mode-lobby #wake-badge {
  display: none !important;
}

/* ---------- Tamu (Level 5) ---------- */
#visit-banner {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  padding: 7px 16px;
  font-size: 15px;
  font-weight: 800;
  color: #0f172a;
  background: #fde68a;
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  pointer-events: none;
  z-index: 6;
}

#visit-banner span {
  margin-left: 8px;
  font-size: 12px;
  font-weight: 600;
  opacity: 0.7;
}

#visit-banner.active {
  display: block;
}

body.mode-lobby #visit-banner {
  display: none !important;
}

/* Balon teks NPC ("Pus, pus!") */
.float-text.speech {
  padding: 4px 10px;
  font-size: 15px;
  color: #1f2937;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
  text-shadow: none;
}

/* --- Level Bonus: kartu khusus, ikon urutan ruangan, angka Chaos berkurang --- */
.level-card.bonus {
  background: linear-gradient(135deg, rgba(120, 72, 10, 0.92), rgba(51, 65, 85, 0.92));
  border: 1px solid rgba(250, 204, 21, 0.75);
  box-shadow: 0 0 14px rgba(250, 204, 21, 0.25);
}

.level-card.bonus .lc-num {
  color: #facc15;
  font-weight: 800;
}

body.mode-lobby #clean-rooms {
  display: none;
}

#clean-rooms {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  gap: 6px;
  align-items: center;
  padding: 5px 10px;
  background: rgba(15, 23, 42, 0.62);
  border-radius: 999px;
  pointer-events: none;
  font-size: 13px;
  color: #e2e8f0;
}

#clean-rooms.active {
  display: flex;
}

#clean-rooms .cr-icon {
  position: relative;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  font-size: 17px;
  border-radius: 50%;
  background: rgba(51, 65, 85, 0.7);
  opacity: 0.55;
  overflow: hidden;
}

#clean-rooms .cr-icon.next {
  opacity: 0.85;
  outline: 1px dashed rgba(250, 204, 21, 0.7);
}

#clean-rooms .cr-icon.now {
  opacity: 1;
  background: rgba(250, 204, 21, 0.3);
  outline: 2px solid #facc15;
}

#clean-rooms .cr-icon.now::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: calc(var(--left, 1) * 100%);
  background: #facc15;
}

#clean-rooms .cr-label {
  margin-left: 4px;
  font-weight: 700;
}

.float-text.penalty {
  color: #ef4444;
  font-size: 22px;
  font-weight: 900;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.55);
}

/* ---------- Pengaturan: tab & bagian (Fase 9) ---------- */
.seg.tabs {
  flex-wrap: wrap;
}

.set-section {
  display: none;
  flex-direction: column;
  gap: 10px;
}

.set-section.active {
  display: flex;
}

/* Pemberitahuan singkat (hud.toast) */
#toast {
  position: fixed;
  top: 64px;
  left: 50%;
  transform: translate(-50%, -8px);
  padding: 8px 16px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.9);
  color: #f8fafc;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 40;
}

#toast.active {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- Kontrol sentuh (HP & tablet, Fase 9.4) ---------- */
.touch-only {
  display: none;
}

body.touch .touch-only {
  display: revert;
}

body.touch table.touch-only {
  display: table;
}

body.touch .kbd-only {
  display: none !important;
}

#touch-ui {
  display: none;
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 7;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

body.touch.mode-play #touch-ui {
  display: block;
}

body.touch #interact-prompt {
  display: none !important;
}

body.touch #game-canvas {
  touch-action: none;
}

.touch-stick {
  position: fixed;
  width: 112px;
  height: 112px;
  margin: -56px 0 0 -56px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.35);
  opacity: 0;
  transition: opacity 0.15s;
}

.touch-stick.active {
  opacity: 1;
}

.touch-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(250, 204, 21, 0.85);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  transform: translate(-50%, -50%);
}

.touch-btn {
  position: fixed;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.35);
  color: #f8fafc;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  pointer-events: auto;
  touch-action: none;
}

.touch-btn small {
  font-size: 9px;
  font-weight: 600;
  margin-top: 3px;
  opacity: 0.9;
}

.touch-btn.down,
.touch-btn.on {
  background: rgba(250, 204, 21, 0.75);
  color: #1f2937;
  border-color: #facc15;
}

/* Gugus tombol kanan bawah (jempol kanan) */
.touch-btn.jump {
  right: calc(18px + env(safe-area-inset-right));
  bottom: calc(22px + env(safe-area-inset-bottom));
  width: 78px;
  height: 78px;
}

.touch-btn.interact {
  right: calc(106px + env(safe-area-inset-right));
  bottom: calc(34px + env(safe-area-inset-bottom));
  width: 72px;
  height: 72px;
  border-color: rgba(250, 204, 21, 0.8);
}

.touch-btn.interact.idle {
  opacity: 0.45;
}

.touch-btn.interact .e-label {
  max-width: 88px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: absolute;
  bottom: -16px;
  color: #facc15;
  font-size: 10px;
  text-shadow: 0 1px 2px #000;
}

.touch-btn.interact.hold::after {
  content: 'tahan';
  position: absolute;
  top: -14px;
  font-size: 9px;
  color: #fde68a;
}

.touch-btn.run {
  right: calc(26px + env(safe-area-inset-right));
  bottom: calc(112px + env(safe-area-inset-bottom));
}

.touch-btn.sneak {
  right: calc(104px + env(safe-area-inset-right));
  bottom: calc(124px + env(safe-area-inset-bottom));
  width: 54px;
  height: 54px;
}

.touch-btn.meow {
  right: calc(188px + env(safe-area-inset-right));
  bottom: calc(20px + env(safe-area-inset-bottom));
  width: 52px;
  height: 52px;
}

.touch-btn.pause {
  right: calc(12px + env(safe-area-inset-right));
  top: calc(10px + env(safe-area-inset-top));
  width: 44px;
  height: 44px;
  font-size: 18px;
}

body.touch #visit-banner {
  pointer-events: auto;
}

/* Anjuran lanskap (HP dalam posisi potret saat bermain) */
#rotate-hint {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(15, 23, 42, 0.92);
  color: #f8fafc;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}

#rotate-hint .rotate-icon {
  font-size: 54px;
  margin-bottom: 12px;
}

#rotate-hint .btn {
  margin: 0 auto;
}

#rotate-hint p {
  font-size: 17px;
  margin-bottom: 18px;
}

@media (orientation: portrait) {
  body.touch.mode-play:not(.portrait-ok) #rotate-hint {
    display: flex;
  }
}

/* Layar kecil (HP lanskap / potret): HUD & panel menyesuaikan */
@media (max-height: 480px), (max-width: 640px) {
  #hud {
    top: calc(6px + env(safe-area-inset-top));
    left: calc(6px + env(safe-area-inset-left));
    transform: scale(0.9);
    transform-origin: top left;
  }

  .lobby-panel.side,
  .lobby-panel.wide {
    max-height: 92vh;
    padding: 12px 14px;
  }

  .lobby-panel {
    left: 4vw;
  }

  .lobby-panel.wide {
    width: calc(100vw - 4vw - 170px); /* sisakan tempat untuk label tabungan */
  }

  #help-overlay .help-panel {
    max-height: 90vh;
    overflow-y: auto;
  }

  #toast {
    top: 12px;
  }
}

#help-overlay.active {
  pointer-events: auto; /* ketuk untuk menutup */
}

/* ---------- Rebind tombol (Pengaturan → Kontrol) ---------- */
.rebind {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rebind-row {
  display: grid;
  grid-template-columns: 1fr 72px 72px;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  color: #cbd5e1;
}

.rebind-key {
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: #1e293b;
  color: #f8fafc;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.rebind-key.alt {
  color: #94a3b8;
}

.rebind-key.waiting {
  border-color: #facc15;
  color: #facc15;
}

.rebind-note {
  display: block;
  font-size: 11px;
  color: #94a3b8;
}

.btn.small {
  padding: 6px 10px;
  font-size: 12px;
}

/* ---------- Aksesibilitas (Fase 9.5) ---------- */
/* Ukuran teks HUD */
body.hud-small #hud {
  transform: scale(0.85);
  transform-origin: top left;
}

body.hud-large #hud {
  transform: scale(1.3);
  transform-origin: top left;
}

body.hud-large #interact-prompt,
body.hud-large #toast,
body.hud-large #tutorial-box {
  font-size: 18px;
}

body.hud-large #owner-indicator .oi-icon {
  font-size: 44px;
}

/* Kurangi kilat & efek berkedip: animasi kedip/denyut dimatikan */
body.reduce-flash #owner-indicator .oi-icon.alarm,
body.reduce-flash #meeting-badge .dot,
body.reduce-flash #storm-badge.thunder,
body.reduce-flash #wake-badge.awake {
  animation: none !important;
}

body.reduce-flash #zoomies-overlay {
  animation: none;
}

/* Ramah buta warna: biru ↔ oranye (bukan hijau ↔ merah) + bentuk */
body.colorblind #hud .hide-eye.closed {
  color: #60a5fa;
}

body.colorblind #hud .hide-eye.half {
  color: #fde68a;
}

body.colorblind #hud .hide-eye.open {
  color: #fb923c;
  border-width: 2.5px;
}

body.colorblind #owner-indicator .oi-icon.curious {
  color: #7dd3fc;
}

body.colorblind #owner-indicator .oi-icon.alarm {
  color: #fb923c;
  background: rgba(15, 23, 42, 0.75);
  border: 3px solid #fb923c;
  border-radius: 8px;
  padding: 0 10px;
}

body.colorblind #owner-indicator .oi-fill {
  background: linear-gradient(90deg, #7dd3fc, #fb923c);
}

body.colorblind .chaos-fill {
  background: linear-gradient(90deg, #60a5fa, #fb923c) !important;
}
