:root {
  --ink: #f2ecd9;
  --gold: #e8c05a;
  --panel: rgba(16, 12, 24, 0.72);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #0d0b16;
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
}

#game-root {
  position: fixed;
  inset: 0;
  min-height: 100dvh;
  min-height: 100svh;
  overflow: hidden;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #0d0b16;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* Touch controls */
.touch-layer {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 18px;
  padding-bottom: calc(18px + env(safe-area-inset-bottom));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.touch-layer.visible { opacity: 1; }
.touch-layer .pad {
  display: flex;
  gap: 14px;
  align-items: flex-end;
}
.pad-left { flex-direction: row; }
.pad-right { flex-direction: row; }
.touch-layer .ctl {
  pointer-events: auto;
  width: 64px;
  height: 64px;
  border: 2px solid rgba(242, 236, 217, 0.32);
  background: rgba(16, 12, 24, 0.42);
  color: var(--ink);
  font-size: 26px;
  line-height: 1;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  user-select: none;
}
.touch-layer .ctl:active { background: rgba(232, 192, 90, 0.35); border-color: var(--gold); }
.touch-layer .ctl-main { width: 84px; height: 84px; font-size: 34px; }
.touch-layer .ctl-alt { width: 60px; height: 60px; font-size: 22px; }

/* Overlay screens */
.overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: radial-gradient(circle at 50% 40%, rgba(40, 30, 55, 0.55), rgba(8, 6, 14, 0.94));
  backdrop-filter: blur(3px);
  z-index: 20;
}
.overlay.visible { display: flex; }
.overlay .panel {
  max-width: 560px;
  width: min(92vw, 560px);
  padding: 30px 26px;
  background: var(--panel);
  border: 1px solid rgba(232, 192, 90, 0.35);
}
.overlay h1 {
  margin: 0 0 6px;
  font-size: clamp(30px, 6vw, 52px);
  letter-spacing: 4px;
  color: var(--gold);
  text-shadow: 0 2px 0 #000;
}
.overlay h2 {
  margin: 0 0 12px;
  font-size: 22px;
  letter-spacing: 2px;
  color: var(--ink);
}
.overlay .tag { color: #c9c0a6; font-size: 14px; margin: 0 0 18px; }
.overlay .btn {
  display: inline-block;
  margin: 8px 6px;
  padding: 14px 30px;
  font-size: 18px;
  letter-spacing: 1px;
  color: #1b1420;
  background: var(--gold);
  border: 0;
  cursor: pointer;
  font-weight: 700;
}
.overlay .btn:hover { filter: brightness(1.08); }
.overlay .btn.secondary { background: transparent; color: var(--ink); border: 2px solid rgba(242,236,217,0.5); }
.overlay .legend {
  margin: 18px auto 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 18px;
  text-align: left;
  font-size: 14px;
  color: #d8cfa9;
  max-width: 460px;
}
.overlay .legend b { color: var(--ink); display: inline-block; min-width: 92px; }
.overlay .small { color: #b6ad93; font-size: 13px; margin-top: 16px; }

/* Toast / banner */
.toast {
  position: absolute;
  top: max(18px, calc(18px + env(safe-area-inset-top)));
  left: 50%;
  transform: translateX(-50%) translateY(-14px);
  padding: 10px 22px;
  background: var(--panel);
  border: 1px solid rgba(232, 192, 90, 0.4);
  color: var(--ink);
  font-size: 18px;
  letter-spacing: 1px;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 30;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
