:root { --ink: #3b2a6b; --accent: #ff7eb6; --accent2: #8f7bff; --gold: #ffb627; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #f3e9ff; color: var(--ink);
  font-family: system-ui, "Segoe UI", Roboto, sans-serif; touch-action: none; user-select: none; -webkit-user-select: none;
  overscroll-behavior: none;
}
button { font-family: inherit; cursor: pointer; }
body { display: flex; flex-direction: column; }

/* canvas phủ toàn màn hình; #wrap chỉ để đo vùng chơi giữa header và thanh trợ giúp */
#board { position: fixed; inset: 0; display: block; z-index: 0; touch-action: none; }

header {
  position: relative; z-index: 2; flex: none;
  display: flex; align-items: center; gap: 6px; padding: 6px 10px;
  padding-top: calc(6px + env(safe-area-inset-top));
  padding-left: calc(10px + env(safe-area-inset-left)); padding-right: calc(10px + env(safe-area-inset-right));
  pointer-events: none;
}
header > * { pointer-events: auto; }
.brand { flex: 1; font-weight: 900; font-size: 17px; letter-spacing: .3px; white-space: nowrap; pointer-events: none; min-width: 0; overflow: hidden; }
.brand span { background: linear-gradient(90deg, #ff5fa2, #7b61ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.pill {
  pointer-events: none; background: rgba(255, 255, 255, .72); border: 1px solid rgba(140, 110, 220, .25);
  border-radius: 999px; padding: 5px 11px; font-size: 13px; font-weight: 800; white-space: nowrap;
  box-shadow: 0 2px 8px rgba(110, 70, 180, .12);
}
.pill.score { color: #7b3fe4; min-width: 54px; text-align: center; transition: transform .15s; }
.pill.score.bump { transform: scale(1.12); }
header button {
  background: rgba(255, 255, 255, .75); color: var(--ink); border: 1px solid rgba(140, 110, 220, .25);
  border-radius: 10px; padding: 7px 10px; font-size: 14px; line-height: 1; box-shadow: 0 2px 8px rgba(110, 70, 180, .12);
}
header button:hover { background: #fff; }

#wrap {
  flex: 1; min-height: 0; pointer-events: none;
  margin: 0 env(safe-area-inset-right) 0 env(safe-area-inset-left);
}

#boosters {
  position: relative; z-index: 2; flex: none; display: flex; justify-content: center; gap: 10px;
  padding: 6px 10px; padding-bottom: calc(8px + env(safe-area-inset-bottom));
  pointer-events: none;
}
.booster {
  pointer-events: auto; position: relative; display: flex; align-items: center; gap: 6px;
  background: linear-gradient(180deg, #ffffff, #f1e8ff); color: var(--ink);
  border: 1px solid rgba(140, 110, 220, .3); border-radius: 14px; padding: 8px 14px 8px 10px;
  font-size: 14px; font-weight: 800; box-shadow: 0 4px 0 rgba(130, 100, 200, .25), 0 6px 14px rgba(110, 70, 180, .15);
  transition: transform .08s, box-shadow .08s, opacity .2s;
}
.booster:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(130, 100, 200, .25), 0 3px 8px rgba(110, 70, 180, .15); }
.booster .ic { font-size: 18px; line-height: 1; }
.booster .ct {
  position: absolute; top: -7px; right: -7px; min-width: 20px; height: 20px; border-radius: 10px; padding: 0 5px;
  background: linear-gradient(180deg, #ff6f9f, #ff3d7f); color: #fff; font-size: 12px; line-height: 20px; text-align: center;
  box-shadow: 0 2px 4px rgba(200, 40, 100, .35);
}
.booster:disabled { opacity: .45; cursor: default; }
.booster:disabled .ct { background: #b9adcf; box-shadow: none; }
.booster.active { background: linear-gradient(180deg, #ffe08a, #ffc13b); border-color: #e6a100; animation: glow 1s ease-in-out infinite alternate; }
@keyframes glow { from { box-shadow: 0 4px 0 #d39200, 0 0 0 rgba(255, 190, 40, .0); } to { box-shadow: 0 4px 0 #d39200, 0 0 18px rgba(255, 190, 40, .8); } }
@media (max-width: 380px) { .booster { padding: 7px 10px 7px 8px; font-size: 13px; } #boosters { gap: 7px; } .pill { padding: 4px 8px; } }

.overlay {
  position: fixed; inset: 0; background: rgba(70, 40, 120, .38); display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 10; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  animation: ovIn .25s ease-out;
}
@keyframes ovIn { from { opacity: 0; } to { opacity: 1; } }
.panel {
  background: linear-gradient(170deg, #fffdfd, #f6efff); color: var(--ink);
  border: 1px solid rgba(160, 130, 240, .35); border-radius: 22px; padding: 22px 24px;
  max-width: 420px; width: 100%; max-height: 100%; overflow: auto; text-align: center;
  box-shadow: 0 24px 60px rgba(70, 30, 140, .35), inset 0 1px 0 #fff;
  animation: panelIn .32s cubic-bezier(.2, 1.4, .4, 1);
}
@keyframes panelIn { from { transform: translateY(14px) scale(.94); opacity: 0; } to { transform: none; opacity: 1; } }
.panel h1 { margin: 0 0 8px; font-size: 28px; color: #7b3fe4; }
.panel h1 .t { background: linear-gradient(90deg, #ff5fa2, #7b61ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.gnx-btn {
  display: inline-block; margin-top: 10px; background: rgba(123, 97, 255, .1); color: var(--ink); border: 1px solid rgba(123, 97, 255, .3);
  border-radius: 10px; padding: 8px 14px; font-size: 14px; font-weight: 700;
}
/* leaderboard.js mặc định cho nền tối – chỉnh lại trong bảng sáng của game này */
.panel .gnx-btn, .panel .gnx-result button {
  background: rgba(123, 97, 255, .1); color: var(--ink); border: 1px solid rgba(123, 97, 255, .3);
}
.panel .gnx-btn:hover, .panel .gnx-result button:hover { background: rgba(123, 97, 255, .18); }
.panel .gnx-result { background: #fff7e8; border-color: rgba(230, 160, 40, .45); color: var(--ink); }
.panel .gnx-result b { color: #c26a00; }
.panel .gnx-result input { background: #fff; color: var(--ink); border-color: rgba(123, 97, 255, .35); }
.panel .gnx-result input:focus { border-color: #ff9f43; }
.panel .gnx-result button.gnx-send { background: linear-gradient(135deg, #ffd36b, #ff9f43); color: #201300; border: none; }
.panel .gnx-result button.gnx-share { background: linear-gradient(135deg, #ff6a88, #ff9f43); color: #fff; border: none; }
.panel .gnx-result .gnx-edit { background: none; border: none; }
.panel .gnx-result .gnx-chip { background: rgba(123, 97, 255, .08); border-color: rgba(123, 97, 255, .25); }
#ov-text { line-height: 1.5; margin: 8px 0; font-size: 15px; }
#ov-text p { margin: 6px 0; }
.panel kbd {
  display: inline-block; min-width: 22px; background: #fff; border: 1px solid rgba(100, 80, 160, .3);
  border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; font-size: 12px; line-height: 18px; font-family: inherit;
}
.keys { display: grid; grid-template-columns: auto 1fr; gap: 5px 10px; text-align: left; font-size: 13px; margin: 10px auto 2px; max-width: 320px; }
.keys > span:nth-child(odd) { text-align: right; white-space: nowrap; }
.keys > span:nth-child(even) { opacity: .85; }
.rec { color: #e08a00; font-weight: 800; }
#ov-stats { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 10px 0; }
#ov-stats:empty { display: none; }
.stat { background: #fff; border: 1px solid rgba(140, 110, 220, .22); border-radius: 12px; padding: 4px 12px; min-width: 72px; text-align: center; }
.stat .label { display: block; font-size: 10px; opacity: .7; text-transform: uppercase; letter-spacing: .5px; }
.stat b { font-size: 16px; color: #7b3fe4; }
.primary {
  background: linear-gradient(135deg, #ff7eb6, #8f7bff); color: #fff; border: none; border-radius: 14px;
  padding: 12px 30px; font-size: 17px; font-weight: 800; margin-top: 6px; box-shadow: 0 6px 0 #6a4fd8, 0 10px 22px rgba(120, 80, 230, .35);
  text-shadow: 0 1px 2px rgba(60, 20, 120, .35);
}
.primary:hover { filter: brightness(1.06); }
.primary:active { transform: translateY(3px); box-shadow: 0 3px 0 #6a4fd8, 0 6px 14px rgba(120, 80, 230, .35); }
.linkbtn {
  background: none; border: none; color: #6b55c9; text-decoration: underline; font-size: 14px; padding: 4px 8px; opacity: .85;
}
.linkbtn:hover { opacity: 1; }
.hidden { display: none !important; }
