/* Tide & Crown — host page + embed shell */

:root {
  --bg: #071018;
  --bg-elevated: #0c1822;
  --ink: #e8f1f5;
  --muted: #8aa0ad;
  --accent: #5eead4;
  --gold: #fbbf24;
  --line: #1e3a4a;
  --radius: 16px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, #143042 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 80% 100%, #0d2a28 0%, transparent 50%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font);
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 48px;
}

.site-header {
  width: min(960px, 100%);
  margin-bottom: 16px;
  text-align: center;
}

.site-header h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  letter-spacing: 0.04em;
  color: #f5f0e6;
}

.site-header .tagline {
  margin: 8px 0 0;
  color: var(--accent);
  font-size: 1rem;
  letter-spacing: 0.02em;
}

.site-header .meta {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

#game-frame {
  width: min(960px, 100%);
  aspect-ratio: 960 / 640;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow:
    0 0 0 1px rgba(94, 234, 212, 0.06),
    0 24px 64px rgba(0, 0, 0, 0.45),
    0 0 80px rgba(20, 80, 90, 0.15);
  overflow: hidden;
  position: relative;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

#game-container {
  width: 100%;
  height: 100%;
  touch-action: none;
}

#game-container canvas {
  display: block;
  margin: 0 auto;
  touch-action: none;
}

/* Phones (marketing chrome mode only) */
@media (max-width: 720px), (pointer: coarse) {
  body:not(.embed-mode) {
    padding: 10px 8px 28px;
  }

  body:not(.embed-mode) .site-header {
    margin-bottom: 10px;
  }

  body:not(.embed-mode) .site-header .meta {
    display: none;
  }

  body:not(.embed-mode) #game-frame {
    width: 100%;
    max-width: 100%;
    border-radius: 12px;
  }

  body:not(.embed-mode) .site-footer {
    margin-top: 18px;
  }
}

.site-footer {
  width: min(960px, 100%);
  margin-top: 28px;
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.card {
  background: rgba(12, 24, 34, 0.85);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
}

.card h2 {
  margin: 0 0 10px;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
  font-weight: 600;
}

.card p,
.card li {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

.card ul {
  margin: 0;
  padding-left: 1.1rem;
}

.card code {
  font-size: 0.8rem;
  background: #0a1218;
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent);
}

.embed-snippet {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 12px;
  background: #050a0e;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: #b6d0da;
  font-size: 0.75rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-all;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}

.badge {
  display: inline-block;
  margin-top: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(94, 234, 212, 0.12);
  color: var(--accent);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}

/* ═══════════════════════════════════════════════════════════
   MOBILE / EMBED FULLSCREEN
   Fixed viewport shell so Phaser Scale.FIT always has a real
   width×height parent (not a collapsed flex box).
   DO NOT set canvas width/height in CSS — Phaser owns that.
   ═══════════════════════════════════════════════════════════ */
html.embed-mode {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #000;
}

html.embed-mode,
body.embed-mode {
  margin: 0 !important;
  padding: 0 !important;
  width: 100%;
  max-width: 100%;
  height: 100%;
  height: 100dvh;
  min-height: 100%;
  min-height: 100dvh;
  background: #000 !important;
  overflow: hidden !important;
  overscroll-behavior: none;
  position: fixed;
  inset: 0;
  display: block;
  touch-action: none;
}

body.embed-mode .site-header,
body.embed-mode .site-footer {
  display: none !important;
}

/* Fill the entire screen (safe-area insets only as black bars outside the game) */
body.embed-mode #game-frame {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  min-width: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  aspect-ratio: auto !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  overflow: hidden !important;
  background: #000 !important;
  /* iOS notch / home bar — keep game drawable inside safe area */
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px)
    env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  box-sizing: border-box !important;
  z-index: 1;
}

body.embed-mode #game-container {
  position: relative !important;
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  inset: auto !important;
  display: block !important;
  overflow: hidden !important;
  background: #000;
}

/*
 * Let Phaser Scale.FIT set inline pixel width/height on the canvas.
 * Overriding with width:auto !important was shrinking the game.
 */
body.embed-mode #game-container canvas {
  display: block !important;
  /* Phaser sets left/top/width/height — don't fight it */
  max-width: none !important;
  max-height: none !important;
  touch-action: none;
  -webkit-touch-callout: none;
  transform: translateZ(0);
}

/* Portrait tip under splash only (phones) */
@media (orientation: portrait) {
  body.embed-mode #boot-splash p::after {
    content: " Rotate to landscape for a bigger view.";
  }
}
