:root {
  --bg: #07111f;
  --bg-soft: rgba(13, 24, 40, 0.82);
  --line: rgba(255,255,255,0.08);
  --text: #eaf2ff;
  --muted: #96a6c2;
  --primary: #f59e0b;
  --primary-strong: #d97706;
  --shadow: 0 20px 60px rgba(0,0,0,0.35);
}
* { box-sizing: border-box; margin: 0; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
html, body { min-height: 100%; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--text); overflow-x: hidden;
  background:
    radial-gradient(circle at top left, rgba(245,158,11,.18), transparent 30%),
    radial-gradient(circle at top right, rgba(251,113,133,.14), transparent 25%),
    linear-gradient(135deg, #040814 0%, #07111f 45%, #0a1626 100%);
}
.mobile-only { display: none; }

/* Desktop */
.app-shell { max-width: 1100px; margin: 0 auto; padding: 20px 16px 32px; }
.hero, .panel, .board-panel {
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  background: var(--bg-soft); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.hero { border-radius: 24px; padding: 22px; display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 20px; }
.eyebrow { margin: 0 0 8px; color: var(--primary); font-weight: 700; text-transform: uppercase; letter-spacing: .18em; font-size: 12px; }
h1 { font-size: clamp(28px, 3.5vw, 44px); line-height: 1.05; }
.subtitle { margin: 10px 0 0; color: var(--muted); font-size: 15px; line-height: 1.7; }
.stats-card { min-width: 220px; display: grid; gap: 10px; }
.stat { border: 1px solid var(--line); border-radius: 18px; padding: 12px 14px; background: rgba(255,255,255,.03); }
.stat span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.stat strong { font-size: 24px; }
.game-layout { display: grid; grid-template-columns: minmax(0,1fr) 260px; gap: 20px; }
.board-panel, .panel { border-radius: 24px; }
.board-panel { padding: 18px; position: relative; overflow: hidden; }
.board-topbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.status-pill { display: inline-flex; align-items: center; padding: 8px 14px; border-radius: 999px; background: rgba(245,158,11,.15); color: #fef3c7; border: 1px solid rgba(245,158,11,.18); font-size: 14px; }
.powerups-bar { display: flex; gap: 10px; }
.pu { display: inline-flex; align-items: center; gap: 4px; padding: 6px 10px; border-radius: 999px; font-size: 13px; background: rgba(255,255,255,.04); border: 1px solid var(--line); }
.pu strong { font-weight: 800; }
.actions { display: flex; gap: 8px; }
.btn { border: 0; border-radius: 14px; padding: 10px 14px; font-size: 14px; font-weight: 700; cursor: pointer; }
.btn.primary { background: linear-gradient(135deg, var(--primary), var(--primary-strong)); color: #1c0a00; }
.btn.secondary { background: rgba(255,255,255,.08); color: var(--text); border: 1px solid var(--line); }
.btn.large { width: 100%; padding: 14px 18px; font-size: 16px; }
.board-stage { position: relative; }
.board-wrap { position: relative; border-radius: 16px; overflow: hidden; border: 1px solid rgba(255,255,255,.08); box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 12px 30px rgba(0,0,0,.25); }
#game { display: block; width: 100%; max-width: 480px; margin: 0 auto; aspect-ratio: 1/1; background: #1a1a2e; touch-action: none; }
.overlay { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(3,8,16,.65); padding: 20px; z-index: 10; }
.overlay.visible { display: flex; }
.overlay-card { width: min(100%, 320px); background: rgba(7,17,31,.94); border: 1px solid var(--line); border-radius: 20px; padding: 20px; text-align: center; box-shadow: var(--shadow); }
.overlay-card h2 { margin: 0 0 10px; font-size: 22px; }
.overlay-card p { margin: 0 0 16px; color: var(--muted); line-height: 1.6; font-size: 14px; }
.sidebar { display: grid; gap: 18px; align-content: start; }
.panel { padding: 18px; background: linear-gradient(180deg, rgba(12,22,36,.88), rgba(8,16,28,.92)); border-radius: 24px; }
.panel h3 { margin-top: 0; margin-bottom: 12px; font-size: 16px; }
.panel ul { margin: 0; padding-left: 18px; color: var(--muted); line-height: 1.8; font-size: 14px; }
/* ctrl-area: hidden on desktop, shown on mobile via media query below */

/* Tablet */
@media (max-width: 920px) {
  .game-layout { grid-template-columns: 1fr; }
  .stats-card { grid-template-columns: repeat(3, 1fr); min-width: 0; }
  .hero { flex-direction: column; }
}

/* ===== Mobile ===== */
@media (max-width: 720px) {
  .desktop-only { display: none !important; }
  .mobile-only { display: flex !important; }
  html, body { height: 100dvh; overflow: hidden; }
  .app-shell { height: 100dvh; padding: 0; display: flex; flex-direction: column; overflow: hidden; }

  /* Top bar */
  .mobile-bar { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; background: var(--bg-soft); border-bottom: 1px solid var(--line); flex-shrink: 0; }
  .mobile-title { font-weight: 800; font-size: 15px; color: var(--primary); }
  .mobile-stats { display: flex; gap: 10px; }
  .m-stat { text-align: center; }
  .m-stat span { display: block; font-size: 9px; color: var(--muted); margin-bottom: 1px; }
  .m-stat strong { font-size: 14px; font-weight: 800; }
  .btn-icon { border: 0; background: rgba(255,255,255,.08); color: var(--text); width: 34px; height: 34px; border-radius: 10px; font-size: 16px; cursor: pointer; }
  .mobile-bar-right { display: flex; gap: 6px; }

  /* Layout */
  .game-layout { display: flex; flex-direction: column; flex: 1; min-height: 0; padding: 6px; gap: 0; }
  .board-panel { display: flex; flex-direction: column; flex: 1; min-height: 0; padding: 0; border-radius: 0; background: none; border: 0; box-shadow: none; backdrop-filter: none; }
  .board-stage { flex: 1; min-height: 0; display: flex; }
  .board-wrap { flex: 1; min-height: 0; display: flex; justify-content: center; align-items: center; border-radius: 10px; }
  #game { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }

  /* Control area: dpad left, bomb right */
  .ctrl-area {
    display: flex !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 30px;
    flex-shrink: 0;
    padding: 10px 16px 16px;
    background: var(--bg-soft);
    border-top: 1px solid var(--line);
  }

  /* D-pad: simple cross layout using absolute positioning for reliability */
  .dpad-wrap {
    position: relative;
    width: 160px;
    height: 160px;
    flex-shrink: 0;
  }

  .d-btn {
    position: absolute;
    width: 52px; height: 52px;
    border: 1.5px solid rgba(255,255,255,.15);
    background: rgba(255,255,255,.07);
    color: var(--text);
    border-radius: 14px;
    font-size: 20px; font-weight: 800;
    display: flex; align-items: center; justify-content: center;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
  }
  .d-btn.active {
    background: rgba(245,158,11,.3);
    border-color: rgba(245,158,11,.5);
  }

  /* Position each button in the cross */
  .d-up    { top: 0;   left: 50%; transform: translateX(-50%); }
  .d-down  { bottom: 0; left: 50%; transform: translateX(-50%); }
  .d-left  { left: 0;  top: 50%; transform: translateY(-50%); }
  .d-right { right: 0; top: 50%; transform: translateY(-50%); }

  /* Bomb button */
  .bomb-fab {
    width: 80px; height: 80px;
    border-radius: 50%;
    border: 2.5px solid rgba(245,158,11,.4);
    background: rgba(245,158,11,.12);
    font-size: 36px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 4px 16px rgba(245,158,11,.15);
  }
  .bomb-fab:active, .bomb-fab.active {
    background: rgba(245,158,11,.35);
    transform: scale(0.93);
  }
}

/* Small phones */
@media (max-width: 380px) {
  .dpad-wrap { width: 136px; height: 136px; }
  .d-btn { width: 44px; height: 44px; font-size: 17px; border-radius: 12px; }
  .bomb-fab { width: 68px; height: 68px; font-size: 30px; }
  .ctrl-area { gap: 20px; padding: 8px 10px 12px; }
}
