:root {
  --grass-dark: #2d6f3d;
  --grass: #4f9b4d;
  --grass-light: #91c96d;
  --soil: #8c6846;
  --gold: #d4a72c;
  --ink: #18221b;
  --panel: #ffffff;
  --sky: #d9eef6;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.84), transparent 28%),
    linear-gradient(180deg, var(--sky) 0%, #f6faf3 46%, #e8f1df 100%);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.top-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: #3b6b47;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 7vw, 4.75rem);
  line-height: 0.95;
}

.status-pill {
  min-width: 132px;
  padding: 8px 12px;
  border: 1px solid rgba(24, 34, 27, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
}

.status-pill.is-ok {
  border-color: rgba(38, 137, 75, 0.45);
  color: #155d2e;
}

.status-pill.is-error {
  border-color: rgba(170, 54, 44, 0.45);
  color: #8f2f28;
}

.drawer-button {
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid rgba(24, 34, 27, 0.16);
  border-radius: 999px;
  background: #1f5c33;
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 800;
}

.diagnostics-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(24, 34, 27, 0.42);
}

.diagnostics-card {
  width: min(560px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  padding: 20px;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(24, 34, 27, 0.28);
}

.diagnostics-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.diagnostics-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.diagnostics-close {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(24, 34, 27, 0.16);
  border-radius: 50%;
  background: #f7faf4;
  font-weight: 800;
}

.diagnostics-content {
  display: grid;
  grid-template-columns: minmax(130px, auto) 1fr;
  gap: 8px 14px;
  margin: 0;
}

.diagnostics-content dt {
  color: #5d6b5d;
  font-weight: 800;
}

.diagnostics-content dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.game-frame {
  position: relative;
  display: block;
}

.lawn-preview {
  position: relative;
  height: clamp(480px, calc(100vh - 190px), 720px);
  min-height: 480px;
  overflow: hidden;
  border: 1px solid rgba(24, 34, 27, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.08) 25%, transparent 25% 75%, rgba(255, 255, 255, 0.08) 75%),
    linear-gradient(45deg, rgba(20, 60, 29, 0.13) 25%, transparent 25% 75%, rgba(20, 60, 29, 0.13) 75%),
    linear-gradient(135deg, var(--grass-light), var(--grass) 48%, var(--grass-dark));
  background-position: 0 0, 24px 24px, 0 0;
  background-size: 48px 48px, 48px 48px, auto;
  box-shadow:
    inset 0 -90px 120px rgba(28, 70, 35, 0.28),
    0 22px 55px rgba(24, 34, 27, 0.16);
}

.lawn-preview canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.lawn-stats {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: min(520px, calc(100% - 28px));
}

.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid rgba(24, 34, 27, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.84);
  color: #1b291d;
  font-size: 0.84rem;
  font-weight: 800;
  box-shadow: 0 8px 22px rgba(24, 34, 27, 0.14);
  cursor: pointer;
}

.stat-chip svg,
.game-summary svg {
  width: 17px;
  height: 17px;
  stroke-width: 2.4;
}

.lawn-preview::after {
  position: absolute;
  inset: auto 0 0;
  height: 34%;
  content: "";
  background: linear-gradient(180deg, transparent, rgba(24, 34, 27, 0.18));
  pointer-events: none;
}

.game-empty {
  position: absolute;
  inset: 0;
}

.game-empty.is-hidden {
  display: none;
}

.joystick {
  position: absolute;
  right: 22px;
  bottom: 22px;
  width: 122px;
  height: 122px;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 50%;
  background: rgba(24, 34, 27, 0.18);
  box-shadow: inset 0 0 0 1px rgba(24, 34, 27, 0.22), 0 12px 24px rgba(24, 34, 27, 0.18);
  touch-action: none;
  z-index: 3;
}

.joystick span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f8fff4, #b5d79d);
  box-shadow: 0 6px 18px rgba(24, 34, 27, 0.28);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.panel {
  min-height: 0;
  padding: 24px;
  border: 1px solid rgba(24, 34, 27, 0.14);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 45px rgba(24, 34, 27, 0.13);
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 15;
  width: min(390px, calc(100vw - 32px));
  height: 100vh;
  overflow: auto;
  border-radius: 0;
  transform: translateX(110%);
  transition: transform 180ms ease;
}

.drawer.is-open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.drawer-header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 14;
  border: 0;
  background: rgba(24, 34, 27, 0.36);
}

.panel h2,
.panel h3 {
  font-size: 1.25rem;
}

.panel p {
  color: #485448;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 20px;
  padding: 4px;
  border: 1px solid rgba(24, 34, 27, 0.12);
  border-radius: 8px;
  background: #eef4e9;
}

.mode-button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #435243;
  font-weight: 700;
}

