/* =====================================================================
   GALAXY NOVA - Gaya Tampilan
   ===================================================================== */

:root {
  --bg-0:      #04060f;
  --bg-1:      #0a0f22;
  --bg-2:      #111938;
  --panel:     rgba(14, 21, 46, 0.82);
  --panel-br:  rgba(83, 230, 255, 0.22);
  --cyan:      #53e6ff;
  --cyan-dim:  #2e93ad;
  --mint:      #64ffda;
  --pink:      #ff3d7f;
  --amber:     #ffc93c;
  --purple:    #9d7bff;
  --text:      #dbe6ff;
  --text-dim:  #8194bd;
  --danger:    #ff5a5a;
}

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

html, body { height: 100%; }

body {
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: radial-gradient(ellipse at 20% 0%, #16214a 0%, var(--bg-0) 55%),
              radial-gradient(ellipse at 90% 90%, #3a1140 0%, transparent 60%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Bintang latar halaman non-game */
body.starry::before {
  content: "";
  position: fixed; inset: 0;
  background-image:
    radial-gradient(1px 1px at 10% 20%, #fff, transparent),
    radial-gradient(1px 1px at 80% 30%, #cfe6ff, transparent),
    radial-gradient(1px 1px at 35% 70%, #fff, transparent),
    radial-gradient(2px 2px at 60% 15%, #ffd9a0, transparent),
    radial-gradient(1px 1px at 90% 80%, #fff, transparent),
    radial-gradient(1px 1px at 25% 45%, #a9c8ff, transparent),
    radial-gradient(1px 1px at 70% 60%, #fff, transparent);
  opacity: 0.55;
  pointer-events: none;
  z-index: 0;
  animation: twinkle 6s ease-in-out infinite alternate;
}
@keyframes twinkle { from { opacity: 0.35; } to { opacity: 0.7; } }

a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap {
  position: relative; z-index: 1;
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 18px 60px;
}

/* ---------------- Header ---------------- */
.topbar {
  position: relative; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 14px 22px;
  background: var(--panel);
  border-bottom: 1px solid var(--panel-br);
  backdrop-filter: blur(8px);
}

.brand {
  display: flex; align-items: center; gap: 12px;
  font-weight: 800; font-size: 20px; letter-spacing: 2px;
  color: #fff; text-transform: uppercase;
}
.brand .dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #a8f4ff, var(--cyan) 45%, #0b5b73);
  box-shadow: 0 0 14px var(--cyan);
}
.brand span.nova { color: var(--cyan); }

.nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.nav a {
  padding: 8px 14px; border-radius: 8px; font-size: 14px;
  color: var(--text-dim); border: 1px solid transparent;
  transition: all .18s ease;
}
.nav a:hover, .nav a.active {
  color: #fff; border-color: var(--panel-br);
  background: rgba(83,230,255,.08); text-decoration: none;
}

.userchip {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px 6px 6px;
  background: rgba(83,230,255,.07);
  border: 1px solid var(--panel-br);
  border-radius: 30px; font-size: 14px;
}
.userchip img { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--cyan-dim); }

/* ---------------- Tombol ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 12px 24px; border-radius: 10px; border: none; cursor: pointer;
  font-size: 15px; font-weight: 600; font-family: inherit;
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease;
  text-decoration: none;
}
.btn:hover { transform: translateY(-2px); text-decoration: none; }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: linear-gradient(135deg, var(--cyan), #2a7fd4);
  color: #04121c; box-shadow: 0 6px 22px rgba(83,230,255,.32);
}
.btn-primary:hover { box-shadow: 0 10px 30px rgba(83,230,255,.45); }

.btn-ghost {
  background: rgba(255,255,255,.05); color: var(--text);
  border: 1px solid var(--panel-br);
}
.btn-ghost:hover { background: rgba(83,230,255,.12); }

.btn-google {
  background: #fff; color: #3c4043; font-weight: 600;
  box-shadow: 0 6px 22px rgba(255,255,255,.18);
}
.btn-google svg { width: 20px; height: 20px; }

.btn-danger { background: linear-gradient(135deg, #ff5a5a, #b4243f); color: #fff; }

.btn-block { width: 100%; }

/* ---------------- Kartu / panel ---------------- */
.card {
  background: var(--panel);
  border: 1px solid var(--panel-br);
  border-radius: 16px;
  padding: 24px;
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 40px rgba(0,0,0,.35);
}
.card + .card { margin-top: 18px; }

.card h2, .card h3 {
  font-size: 17px; letter-spacing: 1.4px; text-transform: uppercase;
  color: var(--cyan); margin-bottom: 16px; font-weight: 700;
}

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

/* ---------------- Statistik ---------------- */
.stat {
  background: rgba(255,255,255,.035);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 12px; padding: 16px; text-align: center;
}
.stat .val {
  font-size: 26px; font-weight: 800; color: #fff; line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.stat .lbl {
  font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--text-dim); margin-top: 6px;
}
.stat.cyan   .val { color: var(--cyan); }
.stat.mint   .val { color: var(--mint); }
.stat.pink   .val { color: var(--pink); }
.stat.amber  .val { color: var(--amber); }
.stat.purple .val { color: var(--purple); }

/* ---------------- Tabel ---------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 520px; }
th {
  text-align: left; padding: 12px 14px;
  font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--text-dim); border-bottom: 1px solid var(--panel-br);
  white-space: nowrap;
}
td { padding: 12px 14px; border-bottom: 1px solid rgba(255,255,255,.05); }
tbody tr:hover { background: rgba(83,230,255,.05); }
tbody tr.me { background: rgba(100,255,218,.10); }
tbody tr.me td { color: #fff; font-weight: 600; }

.pos {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255,255,255,.07); font-weight: 700; font-size: 13px;
}
.pos.p1 { background: linear-gradient(135deg,#ffd700,#b8860b); color:#241a00; }
.pos.p2 { background: linear-gradient(135deg,#e2e8f0,#94a3b8); color:#1a1f2b; }
.pos.p3 { background: linear-gradient(135deg,#d19a66,#8b5a2b); color:#241300; }

.pilot { display: flex; align-items: center; gap: 10px; }
.pilot img { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--cyan-dim); }
.avatar-fallback {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--cyan-dim), #55338a);
  color: #fff; font-weight: 700; font-size: 13px;
}

/* ---------------- Tab ---------------- */
.tabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.tab {
  padding: 9px 18px; border-radius: 8px; cursor: pointer; font-size: 14px;
  background: rgba(255,255,255,.04); border: 1px solid transparent;
  color: var(--text-dim); transition: all .18s;
}
.tab:hover { color: #fff; }
.tab.active { background: rgba(83,230,255,.14); border-color: var(--panel-br); color: var(--cyan); }

/* ---------------- Lencana ---------------- */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap: 12px; }
.badge {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px; border-radius: 10px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.06);
  opacity: .4; transition: all .2s;
}
.badge.on {
  opacity: 1; border-color: rgba(255,201,60,.4);
  background: rgba(255,201,60,.08);
}
.badge .ic {
  flex: 0 0 34px; width: 34px; height: 34px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.07); font-weight: 800; color: var(--amber);
}
.badge.on .ic { background: linear-gradient(135deg, var(--amber), #b47a00); color: #241a00; }
.badge .t { font-size: 13px; font-weight: 700; color: #fff; }
.badge .d { font-size: 11px; color: var(--text-dim); margin-top: 3px; line-height: 1.4; }

/* =====================================================================
   HALAMAN GAME
   ===================================================================== */
body.game-page { overflow: hidden; }

#stage {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh;
  background: #03050f;
}
#stage canvas { display: block; width: 100% !important; height: 100% !important; }

/* --- HUD --- */
.hud {
  position: fixed; inset: 0; pointer-events: none; z-index: 10;
  font-variant-numeric: tabular-nums;
}

.hud-top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; padding: 14px 18px; flex-wrap: wrap;
  background: linear-gradient(180deg, rgba(4,6,15,.85), transparent);
}

.hud-group { display: flex; gap: 10px; flex-wrap: wrap; }

.hud-box {
  background: rgba(10,16,36,.72);
  border: 1px solid var(--panel-br);
  border-radius: 10px; padding: 8px 14px; min-width: 82px;
  backdrop-filter: blur(6px);
}
.hud-box .k {
  font-size: 9.5px; letter-spacing: 1.4px; text-transform: uppercase;
  color: var(--text-dim);
}
.hud-box .v { font-size: 21px; font-weight: 800; color: #fff; line-height: 1.2; }
.hud-box.score .v  { color: var(--cyan); }
.hud-box.level .v  { color: var(--amber); }
.hud-box.lives .v  { color: var(--pink); }
.hud-box.shield .v { color: var(--mint); }
.hud-box.combo .v  { color: var(--purple); }

.bar {
  height: 4px; border-radius: 3px; margin-top: 6px;
  background: rgba(255,255,255,.10); overflow: hidden;
}
.bar i { display: block; height: 100%; width: 0; border-radius: 3px; transition: width .25s ease; }
.bar.lv i { background: linear-gradient(90deg, var(--amber), #ff8a3c); }
.bar.wp i { background: linear-gradient(90deg, var(--mint), var(--cyan)); }

/* Pemberitahuan tengah layar */
#notice {
  position: absolute; top: 22%; left: 50%; transform: translateX(-50%);
  padding: 10px 26px; border-radius: 30px;
  background: rgba(10,16,36,.85); border: 1px solid var(--panel-br);
  color: var(--cyan); font-size: 15px; font-weight: 700; letter-spacing: 1px;
  white-space: nowrap; opacity: 0; transition: opacity .3s;
  text-shadow: 0 0 14px rgba(83,230,255,.6);
}
#notice.show { opacity: 1; }

/* Petunjuk kontrol */
.hud-help {
  position: absolute; bottom: 14px; left: 18px;
  font-size: 11.5px; color: var(--text-dim); line-height: 1.7;
  background: rgba(10,16,36,.6); border: 1px solid rgba(255,255,255,.06);
  padding: 9px 14px; border-radius: 9px;
}
.hud-help kbd {
  background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.16);
  border-radius: 4px; padding: 1px 6px; font-size: 10.5px; color: #fff;
  font-family: inherit;
}

/* --- Overlay (mulai / jeda / selesai) --- */
.overlay {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(3,5,15,.86); backdrop-filter: blur(6px);
  padding: 20px;
}
.overlay.hidden { display: none; }

.overlay-card {
  background: var(--panel); border: 1px solid var(--panel-br);
  border-radius: 18px; padding: 34px; max-width: 620px; width: 100%;
  text-align: center; box-shadow: 0 20px 70px rgba(0,0,0,.6);
  max-height: 92vh; overflow-y: auto;
}
.overlay-card h1 {
  font-size: 30px; letter-spacing: 3px; text-transform: uppercase;
  margin-bottom: 8px; color: #fff;
}
.overlay-card h1 em { font-style: normal; color: var(--cyan); }
.overlay-card p.sub { color: var(--text-dim); font-size: 14px; margin-bottom: 22px; line-height: 1.65; }

.legend { display: grid; grid-template-columns: repeat(auto-fit,minmax(150px,1fr)); gap: 10px; margin: 18px 0 6px; text-align: left; }
.legend div {
  font-size: 12px; color: var(--text-dim);
  padding: 9px 12px; border-radius: 8px;
  background: rgba(255,255,255,.035); border-left: 3px solid var(--cyan);
  line-height: 1.5;
}
.legend div b { color: #fff; display: block; font-size: 12.5px; margin-bottom: 2px; }
.legend div.mint   { border-left-color: var(--mint); }
.legend div.pink   { border-left-color: var(--pink); }
.legend div.amber  { border-left-color: var(--amber); }
.legend div.purple { border-left-color: var(--purple); }

.result-grid {
  display: grid; grid-template-columns: repeat(auto-fit,minmax(105px,1fr));
  gap: 10px; margin: 20px 0;
}
.result-grid .stat { padding: 12px 8px; }
.result-grid .stat .val { font-size: 20px; }

.overlay .actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }

.newhigh {
  display: inline-block; margin-bottom: 14px;
  padding: 7px 20px; border-radius: 30px;
  background: linear-gradient(135deg, var(--amber), #ff8a3c);
  color: #241a00; font-weight: 800; font-size: 13px; letter-spacing: 1.5px;
  animation: pop 1.6s ease-in-out infinite;
}
@keyframes pop { 0%,100%{transform:scale(1);} 50%{transform:scale(1.06);} }

.unlocked-list { margin: 14px 0; display: flex; flex-direction: column; gap: 8px; }
.unlocked-list div {
  background: rgba(255,201,60,.10); border: 1px solid rgba(255,201,60,.35);
  border-radius: 9px; padding: 10px 14px; font-size: 13px; color: var(--amber);
  text-align: left;
}

.save-status { font-size: 12.5px; margin-top: 12px; min-height: 18px; color: var(--text-dim); }
.save-status.ok   { color: var(--mint); }
.save-status.err  { color: var(--danger); }

/* ---------------- Halaman depan (login) ---------------- */
.hero { text-align: center; padding: 40px 0 26px; position: relative; z-index: 1; }
.hero h1 {
  font-size: clamp(34px, 7vw, 62px); letter-spacing: 5px;
  text-transform: uppercase; color: #fff; line-height: 1.05;
  text-shadow: 0 0 40px rgba(83,230,255,.35);
}
.hero h1 em { font-style: normal; color: var(--cyan); }
.hero .tag {
  color: var(--text-dim); margin-top: 14px; font-size: 16px;
  max-width: 620px; margin-left: auto; margin-right: auto; line-height: 1.7;
}

.alert {
  padding: 13px 18px; border-radius: 10px; font-size: 14px; margin-bottom: 18px;
  border: 1px solid; line-height: 1.6;
}
.alert-err  { background: rgba(255,90,90,.10);  border-color: rgba(255,90,90,.4);  color: #ffb3b3; }
.alert-warn { background: rgba(255,201,60,.10); border-color: rgba(255,201,60,.4); color: #ffe4a0; }
.alert-ok   { background: rgba(100,255,218,.10);border-color: rgba(100,255,218,.4);color: #9dffe8; }

.feature-list { list-style: none; text-align: left; }
.feature-list li {
  padding: 9px 0 9px 26px; position: relative; font-size: 14px;
  color: var(--text-dim); line-height: 1.6;
}
.feature-list li::before {
  content: "▸"; position: absolute; left: 6px; color: var(--cyan); font-size: 13px;
}
.feature-list li b { color: var(--text); }

.footer {
  text-align: center; padding: 30px 18px; color: var(--text-dim);
  font-size: 12.5px; position: relative; z-index: 1; line-height: 1.8;
}

.empty {
  text-align: center; padding: 40px 20px; color: var(--text-dim); font-size: 14px;
}

/* ---------------- Responsif ---------------- */
@media (max-width: 720px) {
  .hud-box { min-width: 66px; padding: 6px 10px; }
  .hud-box .v { font-size: 17px; }
  .hud-help { display: none; }
  .overlay-card { padding: 24px 18px; }
  .topbar { padding: 12px 14px; }
  .brand { font-size: 17px; }
}

@media (hover: none) and (pointer: coarse) {
  .touch-only { display: block !important; }
}
.touch-only { display: none; }

/* =====================================================================
   PWA: banner install, notifikasi, indikator offline
   ===================================================================== */

.gn-install {
  position: fixed; left: 50%; bottom: 18px; z-index: 9000;
  transform: translate(-50%, 130%);
  display: flex; align-items: center; gap: 14px;
  width: calc(100% - 28px); max-width: 520px;
  padding: 14px 16px;
  background: rgba(12, 19, 42, .96);
  border: 1px solid var(--panel-br);
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .55);
  backdrop-filter: blur(10px);
  transition: transform .38s cubic-bezier(.22, 1, .36, 1), opacity .3s;
  opacity: 0;
}
.gn-install.show { transform: translate(-50%, 0); opacity: 1; }

.gn-install-icon {
  flex: 0 0 52px; width: 52px; height: 52px; border-radius: 13px;
  box-shadow: 0 4px 16px rgba(83, 230, 255, .3);
}

.gn-install-body { flex: 1; min-width: 0; }
.gn-install-title {
  font-size: 15px; font-weight: 800; color: #fff; letter-spacing: .3px;
}
.gn-install-desc {
  font-size: 12.5px; color: var(--text-dim); line-height: 1.5; margin-top: 3px;
}

.gn-install-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.gn-install-btn { padding: 10px 18px; font-size: 13.5px; border-radius: 9px; }

.gn-install-close {
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
  background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .10);
  color: var(--text-dim); font-size: 19px; line-height: 1;
  font-family: inherit; transition: all .18s;
}
.gn-install-close:hover { background: rgba(255, 255, 255, .13); color: #fff; }

/* Varian iOS: panah menunjuk ke tombol Bagikan di bawah layar */
.gn-install-ios::after {
  content: ""; position: absolute; bottom: -9px; left: 50%;
  width: 16px; height: 16px; transform: translateX(-50%) rotate(45deg);
  background: rgba(12, 19, 42, .96);
  border-right: 1px solid var(--panel-br);
  border-bottom: 1px solid var(--panel-br);
}

/* --- Notifikasi kecil --- */
.gn-toast {
  position: fixed; left: 50%; bottom: 18px; z-index: 9100;
  transform: translate(-50%, 130%); opacity: 0;
  display: flex; align-items: center; gap: 14px;
  max-width: calc(100% - 28px);
  padding: 13px 18px; border-radius: 12px;
  background: rgba(12, 19, 42, .96);
  border: 1px solid var(--panel-br);
  color: var(--text); font-size: 13.5px; line-height: 1.5;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .5);
  backdrop-filter: blur(10px);
  transition: transform .35s cubic-bezier(.22, 1, .36, 1), opacity .3s;
}
.gn-toast.show { transform: translate(-50%, 0); opacity: 1; }
.gn-toast.ok   { border-color: rgba(100, 255, 218, .45); color: #9dffe8; }
.gn-toast.info { border-color: rgba(83, 230, 255, .45); }
.gn-toast.err  { border-color: rgba(255, 90, 90, .45); color: #ffb3b3; }

.gn-toast-btn {
  flex: 0 0 auto; cursor: pointer; font-family: inherit;
  padding: 7px 14px; border-radius: 8px; font-size: 12px; font-weight: 700;
  letter-spacing: .6px; border: none;
  background: linear-gradient(135deg, var(--cyan), #2a7fd4); color: #04121c;
}

/* --- Pita offline --- */
.gn-offline {
  position: fixed; top: 0; left: 0; right: 0; z-index: 9200;
  transform: translateY(-100%); opacity: 0;
  padding: 8px 16px; text-align: center;
  background: linear-gradient(135deg, #b4243f, #7a1028);
  color: #fff; font-size: 12.5px; font-weight: 600; letter-spacing: .4px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .4);
  transition: transform .32s ease, opacity .3s;
}
.gn-offline.show { transform: translateY(0); opacity: 1; }

/* Saat aplikasi berjalan sebagai PWA terpasang */
@media (display-mode: standalone), (display-mode: fullscreen) {
  .gn-install { display: none !important; }
  .topbar { padding-top: max(14px, env(safe-area-inset-top)); }
  .hud-top { padding-top: max(14px, env(safe-area-inset-top)); }
}

@media (max-width: 560px) {
  .gn-install { flex-wrap: wrap; gap: 10px; padding: 13px; }
  .gn-install-body { flex: 1 1 100%; order: 2; }
  .gn-install-icon { order: 1; }
  .gn-install-actions { order: 1; margin-left: auto; }
  .gn-install-desc { font-size: 12px; }
}
