:root { --accent: #ffd25a; --accent2: #ff7a59; --gold: #ffd36b; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #ffe6cc; color: #4a2412;
  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, nằm dưới header; #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: .3px; white-space: nowrap; pointer-events: none;
  overflow: hidden; text-overflow: ellipsis;
}
.brand span {
  background: linear-gradient(90deg, #2f9e44, #e8364a); -webkit-background-clip: text; background-clip: text; color: transparent;
}
header button {
  background: rgba(255, 255, 255, .6); color: #5a2a12; border: 1px solid rgba(120, 60, 20, .18);
  border-radius: 10px; padding: 7px 10px; font-size: 14px; line-height: 1; box-shadow: 0 2px 6px rgba(120, 60, 20, .12);
}
header button:hover { background: rgba(255, 255, 255, .85); }

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

.overlay {
  position: fixed; inset: 0; background: rgba(70, 30, 10, .42); 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(160deg, rgba(98, 44, 30, .97), rgba(50, 20, 26, .97)); color: #fff3e6;
  border: 1px solid rgba(255, 210, 160, .25); 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(60, 20, 0, .5), 0 0 40px rgba(255, 150, 90, .18);
}
.panel h1 {
  margin: 0 0 8px; font-size: 27px;
  background: linear-gradient(90deg, #b6f27a, #ffd36b, #ff8a9a); -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: 320px; }
.keys > span:nth-child(odd) { text-align: right; white-space: nowrap; }
.keys > span:nth-child(even) { opacity: .85; }
.legend {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px 2px; margin: 10px 0 4px;
  background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .1); border-radius: 12px; padding: 8px 4px;
}
.legend span { display: flex; flex-direction: column; align-items: center; font-size: 11px; line-height: 1.2; opacity: .92; }
.legend img { width: 34px; height: 34px; display: block; margin-bottom: 2px; }
.legend .arrow { font-size: 15px; justify-content: center; opacity: .5; }
.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, .13); 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(--gold); }
.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #3a1300; border: none; border-radius: 12px;
  padding: 12px 30px; font-size: 17px; font-weight: 800; margin-top: 6px; box-shadow: 0 6px 20px rgba(255, 120, 70, .38);
}
.primary:hover { filter: brightness(1.08); }
.linkbtn {
  background: none; border: none; color: #ffd9b8; text-decoration: underline; font-size: 14px; padding: 4px 8px; opacity: .85;
}
.linkbtn:hover { opacity: 1; color: #fff; }
.hidden { display: none !important; }
@media (max-width: 380px) {
  .legend { grid-template-columns: repeat(4, 1fr); }
  .panel { padding: 18px 14px; }
}
