:root {
  --soil: #7d4f34;
  --leaf: #2f8a5c;
  --cream: #fff6dd;
  --ink: #233125;
  --sky: #bfe4ff;
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  height: 100%;
  overflow: auto;
  overscroll-behavior: none;
}

body {
  margin: 0;
  width: 100%;
  min-height: 100vh;
  overflow: auto;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, var(--sky), #f6e1a6 55%, #99cb72);
}

body.game-show {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.game-shell {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  overflow: hidden;
  position: fixed;
  inset: 0;
  padding:
    env(safe-area-inset-top)
    env(safe-area-inset-right)
    env(safe-area-inset-bottom)
    env(safe-area-inset-left);
  touch-action: none;
  overscroll-behavior: none;
}

#game-root {
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background:
    linear-gradient(180deg, rgba(191, 232, 255, 0.95), rgba(153, 203, 114, 0.95)),
    url("/assets/game/backgrounds/farm_background.png") center / cover no-repeat;
  box-shadow: none;
  touch-action: none;
}

canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  touch-action: none;
}

.orientation-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(180deg, rgba(25, 38, 31, 0.92), rgba(38, 56, 47, 0.86)),
    url("/assets/game/backgrounds/farm_background.png") center / cover no-repeat;
  color: #fff6dd;
  text-align: center;
}

.orientation-overlay div {
  display: grid;
  gap: 10px;
  max-width: 360px;
}

.orientation-overlay strong {
  font-size: 28px;
  line-height: 1.05;
}

.orientation-overlay span {
  color: rgba(255, 246, 221, 0.82);
  font-weight: 800;
  line-height: 1.35;
}

.pwa-install-popup {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, calc(env(safe-area-inset-bottom) + 86px));
  z-index: 44;
  width: min(330px, calc(100vw - 32px));
  padding: 16px;
  border: 1px solid rgba(255, 246, 221, 0.22);
  border-radius: 16px;
  background: rgba(27, 39, 31, 0.92);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  color: #fff6dd;
  display: grid;
  gap: 10px;
  backdrop-filter: blur(10px);
}

.pwa-install-popup[hidden] {
  display: none;
}

.pwa-install-popup strong {
  padding-right: 28px;
  font-size: 18px;
  line-height: 1.1;
}

.pwa-install-popup span {
  color: rgba(255, 246, 221, 0.78);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.3;
}

.pwa-install-button {
  min-height: 42px;
  border: 0;
  border-radius: 999px;
  background: #f4c247;
  color: #26382f;
  cursor: pointer;
  font: inherit;
  font-weight: 900;
}

.pwa-install-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 246, 221, 0.12);
  color: #fff6dd;
  cursor: pointer;
  font: inherit;
  font-weight: 900;
}

.pwa-install-button:active,
.pwa-install-close:active {
  transform: translateY(1px);
}

@media (hover: none) and (pointer: coarse) and (orientation: portrait) and (max-width: 760px) {
  body.game-show .orientation-overlay {
    display: grid;
  }
}

.landing-page,
.auth-page {
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(17, 31, 21, 0.76) 0%, rgba(17, 31, 21, 0.48) 42%, rgba(17, 31, 21, 0.1) 100%),
    url("/assets/game/backgrounds/farm_background.png") center / cover no-repeat;
  color: #fff6dd;
}

.landing-header,
.auth-header {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10;
  width: 100%;
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 42px;
}

.landing-brand {
  color: #fff6dd;
  font-size: 22px;
  font-weight: 900;
  text-decoration: none;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
}

.landing-play,
.auth-back,
.landing-cta,
.auth-submit,
.google-button {
  border: 0;
  border-radius: 999px;
  background: #f4c247;
  color: #26382f;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 22px;
  font: inherit;
  font-weight: 900;
  text-decoration: none;
  transition: transform 140ms ease, background 140ms ease, opacity 140ms ease;
}

.landing-play:hover,
.auth-back:hover,
.landing-cta:hover,
.auth-submit:hover,
.google-button:hover {
  background: #ffd86a;
  transform: translateY(-1px);
}

.landing-hero {
  min-height: 100svh;
  display: flex;
  align-items: center;
  padding: 96px 42px 54px;
}

.landing-copy {
  max-width: 560px;
  animation: landing-rise 520ms ease-out both;
}

