* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg0: #141026;
  --bg1: #241a45;
  --accent: #ffd24a;
  --accent2: #5cf2ff;
  --ink: #f4f1ff;
  --sub: #a99fc9;
}

html, body {
  height: 100%;
  background: linear-gradient(180deg, #2a1f50 0%, var(--bg0) 60%, #0c0a18 100%);
  color: var(--ink);
  font-family: "Press Start 2P", "Quicksand", "Apple SD Gothic Neo", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 44px; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px;
  background: linear-gradient(180deg, rgba(12,10,24,.9), rgba(12,10,24,0));
  font-size: 13px; letter-spacing: .3px; font-weight: 700;
}
.topbar .back { color: var(--accent2); text-decoration: none; opacity: .92; }
.topbar .back:hover { opacity: 1; }
.topbar .brand { color: var(--ink); opacity: .9; font-size: 13px; }
.topbar .hs { color: var(--accent); font-size: 12px; }

#stage {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
}

canvas#game {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #0c0a18;
  box-shadow: 0 18px 50px rgba(0,0,0,.6), 0 0 0 1px rgba(92,242,255,.14);
  border-radius: 12px;
}

.hint {
  position: fixed; bottom: 12px; left: 0; right: 0; text-align: center;
  font-size: 12px; color: var(--sub); z-index: 20; pointer-events: none;
  text-shadow: 0 1px 3px rgba(0,0,0,.7); transition: opacity 1s;
  padding: 0 18px; font-weight: 600;
}

/* ── 모바일 컨트롤 ── */
#pad { display: none; }
@media (pointer: coarse) {
  #pad {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
    justify-content: space-between; align-items: flex-end;
    padding: 16px 18px calc(18px + env(safe-area-inset-bottom));
    pointer-events: none;
  }
  .hint { bottom: 184px; }
  .dpad, .abtn { pointer-events: auto; }
  .dpad { position: relative; width: 174px; height: 174px; }
  .key {
    position: absolute; width: 58px; height: 58px;
    background: rgba(40,32,72,.72); color: #d9d2ff;
    border: 1px solid rgba(124,132,200,.4); border-radius: 14px;
    font-size: 20px; backdrop-filter: blur(4px);
  }
  .key:active { background: rgba(92,242,255,.32); }
  .key.up    { left: 58px; top: 0; }
  .key.left  { left: 0; top: 58px; }
  .key.right { left: 116px; top: 58px; }
  .key.down  { left: 58px; top: 116px; }
  .abtn { display: flex; gap: 14px; align-items: flex-end; }
  .bomb, .det {
    width: 74px; height: 74px; border-radius: 50%;
    border: 1px solid rgba(255,210,74,.5); background: rgba(60,40,30,.72);
    color: #fff; font-size: 30px; backdrop-filter: blur(4px);
  }
  .det { width: 58px; height: 58px; font-size: 22px; border-color: rgba(92,242,255,.5); background: rgba(30,46,60,.72); }
  .bomb:active, .det:active { transform: scale(.94); filter: brightness(1.3); }
}

@media (max-width: 640px) {
  .topbar .brand { display: none; }
}
