/* Ferment Lah! — page shell. The game itself is drawn on the canvas. */
:root {
  --ink: #2b1b14;
  --tile: #2f8f6c;
  --grout: #23785a;
  --glow: rgba(255, 200, 58, 0.18);
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background-color: var(--tile);
  touch-action: none;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

/* Kopitiam mosaic floor behind the game on wide screens. */
body {
  background-image:
    radial-gradient(ellipse at center, var(--glow), transparent 65%),
    linear-gradient(var(--grout) 2px, transparent 2px),
    linear-gradient(90deg, var(--grout) 2px, transparent 2px);
  background-size: 100% 100%, 22px 22px, 22px 22px;
  background-position: center, -1px -1px, -1px -1px;
  font-family: 'Fredoka', 'Trebuchet MS', system-ui, sans-serif;
  color: #fff;
}

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

#game {
  display: block;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  outline: none;
  background: var(--ink);
}

@media (min-aspect-ratio: 1/1) {
  #game {
    border-radius: 18px;
    box-shadow:
      0 0 0 6px var(--ink),
      0 18px 60px rgba(0, 0, 0, 0.45);
  }
}

/* Reads env(safe-area-inset-*) for the canvas layout. */
#probe {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  padding-top: env(safe-area-inset-top, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  visibility: hidden;
  pointer-events: none;
}

#rotate {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  background: rgba(43, 27, 20, 0.92);
  font-size: 22px;
  font-weight: 600;
  text-align: center;
  padding: 24px;
  z-index: 5;
}

#rotate .phone {
  width: 46px;
  height: 78px;
  border: 5px solid #fff;
  border-radius: 10px;
  animation: tilt 1.6s ease-in-out infinite;
}

body.landscape-phone #rotate {
  display: flex;
}

@keyframes tilt {
  0%,
  30% {
    transform: rotate(-90deg);
  }
  60%,
  100% {
    transform: rotate(0deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  #rotate .phone {
    animation: none;
  }
}

#err {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  max-height: 40vh;
  overflow: auto;
  padding: 12px 14px;
  border-radius: 12px;
  background: #b21d27;
  color: #fff;
  font: 600 14px/1.35 'Fredoka', system-ui, sans-serif;
  white-space: pre-wrap;
  z-index: 10;
  user-select: text;
  -webkit-user-select: text;
}

#err[hidden] {
  display: none;
}

noscript {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  padding: 24px;
  text-align: center;
}
