* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --canvas-ratio: 1.77778;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #000;
  color: #f3f6f8;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  overflow: hidden;
  touch-action: none;
}

body {
  display: grid;
  place-items: center;
  gap: 0;
}

/* ---------- Install banner ---------- */
#install-banner {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  padding: 10px 40px 10px 14px;
  background: linear-gradient(135deg, #1a5276, #1a7a5a);
  color: #fff;
  font-size: 0.85rem;
  line-height: 1.35;
  text-align: center;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

#install-banner:not(.hidden) {
  display: block;
}

#install-banner.hidden {
  display: none;
}

#install-close {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
}

#install-close:hover {
  color: #fff;
}

/* ---------- Game wrapper ---------- */
#game-wrap {
  position: relative;
  display: inline-block;
  line-height: 0;
}

#game {
  /* contain-fit using dynamic ratio set by JS on :root */
  width:  min(100vw, calc(100dvh * var(--canvas-ratio)));
  height: min(100dvh, calc(100vw / var(--canvas-ratio)));
  display: block;
  background: #000;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* ---------- Fullscreen button ---------- */
#fs-btn {
  position: absolute;
  bottom: 8px;
  right: 8px;
  z-index: 100;
  width: 40px;
  height: 40px;
  padding: 6px;
  border: none;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.45);
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  transition: background 0.15s, opacity 0.2s;
}

#fs-btn:hover {
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
}

#fs-btn svg {
  display: block;
  width: 100%;
  height: 100%;
}

#fs-btn.hidden {
  opacity: 0;
  pointer-events: none;
}

/* ---------- Desktop ---------- */
@media (min-width: 961px) and (pointer: fine) {
  html, body {
    background: #202327;
  }
  body {
    gap: 12px;
  }
  #game {
    width:  min(100vw, calc(100vh * var(--canvas-ratio)));
    height: min(100vh, calc(100vw / var(--canvas-ratio)));
    border: 3px solid #0f1114;
    border-radius: 12px;
    background: #4a4a4a;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  }
  #fs-btn {
    bottom: 12px;
    right: 12px;
  }
}

/* ---------- Safe-area padding for notch devices ---------- */
@supports (padding: env(safe-area-inset-top)) {
  #game {
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }
}

.hint {
  width: min(96vw, 1280px);
  opacity: 0.9;
  font-size: 14px;
  line-height: 1.2;
}

@media (max-width: 960px), (pointer: coarse) {
  .hint {
    display: none;
  }
}

.hint p {
  margin: 2px 0;
}