.landing-kicker {
  margin: 0 0 12px;
  color: #bce8a8;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.landing-copy h1,
.auth-intro h1 {
  margin: 0;
  color: #fff6dd;
  font-size: clamp(54px, 8vw, 118px);
  line-height: 0.88;
  letter-spacing: 0;
  text-shadow: 0 7px 26px rgba(0, 0, 0, 0.34);
}

.landing-text,
.auth-intro p {
  max-width: 470px;
  margin: 22px 0 30px;
  color: rgba(255, 246, 221, 0.88);
  font-size: 19px;
  font-weight: 700;
  line-height: 1.45;
}

.auth-page {
  min-height: 100vh;
  padding: 104px 42px 54px;
  background:
    linear-gradient(90deg, rgba(17, 31, 21, 0.82), rgba(17, 31, 21, 0.52)),
    url("/assets/game/backgrounds/farm_background.png") center / cover no-repeat;
}

.auth-shell {
  width: min(1180px, 100%);
  min-height: calc(100svh - 158px);
  display: grid;
  grid-template-columns: minmax(260px, 0.72fr) minmax(560px, 1fr);
  gap: 46px;
  align-items: center;
  margin: 0 auto;
}

.auth-intro {
  animation: landing-rise 500ms ease-out both;
}

.auth-actions {
  animation: landing-rise 620ms ease-out both;
}

.google-button {
  width: 100%;
  margin: 0;
  background: #fff6dd;
  color: #233125;
}

.google-button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
}

.auth-note,
.auth-flash,
.auth-errors p {
  margin: 8px 0 0;
  color: rgba(255, 246, 221, 0.78);
  font-size: 13px;
  font-weight: 800;
}

.auth-flash-alert,
.auth-errors p {
  color: #ffd2c6;
}

.auth-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.auth-panel {
  padding: 22px;
  border: 1px solid rgba(255, 246, 221, 0.22);
  border-radius: 18px;
  background: rgba(27, 39, 31, 0.78);
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.26);
  backdrop-filter: blur(10px);
}

.auth-panel h2 {
  margin: 0 0 18px;
  color: #fff6dd;
  font-size: 24px;
}

.auth-form {
  display: grid;
  gap: 13px;
}

.auth-google-login {
  margin-top: 28px;
}

.auth-google-login form {
  margin: 0;
}

.auth-google-login .auth-note {
  margin-top: 10px;
  color: rgba(255, 246, 221, 0.7);
  line-height: 1.35;
}

.auth-form label {
  display: grid;
  gap: 6px;
  color: rgba(255, 246, 221, 0.84);
  font-size: 13px;
  font-weight: 900;
}

.auth-form input[type="email"],
.auth-form input[type="password"],
.auth-form input[type="text"] {
  width: 100%;
  height: 42px;
  border: 1px solid rgba(255, 246, 221, 0.2);
  border-radius: 10px;
  background: rgba(255, 246, 221, 0.95);
  color: #233125;
  font: inherit;
  font-weight: 800;
  padding: 0 12px;
  outline: none;
}

.auth-form input:focus {
  border-color: #f4c247;
  box-shadow: 0 0 0 3px rgba(244, 194, 71, 0.24);
}

.auth-check {
  grid-template-columns: 18px 1fr;
  align-items: center;
}

.auth-check input {
  width: 16px;
  height: 16px;
}

.auth-submit {
  width: 100%;
  margin-top: 4px;
}

@keyframes landing-rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 720px) {
  .game-shell {
    padding: 0;
  }

  #game-root {
    height: 100%;
    min-height: 0;
  }

  .pwa-install-popup {
    left: 14px;
    right: 14px;
    bottom: max(12px, calc(env(safe-area-inset-bottom) + 76px));
    width: auto;
    padding: 12px 14px;
    gap: 8px;
  }

  .pwa-install-popup strong {
    font-size: 16px;
  }

  .pwa-install-popup span {
    font-size: 12px;
  }

  .pwa-install-button {
    min-height: 38px;
  }

  .landing-header,
  .auth-header {
    height: 66px;
    padding: 0 18px;
  }

  .landing-hero,
  .auth-page {
    padding: 86px 18px 36px;
  }

  .landing-copy h1,
  .auth-intro h1 {
    font-size: 58px;
  }

  .landing-text,
  .auth-intro p {
    font-size: 16px;
  }

  .auth-shell,
  .auth-grid {
    grid-template-columns: 1fr;
  }

  .auth-shell {
    min-height: auto;
    gap: 24px;
  }
}
