:root {
  --sage: #7c915b;
  --sage-dark: #5a6b40;
  --sage-deep: #3d4a2c;
  --cream: #f4f0e6;
  --ink: #2c331f;
  --amber: #c9842a;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
  background: linear-gradient(180deg, #7c915b 0%, #5a6b40 55%, #3d4a2c 100%);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
}

.phone-only {
  display: none;
}

.site-bar {
  width: 100%;
  background: #fff;
  border-bottom: 4px solid var(--sage);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.crest {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  border-radius: 50%;
}

.brand h1 {
  font-size: 15px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--sage-deep);
}

.brand p {
  font-size: 11px;
  color: #667155;
}

.site-bar a {
  color: var(--sage-deep);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  border: 2px solid var(--sage);
  padding: 6px 12px;
  border-radius: 4px;
  background: var(--cream);
}

#wrap {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 18px 12px 28px;
  gap: 12px;
}

#stage {
  position: relative;
  line-height: 0;
  width: min(96vw, calc(92vh * 320 / 240));
}

.fs-fab {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 6;
  appearance: none;
  border: 0;
  background: rgba(244, 240, 230, 0.92);
  color: var(--sage-deep);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.04em;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  line-height: 1;
  pointer-events: auto;
}

html.app .fs-fab,
html.app .actions {
  display: none !important;
}

#game {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #000;
  border: 6px solid var(--sage-deep);
  border-radius: 6px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  width: 100%;
  height: auto;
  touch-action: none;
}

#touch {
  display: none;
  position: absolute;
  inset: auto 0 0 0;
  padding: 8px 10px 78px;
  gap: 10px;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
}

#touch .cluster {
  display: flex;
  gap: 8px;
  pointer-events: auto;
  align-items: flex-end;
}

.pad {
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  background: rgba(44, 51, 31, 0.55);
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.pad small {
  font-size: 9px;
  letter-spacing: 0.04em;
  opacity: 0.9;
  margin-top: 2px;
}

.pad:active,
.pad.held {
  background: rgba(201, 132, 42, 0.9);
}

.pad-a {
  background: rgba(201, 132, 42, 0.75);
  width: 70px;
  height: 70px;
}

.pad-b {
  width: 62px;
  height: 62px;
}

.meta {
  color: #f4f0e6;
  text-align: center;
  max-width: 720px;
  font-size: 13px;
  line-height: 1.45;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.meta strong {
  color: #fff;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.actions a,
.actions button,
#phone-bar button,
.install-card button {
  appearance: none;
  border: 0;
  background: #fff;
  color: var(--sage-deep);
  font-weight: 700;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 4px;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
}

.install-card {
  max-width: 520px;
  background: rgba(244, 240, 230, 0.95);
  color: var(--ink);
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.4;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.install-card[hidden] {
  display: none !important;
}

.ios-share {
  display: inline-block;
  padding: 0 4px;
  font-weight: 700;
}

footer {
  width: 100%;
  background: #fff;
  color: #667155;
  text-align: center;
  font-size: 12px;
  padding: 12px;
}

footer a {
  color: var(--sage-deep);
}

/* Netlify injects a floating badge that covers Jump/Run on phones */
a[href*="netlify.com"],
.netlify-badge,
#netlify-badge,
[data-netlify-badge],
img[alt*="Netlify" i],
img[src*="netlify.com"],
iframe[src*="app.netlify.com"] {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
  opacity: 0 !important;
  width: 0 !important;
  height: 0 !important;
}

@media (pointer: coarse), (max-width: 900px) {
  #touch {
    display: flex;
  }

  #stage {
    width: min(96vw, 920px);
  }
}

/* Installed PWA, native WebView, or ?app=1 */
html.app,
html.app body {
  background: #3d4a2c;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

html.app body {
  min-height: 100dvh;
  height: 100dvh;
}

html.app .web-only {
  display: none !important;
}

html.app .phone-only,
html.app #phone-bar {
  display: flex;
}

html.app #phone-bar {
  position: absolute;
  top: calc(8px + env(safe-area-inset-top, 0px));
  right: 10px;
  z-index: 5;
  gap: 8px;
}

html.app #phone-bar button {
  background: rgba(244, 240, 230, 0.88);
  padding: 8px 10px;
}

