:root {
  color-scheme: light;
  --ink: #123044;
  --foam: #efffff;
  --tile: #8fe8ef;
  --rubber: #ffd43f;
  --coral: #ff6f59;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  /* Full-bleed scene behind the game; subtle dim so the centred play area pops.
     The gradient at the end is the fallback if the image can't load. */
  background:
    linear-gradient(rgba(7, 38, 63, 0.22), rgba(7, 38, 63, 0.34)),
    url("assets/bg_game.jpg?v=20260623-bg1") center center / cover no-repeat fixed,
    linear-gradient(135deg, #e8fbff 0%, #8fe8ef 45%, #2fb5d8 100%);
  color: var(--ink);
  font-family: "Trebuchet MS", "Gill Sans", Verdana, sans-serif;
  touch-action: none;
  -webkit-font-smoothing: antialiased;
}

button,
canvas {
  font: inherit;
}

.game-shell {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

#game {
  width: min(100vw - 24px, 1180px);
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - 24px);
  border: 4px solid rgba(255, 255, 255, 0.86);
  border-radius: 18px;
  overflow: hidden;
  background: #7ee8f2;
  box-shadow:
    0 26px 70px rgba(11, 73, 102, 0.32),
    inset 0 0 0 1px rgba(18, 48, 68, 0.08);
}

#game canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.rotate-gate {
  display: none;
}

@media (max-width: 700px) {
  .game-shell {
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
      max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }

  #game {
    width: calc(100vw - 24px);
    height: calc(100svh - 24px);
    max-height: none;
  }
}

@media (orientation: portrait) and (pointer: coarse) {
  .game-shell {
    background:
      radial-gradient(circle at 50% 22%, rgba(255, 212, 63, 0.32), transparent 14rem),
      linear-gradient(180deg, #baf7fb 0%, #42c5dd 100%);
  }

  #game {
    height: auto;
    aspect-ratio: 16 / 9;
    box-shadow: 0 18px 46px rgba(11, 73, 102, 0.28);
  }

  .rotate-gate {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: grid;
    place-items: center;
    padding: 16px;
    background:
      radial-gradient(circle at 50% 32%, rgba(255, 212, 63, 0.34), transparent 13rem),
      linear-gradient(180deg, rgba(7, 42, 65, 0.92), rgba(3, 23, 39, 0.96));
  }

  .rotate-gate img {
    width: 100%;
    height: 100%;
    object-fit: contain;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .game-shell {
    padding: max(4px, env(safe-area-inset-top)) max(4px, env(safe-area-inset-right))
      max(4px, env(safe-area-inset-bottom)) max(4px, env(safe-area-inset-left));
  }

  #game {
    width: min(calc(100vw - 8px), calc((100svh - 8px) * 16 / 9));
    height: auto;
    aspect-ratio: 16 / 9;
    border-width: 2px;
    border-radius: 10px;
  }
}
