:root { --accent: #ffd34a; --accent2: #ff8a3d; --gold: #ffd36b; --ink: #1d2236; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #6cbf55; color: #fff;
  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; header/footer nổi lên trên; #wrap chỉ để đo vùng chơi */
#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; min-width: 0; font-weight: 900; font-size: 17px; letter-spacing: .3px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; pointer-events: none; text-shadow: 0 2px 0 rgba(0, 0, 0, .25);
}
.brand span { color: #fff; }
.hud { display: flex; gap: 5px; pointer-events: none; }
.chip {
  background: rgba(20, 28, 48, .72); border: 1px solid rgba(255, 255, 255, .18); border-radius: 999px;
  padding: 5px 10px; font-size: 13px; font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .18);
}
.chip.score { color: var(--gold); }
.chip.warn { background: #e8384f; animation: pulse .5s ease-in-out infinite alternate; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.08); } }
header button {
  background: rgba(20, 28, 48, .72); color: #fff; border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 10px; padding: 7px 9px; font-size: 14px; line-height: 1;
}
header button:hover { background: rgba(40, 52, 84, .85); }
@media (max-width: 560px) { .brand span { display: none; } .brand { flex: 0 0 auto; } .hud { flex: 1; justify-content: center; } }
@media (max-width: 360px) { .chip { padding: 4px 7px; font-size: 12px; } }

#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: 8px;
  padding: 6px 10px; padding-bottom: calc(8px + env(safe-area-inset-bottom));
  pointer-events: none;
}
.boost {
  pointer-events: auto; position: relative; display: flex; flex-direction: column; align-items: center; gap: 1px;
  min-width: 76px; padding: 6px 10px 5px; border-radius: 14px; color: var(--ink);
  background: linear-gradient(180deg, #fffaf0, #ffe7b8); border: none;
  box-shadow: 0 4px 0 #d39a3a, 0 6px 12px rgba(0, 0, 0, .22); transition: transform .08s, filter .15s;
}
.boost:active { transform: translateY(3px); box-shadow: 0 1px 0 #d39a3a, 0 3px 8px rgba(0, 0, 0, .2); }
.boost .ic { font-size: 20px; line-height: 1.1; }
.boost .nm { font-size: 11.5px; font-weight: 800; white-space: nowrap; }
.boost .cnt {
  position: absolute; top: -6px; right: -6px; min-width: 21px; height: 21px; border-radius: 11px; padding: 0 5px;
  background: #e8384f; color: #fff; font-size: 12px; line-height: 21px; box-shadow: 0 2px 4px rgba(0, 0, 0, .3);
}
.boost.empty { filter: grayscale(1) brightness(.85); opacity: .75; }
.boost.empty .cnt { background: #7a8296; }

.toast {
  position: fixed; left: 50%; top: calc(56px + env(safe-area-inset-top)); z-index: 5; transform: translate(-50%, -12px);
  background: rgba(20, 26, 44, .9); color: #fff; padding: 8px 16px; border-radius: 999px; font-size: 14px; font-weight: 700;
  max-width: calc(100% - 24px); text-align: center; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .3);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.overlay {
  position: fixed; inset: 0; background: rgba(10, 22, 38, .5); display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 10; backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.panel {
  background: linear-gradient(165deg, rgba(36, 58, 104, .97), rgba(18, 28, 56, .97));
  border: 1px solid rgba(255, 220, 140, .3); border-radius: 20px; padding: 22px 24px;
  max-width: 440px; width: 100%; max-height: 100%; overflow: auto; text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5), 0 0 40px rgba(255, 190, 80, .15);
  animation: pop .28s cubic-bezier(.2, 1.4, .4, 1);
}
@keyframes pop { from { transform: scale(.88); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.panel h1 {
  margin: 0 0 8px; font-size: 27px;
  background: linear-gradient(90deg, #ffe27a, #ff9d4d); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.gnx-btn {
  display: inline-block; margin-top: 10px; background: rgba(255, 255, 255, .1); color: #fff; border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 10px; padding: 8px 14px; font-size: 14px; font-weight: 700;
}
#ov-text { line-height: 1.5; opacity: .95; margin: 8px 0; font-size: 15px; }
#ov-text p { margin: 6px 0; }
.panel kbd {
  display: inline-block; min-width: 22px; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .25);
  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: 340px; }
.keys > span:nth-child(odd) { text-align: right; white-space: nowrap; }
.keys > span:nth-child(even) { opacity: .85; }
.rec { color: var(--gold); 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: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .14); border-radius: 10px; padding: 4px 12px; min-width: 76px; text-align: center; }
.stat .label { display: block; font-size: 10px; opacity: .72; text-transform: uppercase; letter-spacing: .5px; }
.stat b { font-size: 16px; color: var(--accent); }
.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #2a1400; border: none; border-radius: 12px;
  padding: 12px 30px; font-size: 17px; font-weight: 800; margin-top: 6px; box-shadow: 0 6px 20px rgba(255, 150, 60, .38);
}
.primary:hover { filter: brightness(1.07); }
.linkbtn { background: none; border: none; color: #c9d6ff; text-decoration: underline; font-size: 14px; padding: 4px 8px; opacity: .85; }
.linkbtn:hover { opacity: 1; color: #fff; }
.stars { display: flex; justify-content: center; gap: 6px; margin: 4px 0 8px; font-size: 44px; line-height: 1; }
.stars span { color: rgba(255, 255, 255, .26); text-shadow: 0 3px 0 rgba(0, 0, 0, .25); transform: scale(0); animation: star .45s cubic-bezier(.2, 1.6, .4, 1) forwards; }
.stars span.on { color: #ffd34a; text-shadow: 0 0 18px rgba(255, 200, 60, .7), 0 3px 0 #c98a12; }
@keyframes star { to { transform: scale(1); } }
.hidden { display: none !important; }