html.app #wrap {
  padding: 0;
  height: 100dvh;
  justify-content: stretch;
}

html.app #stage {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

html.app #game {
  width: 100%;
  height: auto;
  max-height: 58dvh;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  flex: 0 0 auto;
}

html.app #touch {
  display: flex;
  position: relative;
  inset: auto;
  flex: 1;
  padding: 12px 18px calc(88px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, #4e5e38, #2c331f);
}

html.app .pad,
html.app .pad-b {
  width: 74px;
  height: 74px;
  font-size: 22px;
}

html.app .pad-a {
  width: 88px;
  height: 88px;
}

html.app .pad-sm {
  width: 58px;
  height: 58px;
}

@media (orientation: landscape) and (max-height: 560px) {
  html.app #stage,
  html.is-fullscreen #stage,
  html:fullscreen #stage,
  html:-webkit-full-screen #stage {
    flex-direction: row;
    align-items: stretch;
  }

  html.app #game,
  html.is-fullscreen #game,
  html:fullscreen #game,
  html:-webkit-full-screen #game {
    max-height: none;
    height: 100dvh;
    width: auto;
    flex: 1 1 auto;
    object-fit: contain;
  }

  html.app #touch,
  html.is-fullscreen #touch,
  html:fullscreen #touch,
  html:-webkit-full-screen #touch {
    position: absolute;
    inset: 0;
    background: transparent;
    pointer-events: none;
    padding: 0 12px calc(78px + env(safe-area-inset-bottom, 0px));
  }

  html.app #touch .cluster,
  html.is-fullscreen #touch .cluster,
  html:fullscreen #touch .cluster {
    pointer-events: auto;
  }

  html.app #touch .move,
  html.is-fullscreen #touch .move,
  html:fullscreen #touch .move {
    margin-right: auto;
  }
}

/* Native or CSS fullscreen (needed inside Wix iframes and Safari) */
html.is-fullscreen,
html:fullscreen,
html:-webkit-full-screen {
  background: #3d4a2c;
  height: 100%;
}

html.is-fullscreen body,
html:fullscreen body,
html:-webkit-full-screen body {
  min-height: 100dvh;
  height: 100dvh;
  overflow: hidden;
  background: #3d4a2c;
}

html.is-fullscreen .web-only,
html:fullscreen .web-only,
html:-webkit-full-screen .web-only {
  display: none !important;
}

html.is-fullscreen .actions,
html:fullscreen .actions,
html:-webkit-full-screen .actions {
  display: none !important;
}

html.is-fullscreen .fs-fab,
html:fullscreen .fs-fab,
html:-webkit-full-screen .fs-fab {
  display: inline-flex !important;
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 30;
}

html.is-fullscreen #wrap,
html:fullscreen #wrap,
html:-webkit-full-screen #wrap {
  padding: 0;
  height: 100dvh;
  justify-content: stretch;
}

html.is-fullscreen #stage,
html:fullscreen #stage,
html:-webkit-full-screen #stage {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

html.is-fullscreen #game,
html:fullscreen #game,
html:-webkit-full-screen #game {
  width: 100%;
  max-height: 100dvh;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

html.is-fullscreen #touch,
html:fullscreen #touch,
html:-webkit-full-screen #touch {
  position: relative;
  inset: auto;
  flex: 1;
  padding: 12px 18px calc(72px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, #4e5e38, #2c331f);
}

@media (pointer: coarse), (max-width: 900px) {
  html.is-fullscreen #game,
  html:fullscreen #game,
  html:-webkit-full-screen #game {
    max-height: 70dvh;
  }

  html.is-fullscreen #touch,
  html:fullscreen #touch,
  html:-webkit-full-screen #touch {
    display: flex;
  }
}