.mode-button.is-active {
  background: #ffffff;
  color: #1f5c33;
  box-shadow: 0 2px 8px rgba(24, 34, 27, 0.08);
}

.auth-form {
  display: block;
}

.google-login {
  display: grid;
  justify-content: center;
  margin-bottom: 16px;
}

.auth-form .form-label {
  margin-top: 12px;
  margin-bottom: 6px;
  color: #374437;
  font-size: 0.9rem;
  font-weight: 700;
}

.auth-form .btn {
  margin-top: 18px;
}

.form-message {
  min-height: 24px;
  margin-top: 16px;
  margin-bottom: 0;
  font-size: 0.92rem;
}

.form-message.is-error {
  color: #8f2f28;
}

.form-message.is-ok {
  color: #155d2e;
}

.game-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 18px 0;
}

.game-summary div {
  min-height: 68px;
  padding: 12px;
  border: 1px solid rgba(24, 34, 27, 0.1);
  border-radius: 8px;
  background: linear-gradient(180deg, #fbfdf8, #f0f6eb);
}

.game-summary dt {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #5d6b5d;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.game-summary dd {
  margin: 4px 0 0;
  color: #1b291d;
  font-size: 1rem;
  font-weight: 800;
}

.orders-panel {
  margin: 18px 0;
}

.orders-panel h3,
.admin-panel h3 {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 1rem;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.icon-button svg,
.orders-panel h3 svg,
.order-row svg {
  width: 17px;
  height: 17px;
  stroke-width: 2.4;
}

.upgrade-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 0 10px;
}

.orders-list {
  display: grid;
  gap: 8px;
}

.order-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid rgba(24, 34, 27, 0.12);
  border-radius: 8px;
  background: #fbfcf7;
}

.order-row .btn:disabled {
  opacity: 0.45;
}

.order-row p {
  margin: 0;
  color: #2d382e;
  font-size: 0.9rem;
  font-weight: 800;
}

.order-row span {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #65705f;
  font-size: 0.78rem;
  font-weight: 700;
}

.admin-panel {
  margin: 18px 0;
  padding-top: 16px;
  border-top: 1px solid rgba(24, 34, 27, 0.12);
}

.admin-settings {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.admin-settings label {
  display: grid;
  gap: 4px;
  color: #4e5b4e;
  font-size: 0.76rem;
  font-weight: 800;
}

.admin-settings input {
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid rgba(24, 34, 27, 0.16);
  border-radius: 6px;
}

.is-hidden {
  display: none !important;
}

.windmill {
  position: absolute;
  top: 22%;
  left: 58%;
  width: 112px;
  height: 170px;
  filter: drop-shadow(18px 20px 14px rgba(24, 34, 27, 0.28));
}

.tower {
  position: absolute;
  right: 34px;
  bottom: 0;
  width: 48px;
  height: 116px;
  clip-path: polygon(28% 0, 72% 0, 100% 100%, 0 100%);
  background: linear-gradient(90deg, #f2e6cf, #c9a87b);
  border: 3px solid #7b5b3d;
}

.blade {
  position: absolute;
  top: 18px;
  left: 30px;
  width: 70px;
  height: 14px;
  border-radius: 999px;
  background: #f7f0df;
  transform-origin: 26px 7px;
  box-shadow: 0 0 0 2px #77583c inset;
}

.blade-a {
  transform: rotate(28deg);
}

.blade-b {
  transform: rotate(118deg);
}

.mower {
  position: absolute;
  right: 24%;
  bottom: 22%;
  width: 96px;
  height: 62px;
  border-radius: 16px 16px 10px 10px;
  background:
    linear-gradient(90deg, transparent 0 10px, #1c1f1d 10px 20px, transparent 20px 76px, #1c1f1d 76px 86px, transparent 86px),
    linear-gradient(135deg, #dc4739, #a92722);
  box-shadow: 18px 24px 18px rgba(24, 34, 27, 0.32);
}

.mower::before {
  position: absolute;
  top: -24px;
  right: 16px;
  width: 58px;
  height: 28px;
  border-top: 6px solid #323834;
  border-right: 6px solid #323834;
  border-radius: 0 18px 0 0;
  content: "";
}

@media (max-width: 820px) {
  .top-bar {
    display: block;
  }

  .status-pill {
    margin-top: 16px;
    width: max-content;
  }

  .lawn-preview {
    height: calc(100vh - 190px);
    min-height: 420px;
    margin-bottom: 16px;
  }

  .joystick {
    width: 104px;
    height: 104px;
  }

  .lawn-stats {
    top: 10px;
    right: 10px;
    gap: 6px;
  }

  .stat-chip {
    min-height: 32px;
    padding: 6px 8px;
    font-size: 0.78rem;
  }

  .game-summary,
  .upgrade-actions {
    grid-template-columns: 1fr;
  }
}
