:root {
  --bg: #09070d;
  --panel: rgba(21, 14, 28, 0.92);
  --panel2: rgba(34, 21, 43, 0.92);
  --line: rgba(255, 150, 50, 0.24);
  --text: #f7efe5;
  --muted: #d6c8b9;
  --orange: #ff8f1f;
  --orange2: #ffbd60;
  --green: #88ff69;
  --purple: #a880ff;
  --danger: #ff4c4c;
  --shadow: 0 18px 38px rgba(0, 0, 0, 0.45);
  --radius: 22px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 6%, rgba(255, 143, 31, 0.12), transparent 24%),
    radial-gradient(circle at 88% 0%, rgba(168, 128, 255, 0.13), transparent 28%),
    linear-gradient(180deg, #130d1a 0%, #09070d 56%, #050408 100%);
  overflow-x: hidden;
  touch-action: manipulation;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
.game-topbar {
  min-height: 68px;
  padding: 10px clamp(12px, 3vw, 28px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(6, 5, 9, 0.82);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; color: var(--orange2); }
.brand img { width: 42px; height: 42px; object-fit: contain; }
.quick-nav { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.quick-nav a {
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  color: #f8ead8;
  font-size: 0.95rem;
}
.game-page { width: min(1320px, calc(100% - 24px)); margin: 0 auto; padding: 18px 0 28px; }
.intro-panel, .help-strip {
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.intro-panel {
  padding: 22px;
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.eyebrow {
  display: inline-flex;
  padding: 8px 12px;
  border-radius: 999px;
  color: #eadfff;
  background: rgba(168, 128, 255, .13);
  border: 1px solid rgba(168, 128, 255, .2);
  font-weight: 800;
  font-size: .92rem;
}
h1 { margin: 10px 0 6px; font-size: clamp(2rem, 4vw, 3.8rem); line-height: 1; color: var(--orange2); }
p { color: var(--muted); line-height: 1.55; margin: 0; }
.intro-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.primary-btn, .ghost-btn {
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 16px;
  padding: 14px 18px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(0,0,0,.25);
}
.primary-btn { background: linear-gradient(180deg, #ffad43, #ff7b18); color: #1d1107; }
.ghost-btn { background: rgba(255,255,255,0.05); color: var(--text); }
.game-shell {
  background: linear-gradient(180deg, rgba(18,13,24,.96), rgba(9,7,13,.96));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}
.hud {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.hud div {
  padding: 10px 12px;
  background: rgba(255,255,255,.045);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 14px;
}
.hud span { display: block; font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.hud strong { display: block; font-size: clamp(1rem, 2.4vw, 1.6rem); color: #fff7e6; margin-top: 3px; }
.canvas-wrap {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.1);
  background: #05060b;
}
#gameCanvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  background: #05060b;
}
.game-message {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: rgba(4, 4, 7, 0.45);
  padding: 16px;
}
.game-message.hidden { display: none; }
.message-card {
  width: min(520px, 92%);
  padding: 24px;
  text-align: center;
  border-radius: 22px;
  background: rgba(10, 8, 14, .86);
  border: 1px solid rgba(255, 177, 73, .3);
  box-shadow: 0 24px 50px rgba(0,0,0,.45);
}
.message-card h2 { margin: 0 0 10px; color: var(--orange2); font-size: clamp(1.8rem, 4vw, 3rem); }
.message-card .small { margin-top: 12px; font-size: .95rem; color: #c9b9aa; }
.touch-controls {
  display: grid;
  grid-template-columns: 1fr 1fr 2fr 1fr;
  gap: 10px;
  margin-top: 12px;
}
.touch-btn {
  min-height: 70px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 18px;
  color: #fff8e9;
  background: linear-gradient(180deg, rgba(255,255,255,.13), rgba(255,255,255,.04));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 10px 20px rgba(0,0,0,.25);
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: 900;
  cursor: pointer;
  user-select: none;
  touch-action: none;
}
.touch-btn:active, .touch-btn.pressed { transform: translateY(2px); background: linear-gradient(180deg, rgba(255,143,31,.35), rgba(255,143,31,.12)); }
.touch-btn.beam { font-size: clamp(1rem, 3vw, 1.65rem); color: #13200f; background: linear-gradient(180deg, #b8ff83, #77e553); }
.touch-btn.small-touch { font-size: clamp(.86rem, 2.5vw, 1.15rem); }
.help-strip {
  margin-top: 16px;
  padding: 14px 18px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  color: var(--muted);
}
.help-strip strong { color: var(--orange2); }
@media (max-width: 900px) {
  .intro-panel { align-items: flex-start; flex-direction: column; }
  .intro-actions { justify-content: flex-start; }
  .hud { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .help-strip { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .quick-nav { display: none; }
  .game-page { width: min(100% - 14px, 1320px); padding-top: 10px; }
  .intro-panel { padding: 16px; }
  .game-shell { padding: 10px; }
  .touch-controls { grid-template-columns: 1fr 1fr; }
  .touch-btn.beam, .touch-btn.small-touch { grid-column: span 2; }
  .touch-btn { min-height: 62px; }
}
@media (orientation: landscape) and (max-height: 620px) {
  .game-topbar { min-height: 52px; padding: 6px 14px; }
  .brand img { width: 34px; height: 34px; }
  .intro-panel { display: none; }
  .game-page { padding: 8px 0; }
  .hud { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; margin-bottom: 8px; }
  .hud div { padding: 7px 9px; }
  .touch-controls { grid-template-columns: 1fr 1fr 2.4fr 1fr; gap: 8px; margin-top: 8px; }
  .touch-btn { min-height: 50px; }
  .help-strip { display: none; }
}
