:root { --accent: #6fe3ff; --accent2: #a97bff; --gold: #ffd36b; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #05061a; color: #e8eeff;
  font-family: system-ui, "Segoe UI", Roboto, sans-serif; touch-action: none; user-select: none; -webkit-user-select: none;
}
button { font-family: inherit; cursor: pointer; }
body { display: flex; flex-direction: column; }

/* canvas phủ toàn màn hình, nằm dưới header / nút bấm; #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: 8px; 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: .4px; white-space: nowrap; }
.brand span { background: linear-gradient(90deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
header button {
  background: rgba(255, 255, 255, .07); color: #fff; border: 1px solid rgba(255, 255, 255, .15);
  border-radius: 10px; padding: 7px 10px; font-size: 14px; line-height: 1;
}
header button:hover { background: rgba(255, 255, 255, .14); }

#wrap { flex: 1; min-height: 0; pointer-events: none; }

#pad {
  display: none; position: relative; z-index: 2; flex: none; gap: 6px;
  padding: 6px calc(8px + env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left));
}
#pad button {
  flex: 1; min-width: 0; height: 58px; border-radius: 14px; padding: 0;
  border: 1px solid rgba(160, 180, 255, .2); background: rgba(20, 26, 60, .55); color: #e8eeff;
  display: flex; align-items: center; justify-content: center; touch-action: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08); transition: transform .06s, background .06s;
}
#pad button.on { background: rgba(111, 227, 255, .3); border-color: rgba(111, 227, 255, .7); transform: scale(.95); }
#pad svg { width: 26px; height: 26px; pointer-events: none; }
#pad .txt { font-weight: 900; font-size: 14px; letter-spacing: .5px; }
@media (pointer: coarse) { #pad { display: flex; } }

.overlay {
  position: fixed; inset: 0; background: rgba(3, 4, 18, .66); display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 10; backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
.panel {
  background: linear-gradient(160deg, rgba(22, 24, 62, .96), rgba(10, 12, 34, .96));
  border: 1px solid rgba(150, 170, 255, .2); border-radius: 18px; padding: 22px 24px;
  max-width: 460px; width: 100%; max-height: 100%; overflow: auto; text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .6), 0 0 40px rgba(111, 140, 255, .15);
}
.panel h1 { margin: 0 0 8px; font-size: 28px; color: var(--accent); text-shadow: 0 0 18px rgba(111, 227, 255, .35); }
.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: .92; 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: 330px; }
.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, .06); border: 1px solid rgba(255, 255, 255, .12); border-radius: 10px; 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: var(--accent); }
.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #0a0a2a; border: none; border-radius: 12px;
  padding: 12px 30px; font-size: 17px; font-weight: 800; margin-top: 6px; box-shadow: 0 6px 20px rgba(111, 160, 255, .35);
}
.primary:hover { filter: brightness(1.08); }
.hidden { display: none !important; }
