:root {
  --bg: #070b14;
  --panel: rgba(13, 19, 34, 0.92);
  --panel-border: rgba(102, 224, 255, 0.22);
  --text: #eef6ff;
  --muted: #8ea4c8;
  --accent: #00f0ff;
  --accent-2: #39ff14;
  --gold: #ffbe0b;
  --danger: #ff3b5c;
  --radius: 16px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: fixed;
  inset: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  scrollbar-width: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar,
.panel::-webkit-scrollbar,
.catalog-list::-webkit-scrollbar {
  display: none;
}

:fullscreen,
:-webkit-full-screen {
  width: 100% !important;
  height: 100% !important;
  background: var(--bg) !important;
}

#appRoot {
  position: fixed;
  inset: 0;
  width: 100vw;
  width: 100dvw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  background: #070b14;
}

.hidden {
  display: none !important;
}

/* HUD Minimalis Saat Bermain - Tidak Menghalangi Layar & Tanpa Tombol Kontrol */
.hud {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
  z-index: 10;
}

.hud-left,
.hud-right {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hud-right {
  align-items: flex-end;
}

.hud-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding-top: 2px;
}

.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(7, 11, 20, 0.56);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(6px);
  padding: 5px 11px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

.hud-compact {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--muted);
}

.hud-main {
  font-size: 16px;
  font-weight: 900;
  color: #ffffff;
}

.hud-sub {
  font-size: 10px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.8px;
}

.dot {
  opacity: 0.45;
}

.rank-badge {
  color: var(--gold);
  font-weight: 900;
  font-size: 12px;
}

.coin-txt {
  color: var(--gold);
}

.hud-banner {
  background: rgba(0, 240, 255, 0.14);
  border: 1px solid rgba(0, 240, 255, 0.45);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 999px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

.boss-bar-wrap {
  width: min(240px, 44vw);
  background: rgba(7, 11, 20, 0.72);
  border: 1px solid rgba(255, 59, 92, 0.45);
  border-radius: 10px;
  padding: 4px 8px;
}

.boss-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  font-weight: 800;
  color: #ff9eb0;
  margin-bottom: 3px;
}

.boss-bar-track {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 99px;
  overflow: hidden;
}

.boss-bar-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #ff3b5c, #ffbe0b);
  transition: width 0.08s linear;
}

.net-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(7, 11, 20, 0.6);
  border: 1px solid rgba(57, 255, 20, 0.35);
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}

.ping-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 8px var(--accent-2);
}

.btn-pause {
  pointer-events: auto;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(7, 11, 20, 0.65);
  color: #ffffff;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.btn-pause:active {
  transform: scale(0.92);
}

/* Petunjuk Tap Awal */
.tap-cue {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: max(28px, env(safe-area-inset-bottom));
  z-index: 9;
}

.tap-cue-ring {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  animation: pulseRing 1.1s infinite ease-out;
  margin-bottom: 8px;
}

.tap-cue-text {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #dff8ff;
  background: rgba(7, 11, 20, 0.65);
  padding: 5px 14px;
  border-radius: 999px;
  border: 1px solid rgba(0, 240, 255, 0.35);
}

@keyframes pulseRing {
  0% { transform: scale(0.75); opacity: 0.95; }
  100% { transform: scale(1.45); opacity: 0; }
}

/* Overlay & Panel */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 8, 16, 0.72);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  z-index: 20;
  overflow-y: auto;
}

.panel {
  width: min(680px, 100%);
  max-height: 94dvh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.65);
}

.compact-panel {
  width: min(400px, 100%);
  text-align: center;
}

.modal-panel {
  width: min(560px, 100%);
}

.menu-header {
  text-align: center;
  margin-bottom: 14px;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-bottom: 8px;
}

.badge {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.7px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text);
}

.badge.accent {
  background: rgba(0, 240, 255, 0.15);
  border-color: rgba(0, 240, 255, 0.5);
  color: var(--accent);
}

.game-title {
  margin: 0;
  font-size: clamp(22px, 4.8vw, 32px);
  font-weight: 900;
  letter-spacing: 0.6px;
}

.game-title span {
  color: var(--accent);
}

.game-subtitle {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.stat-box,
.res-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 8px;
  text-align: center;
}

.stat-lbl {
  display: block;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.7px;
  color: var(--muted);
  margin-bottom: 2px;
}

.stat-box strong,
.res-card strong {
  font-size: 15px;
  font-weight: 900;
  color: #ffffff;
}

.section-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 8px;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.mode-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 9px 8px;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.mode-card:active {
  transform: scale(0.98);
}

.mode-card.active {
  background: rgba(0, 240, 255, 0.12);
  border-color: var(--accent);
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.15);
}

.mode-icon {
  font-size: 16px;
}

.mode-name {
  font-size: 12px;
  font-weight: 800;
}

.mode-desc {
  font-size: 10px;
  color: var(--muted);
  line-height: 1.25;
}

.quick-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.quick-item label,
.form-row label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 4px;
}

select,
input[type="text"],
input[type="search"],
input[type="url"],
textarea {
  width: 100%;
  background: rgba(6, 10, 18, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 12px;
  outline: none;
}

select:focus,
input:focus,
textarea:focus {
  border-color: var(--accent);
}

.seed-row {
  display: flex;
  gap: 6px;
}

.btn-mini {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--text);
  border-radius: 10px;
  padding: 0 11px;
  font-weight: 800;
  cursor: pointer;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, #00e1ff, #0088ff);
  color: #03101d;
  border: none;
  border-radius: 14px;
  padding: 13px 16px;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.5px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  box-shadow: 0 10px 28px rgba(0, 210, 255, 0.28);
}

.btn-primary small {
  font-size: 10px;
  font-weight: 700;
  opacity: 0.85;
}

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

.menu-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.btn-sec,
.btn-danger,
.btn-ghost {
  border-radius: 11px;
  padding: 9px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.btn-danger {
  background: rgba(255, 59, 92, 0.14);
  border-color: rgba(255, 59, 92, 0.45);
  color: #ff9cb0;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.stack-btns {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

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

.analysis-txt,
.muted-txt {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.modal-head h3 {
  margin: 0;
  font-size: 16px;
}

.btn-close {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
}

.form-row {
  margin-bottom: 10px;
}

.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.chk {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
  cursor: pointer;
}

.chk input {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
}

.catalog-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.catalog-list {
  max-height: 46dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
}

.cat-item {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 11px;
}

.cat-item.unlocked {
  border-color: rgba(57, 255, 20, 0.35);
}

.cat-top {
  display: flex;
  justify-content: space-between;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 2px;
}

.sep {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin: 14px 0;
}

.update-toast {
  position: fixed;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: #0d2137;
  border: 1px solid var(--accent);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 999px;
  z-index: 50;
}

@media (max-width: 600px) {
  .mode-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .menu-actions,
  .catalog-tools {
    grid-template-columns: 1fr;
  }
  .panel {
    padding: 14px;
  }
}

/* Mode Paksa Miring Mutlak (Fallback saat browser masih di posisi potret) */
#appRoot.force-landscape {
  position: fixed;
  top: 0;
  left: 100vw;
  width: 100vh;
  width: 100dvh;
  height: 100vw;
  height: 100dvw;
  transform: rotate(90deg);
  transform-origin: top left;
}