* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: #f4ecd2;
  min-height: 100vh;
  overflow-x: hidden;
  overscroll-behavior: none;
  background:
    radial-gradient(circle at 20% 10%, #234f67 0%, transparent 35%),
    radial-gradient(circle at 80% 20%, #335b7f 0%, transparent 30%),
    linear-gradient(180deg, #0e2235 0%, #122941 100%);
}

.layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}

.panel {
  margin-bottom: 10px;
  padding: 12px 14px;
  border: 1px solid #7f6f49;
  background: rgba(26, 18, 8, 0.65);
  border-radius: 10px;
}

.panel h1 {
  margin: 0 0 8px;
  font-size: 22px;
}

.panel p {
  margin: 4px 0;
}

/* Game canvas wrapper for positioning controls over it */
.game-wrapper {
  position: relative;
  width: 100%;
}

#game {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  display: block;
  margin: 0 auto;
  border-radius: 10px;
  border: 2px solid #8a7440;
  background: #0e2740;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* Mobile controls */
.mobile-controls {
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  user-select: none;
  -webkit-user-select: none;
}

.ctrl-group {
  display: flex;
  gap: 10px;
}

.ctrl-btn {
  width: 64px;
  height: 58px;
  border: 2px solid rgba(138, 116, 64, 0.35);
  border-radius: 12px;
  background: rgba(26, 18, 8, 0.2);
  color: rgba(244, 236, 210, 0.35);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

.ctrl-btn:active, .ctrl-btn.pressed {
  background: rgba(138, 116, 64, 0.3);
  border-color: rgba(196, 166, 84, 0.5);
}

.ctrl-bomb {
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon {
  width: 44px;
  height: 44px;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  pointer-events: none;
  margin-top: -9px;
  margin-left: -1px;
  opacity: 0.35;
}

/* ── Mobile: landscape fullscreen ── */
body.mobile .panel {
  display: none;
}

body.mobile {
  overflow: hidden;
  background: #000;
  touch-action: none;
  -webkit-touch-callout: none;
}

body.mobile .layout {
  max-width: none;
  padding: 0;
  margin: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.mobile .game-wrapper {
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(100vw, calc(100vh * 16 / 9));
  width: min(100dvw, calc(100dvh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  height: min(100dvh, calc(100dvw * 9 / 16));
  aspect-ratio: 16 / 9;
  transform: translate(-50%, -50%);
}

body.mobile #game {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 0;
}

@media (orientation: portrait) {
  body.mobile::before {
    content: "Rotate your phone";
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    background: #050914;
    color: #f8edc8;
    font: 700 26px "Trebuchet MS", "Segoe UI", sans-serif;
    text-align: center;
  }

  body.mobile .game-wrapper {
    display: none;
  }
}
/* Controls overlaid on the game */
body.mobile .mobile-controls {
  display: block;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  top: 0;
  z-index: 10;
  pointer-events: none;
  touch-action: none;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

body.mobile .ctrl-group {
  pointer-events: auto;
  position: absolute;
  bottom: 16px;
}

body.mobile .ctrl-group:first-child {
  left: 20px;
}

body.mobile .ctrl-group:last-child {
  right: 20px;
}

body.mobile .ctrl-btn {
  width: 67px;
  height: 62px;
  font-size: 27px;
  position: relative;
}

/* Extend touch area for movement buttons */
body.mobile #btn-left::after,
body.mobile #btn-right::after {
  content: "";
  position: absolute;
  top: -10px;
  bottom: -10px;
}

body.mobile #btn-left::after {
  left: -20px;
  right: -5px;
}

body.mobile #btn-right::after {
  left: -5px;
  right: -20px;
}

/* Extend touch area for action buttons */
body.mobile #btn-jump::after,
body.mobile #btn-bomb::after {
  content: "";
  position: absolute;
  top: -10px;
  bottom: -10px;
}

body.mobile #btn-jump::after {
  left: -20px;
  right: -5px;
}

body.mobile #btn-bomb::after {
  left: -5px;
  right: -20px;
}

body.mobile .btn-icon {
  width: 46px;
  height: 46px;
}
