/* Shared mobile layout + chrome for all Massespill games.
   Linked before each game's inline <style>, so game-specific rules still win. */

:root { color-scheme: dark; }

html {
  height: 100%;
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: #0a0a0a;
  color: #fafafa;
  font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
}

body {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-sizing: border-box;
  gap: clamp(8px, 1.6vh, 16px);
  padding:
    calc(env(safe-area-inset-top) + clamp(8px, 2vh, 20px))
    calc(env(safe-area-inset-right) + clamp(8px, 3vw, 24px))
    calc(env(safe-area-inset-bottom) + clamp(8px, 2vh, 20px))
    calc(env(safe-area-inset-left) + clamp(8px, 3vw, 24px));
  overscroll-behavior: none;
}

h1 {
  margin: 0;
  font-size: clamp(1.1rem, 4.5vw, 1.5rem);
  font-weight: 600;
  letter-spacing: -0.01em;
  text-align: center;
}

.meta {
  display: flex;
  gap: clamp(12px, 4vw, 24px);
  font-size: clamp(0.8rem, 3vw, 0.9rem);
  color: #a1a1aa;
  flex-wrap: wrap;
  justify-content: center;
}
.meta strong { color: #fafafa; font-variant-numeric: tabular-nums; }

/* Flexible play area: fills the space between header and footer. */
.stage {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

/* The fixed-size playfield (canvas wrap or DOM board), scaled to fit .stage.
   --s is set by mobile.js. Internal game math is never touched. */
.playfield {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(var(--s, 1));
  transform-origin: center center;
  touch-action: none;
}
.playfield canvas { display: block; }

/* Start/Game over overlays (canvas games). */
.overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 10, 0.75);
  border-radius: 12px;
  flex-direction: column;
  gap: 12px;
  text-align: center;
  padding: 20px;
}
.overlay.active { display: flex; }
.overlay-title { font-size: 1.25rem; font-weight: 600; }

.hint {
  font-size: clamp(0.75rem, 2.6vw, 0.85rem);
  color: #71717a;
  text-align: center;
  max-width: 420px;
  margin: 0;
}

button {
  background: #fafafa;
  color: #0a0a0a;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}
button:hover { background: #e4e4e7; }

a {
  color: #a1a1aa;
  text-decoration: none;
  font-size: 0.85rem;
}
a:hover { color: #fafafa; }

/* On-screen touch controls — only shown on touch devices. */
.touch-controls {
  display: none;
  gap: 10px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
  max-width: 440px;
}
.touch-btn {
  flex: 0 0 auto;
  min-width: 60px;
  height: 54px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #18181b;
  color: #fafafa;
  border: 1px solid #27272a;
  border-radius: 12px;
  font-size: 1.4rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}
.touch-btn:active { background: #27272a; border-color: #3f3f46; }
.touch-btn.active { background: #27272a; color: #fbbf24; border-color: #3f3f46; }

@media (pointer: coarse) {
  .touch-controls { display: flex; }
}

/* Reclaim vertical space on short / landscape screens. */
@media (max-height: 560px) {
  h1 { font-size: 1rem; }
  body { gap: 6px; }
  .touch-btn { height: 46px; }
}
