/* Curious Realm: The Game */
.crg-game, .crg-root {
  --crg-purple: #7B2FBE;
  position: relative;
  width: 100%;
  margin: 0 auto 1.5em;
  background: #05010c;
  border: 3px solid var(--crg-purple);
  border-radius: 6px;
  box-shadow: 0 0 0 3px #05010c, 0 8px 30px rgba(0, 0, 0, .45);
  overflow: hidden;
  outline: none;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  font-family: "Courier New", Courier, monospace;
  box-sizing: border-box;
}
.crg-root *, .crg-root *::before, .crg-root *::after { box-sizing: border-box; }
.crg-root:focus-visible { box-shadow: 0 0 0 3px #05010c, 0 0 0 6px var(--crg-purple-light, #b98ae0); }
.crg-screen { width: 100%; display: flex; align-items: center; justify-content: center; background: #000; }
.crg-canvas {
  display: block;
  max-width: 100%;
  image-rendering: -moz-crisp-edges;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  -ms-interpolation-mode: nearest-neighbor;
  touch-action: none;
  cursor: pointer;
}

/* Desktop hint bar */
.crg-bar {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 6px;
  padding: 6px 10px; background: #0a0414; color: #c8b8e8; font-size: 12px; line-height: 1.3;
  border-top: 2px solid var(--crg-purple);
}
.crg-bar button, .crg-sm {
  font: bold 11px/1 "Courier New", monospace; letter-spacing: .05em;
  color: #fff; background: var(--crg-purple); border: 2px solid var(--crg-purple-light, #b98ae0);
  border-radius: 4px; padding: 6px 9px; cursor: pointer; margin: 0;
  -webkit-appearance: none; appearance: none; text-transform: uppercase;
}
.crg-bar button:hover { filter: brightness(1.15); }
.crg-has-touch .crg-bar { display: none; }

/* Touch controls */
.crg-touch { display: none; }
.crg-has-touch .crg-touch {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 10px 18px; gap: 6px; background: linear-gradient(#0a0414, #160a2a);
  border-top: 2px solid var(--crg-purple); touch-action: none;
}
.crg-dpad {
  position: relative; width: min(132px, 33vw); height: min(132px, 33vw); flex: 0 0 auto; border-radius: 50%;
  background: radial-gradient(circle, #2a1a40 0 30%, #1a1028 31% 100%);
  border: 3px solid var(--crg-purple); touch-action: none;
}
.crg-arr { position: absolute; width: 0; height: 0; border: 10px solid transparent; opacity: .85; }
.crg-u { top: 8px; left: 50%; margin-left: -10px; border-bottom-color: var(--crg-purple-light, #b98ae0); border-top: 0; }
.crg-d { bottom: 8px; left: 50%; margin-left: -10px; border-top-color: var(--crg-purple-light, #b98ae0); border-bottom: 0; }
.crg-l { left: 8px; top: 50%; margin-top: -10px; border-right-color: var(--crg-purple-light, #b98ae0); border-left: 0; }
.crg-r { right: 8px; top: 50%; margin-top: -10px; border-left-color: var(--crg-purple-light, #b98ae0); border-right: 0; }
.crg-knob {
  position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%;
  background: var(--crg-purple); border: 3px solid var(--crg-purple-light, #b98ae0); pointer-events: none;
  transition: transform .04s linear;
}
.crg-mid { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.crg-sm { padding: 7px 6px; font-size: 10px; min-width: 56px; touch-action: none; }
.crg-ab { display: flex; gap: 10px; align-items: flex-end; flex: 0 0 auto; }
.crg-btn {
  width: 70px; height: 70px; border-radius: 50%; border: 3px solid #05010c;
  font: bold 24px/1 "Courier New", monospace; color: #fff; cursor: pointer; padding: 0; margin: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: 0 4px 0 #05010c; touch-action: none; -webkit-appearance: none; appearance: none;
}
.crg-btn small { font-size: 9px; letter-spacing: .05em; margin-top: 3px; }
.crg-a { background: var(--crg-purple); outline: 3px solid var(--crg-purple-light, #b98ae0); width: min(78px, 19vw); height: min(78px, 19vw); }
.crg-b { background: #3a2a50; outline: 3px solid #6a5a80; margin-bottom: 24px; width: min(62px, 15vw); height: min(62px, 15vw); }
.crg-btn.crg-on, .crg-sm.crg-on { transform: translateY(3px); box-shadow: 0 1px 0 #05010c; filter: brightness(1.25); }

/* Fullscreen (native + pseudo fallback for iPhone) */
.crg-root.crg-fs { border: 0; border-radius: 0; margin: 0; display: flex; flex-direction: column; background: #000; }
.crg-root.crg-pfs { position: fixed !important; inset: 0; top: 0; left: 0; right: 0; bottom: 0; z-index: 2147483000; width: 100vw; height: 100vh; height: 100dvh; max-width: none !important; }
.crg-root.crg-fs .crg-screen { flex: 1 1 auto; }
html.crg-noscroll, html.crg-noscroll body { overflow: hidden !important; }
@media (orientation: landscape) {
  .crg-fs.crg-has-touch .crg-touch {
    position: absolute; left: 0; right: 0; bottom: 0; background: none; border: 0; pointer-events: none; padding: 12px 18px;
  }
  .crg-fs.crg-has-touch .crg-touch > * { pointer-events: auto; opacity: .7; }
  .crg-fs.crg-has-touch .crg-mid { position: absolute; top: 10px; right: 10px; }
  .crg-fs.crg-has-touch .crg-touch { top: 0; align-items: flex-end; }
}
@media (max-width: 360px) {
  .crg-sm { min-width: 48px; font-size: 9px; }
}
