:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #f8f3e8;
  background: #0d1712;
  font-synthesis: none;
  --ink: #f8f3e8;
  --muted: #a8b7a6;
  --muted-strong: #cad8c7;
  --line: rgba(170, 207, 153, .18);
  --panel: rgba(17, 31, 22, .86);
  --panel-strong: rgba(21, 41, 28, .94);
  --green: #b4e58d;
  --green-deep: #294b36;
  --gold: #f2cc73;
  --soil: #775432;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: #0d1712; }
body { min-width: 320px; margin: 0; overflow-x: hidden; background: radial-gradient(circle at 15% -8%, #3a724b 0, #183321 28%, #0d1712 70%); }
body::before { position: fixed; z-index: -1; inset: 0; pointer-events: none; content: ""; opacity: .28; background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px); background-size: 36px 36px; mask-image: linear-gradient(to bottom, #000, transparent 72%); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
.layout { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 30px 0 80px; }
.hero { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 32px; min-height: 260px; margin-bottom: 22px; padding: 32px; overflow: hidden; border: 1px solid rgba(190, 230, 165, .2); border-radius: 30px; background: linear-gradient(135deg, rgba(31, 72, 44, .94), rgba(16, 31, 21, .96) 70%); box-shadow: 0 24px 80px rgba(0, 0, 0, .26); }
.hero::after { position: absolute; right: -90px; bottom: -140px; width: 420px; height: 420px; border: 1px solid rgba(180, 229, 141, .12); border-radius: 50%; box-shadow: 0 0 0 24px rgba(180, 229, 141, .035), 0 0 0 64px rgba(180, 229, 141, .025); content: ""; }
.hero > * { position: relative; z-index: 1; }
.eyebrow { margin: 0 0 9px; color: var(--green); font-size: 11px; font-weight: 850; letter-spacing: .18em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { max-width: 720px; margin-bottom: 15px; font-size: clamp(42px, 7vw, 82px); line-height: .9; letter-spacing: -.075em; }
h2 { margin-bottom: 0; font-size: 21px; letter-spacing: -.025em; }
.subtitle { max-width: 640px; margin-bottom: 0; color: var(--muted-strong); font-size: 16px; line-height: 1.6; }
.hero-status { display: grid; gap: 14px; justify-items: end; }
.status { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border: 1px solid transparent; border-radius: 999px; font-size: 12px; font-weight: 850; white-space: nowrap; }
.status::before { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 4px rgba(255,255,255,.08); content: ""; }
.status-online { color: #19321f; background: var(--green); box-shadow: 0 8px 22px rgba(180, 229, 141, .18); }
.status-offline { color: #f0c894; border-color: rgba(240, 200, 148, .2); background: rgba(93, 59, 34, .75); }
.resource-strip { display: flex; flex-wrap: wrap; justify-content: end; gap: 8px; }
.resource-chip { display: grid; gap: 3px; min-width: 96px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 15px; background: rgba(8, 18, 12, .42); backdrop-filter: blur(8px); }
.resource-chip small { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.resource-chip strong { color: var(--ink); font-size: 20px; line-height: 1; }
.resource-chip-premium { border-color: rgba(242, 204, 115, .28); background: rgba(80, 60, 24, .3); }
.resource-chip-premium strong { color: var(--gold); }
.panel { position: relative; margin-top: 18px; padding: 24px; border: 1px solid var(--line); border-radius: 24px; background: var(--panel); box-shadow: 0 18px 55px rgba(0, 0, 0, .17); }
.panel::before { position: absolute; top: 0; left: 24px; width: 48px; height: 2px; border-radius: 2px; background: var(--green); content: ""; opacity: .75; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.auth-panel { background: linear-gradient(145deg, rgba(24, 47, 31, .94), rgba(15, 27, 19, .92)); }
.auth-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
label { display: grid; gap: 8px; color: var(--muted-strong); font-size: 12px; font-weight: 800; }
input, select { width: 100%; padding: 13px 14px; border: 1px solid rgba(174, 213, 154, .22); border-radius: 13px; outline: none; color: var(--ink); background: rgba(7, 16, 10, .72); transition: border-color .16s ease, box-shadow .16s ease, background .16s ease; }
input::placeholder { color: #718174; }
input:focus, select:focus { border-color: var(--green); background: rgba(7, 16, 10, .9); box-shadow: 0 0 0 3px rgba(180, 229, 141, .13); }
select { min-width: 220px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 16px; }
.auth-recovery-link { display: block; width: fit-content; margin: 11px auto 0; color: var(--green); font-size: 12px; text-decoration: none; opacity: .9; }
.auth-recovery-link:hover { color: #e3f2d8; text-decoration: underline; }
.recovery-fields { display: grid; gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
[hidden] { display: none !important; }
.recovery-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.button { cursor: pointer; padding: 11px 16px; border: 1px solid transparent; border-radius: 13px; font-weight: 850; transition: transform .16s ease, filter .16s ease, box-shadow .16s ease, border-color .16s ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.07); }
.button:active:not(:disabled) { transform: translateY(0); }
.button:disabled { cursor: not-allowed; opacity: .45; }
.button-primary { color: #132017; background: var(--green); box-shadow: 0 8px 18px rgba(180, 229, 141, .13); }
.button-secondary { color: #dcebd5; border-color: rgba(180, 229, 141, .14); background: #294733; }
.text-button { cursor: pointer; border: 0; color: var(--green); background: transparent; font-size: 12px; text-decoration: none; }
.text-button:hover { text-decoration: underline; }
.message { min-height: 22px; margin: 15px 0 0; color: var(--muted); line-height: 1.45; }
.muted { color: #8fa493; font-size: 12px; }
.farm-meta { display: grid; gap: 2px; text-align: right; color: #8fa493; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.farm-meta strong { color: var(--green); font-size: 22px; letter-spacing: 0; }
.farm-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-bottom: 18px; }
.map-panel, .farm-panel { background: var(--panel-strong); }
.map-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; padding: 10px; border: 1px solid rgba(174, 213, 154, .1); border-radius: 18px; background: #0b1911; }
.map-tile { aspect-ratio: 1; display: grid; place-items: center; min-width: 0; padding: 2px; overflow: hidden; border: 1px solid rgba(255,255,255,.045); border-radius: 7px; color: rgba(227, 242, 216, .72); background: #315f40; font-size: clamp(6px, 1vw, 10px); font-weight: 750; transition: transform .14s ease, filter .14s ease; }
.map-tile:hover { z-index: 1; transform: scale(1.06); filter: brightness(1.16); }
.map-tile.soil { color: #f0d2a3; background: var(--soil); }
.map-tile.water { color: #c7ecf0; background: #27637c; }
.map-tile.occupied { color: #142017; border-color: var(--gold); background: var(--gold); }
.map-tile.player { color: #132017; border-color: var(--green); background: var(--green); box-shadow: 0 0 0 3px rgba(180, 229, 141, .22); }
.farm-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px; min-height: 220px; padding: 14px; border: 1px solid rgba(174, 213, 154, .1); border-radius: 18px; background: #172c1d; }
.plot { position: relative; aspect-ratio: 1; display: grid; place-items: center; overflow: hidden; border: 1px solid #456c4d; border-radius: 11px; color: #e6f0dd; background: #365b3c; transition: transform .14s ease, border-color .14s ease, filter .14s ease; }
.plot:hover { z-index: 1; transform: translateY(-2px); border-color: var(--green); filter: brightness(1.1); }
.plot.empty { cursor: pointer; background: #2d5135; }
.plot.empty:hover { background: #416c47; }
.plot.planted { background: #614a32; }
.plot.ready { border-color: var(--gold); background: #765531; box-shadow: inset 0 0 0 1px rgba(242,204,115,.2); }
.plot span { font-size: 19px; font-weight: 800; }
.plot small { position: absolute; right: 5px; bottom: 4px; color: #dce8d5; font-size: 9px; }
.event-log { max-height: 180px; margin: 0; overflow: auto; color: var(--green); font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; }
.production-controls { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px; border: 1px solid rgba(174, 213, 154, .12); border-radius: 16px; background: rgba(13, 31, 19, .74); }
.production-controls p { margin: 6px 0 0; }
.production-list { display: grid; gap: 8px; margin-top: 12px; }
.production-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 12px; color: #d8ead0; background: #1d3324; }
.production-card small { color: #8ca08f; }
.production-empty { color: #8ca08f; font-size: 13px; }
@media (max-width: 720px) {
  .layout { width: min(100% - 20px, 620px); padding-top: 16px; }
  .hero { display: block; min-height: 0; padding: 24px 20px; border-radius: 23px; }
  .hero-status { justify-items: start; margin-top: 28px; }
  .resource-strip { justify-content: start; }
  .auth-grid { grid-template-columns: 1fr; }
  .panel { padding: 18px; border-radius: 19px; }
  .panel::before { left: 18px; }
  .farm-grid { gap: 5px; padding: 8px; }
  .map-grid { gap: 3px; padding: 7px; }
  .production-controls { align-items: stretch; flex-direction: column; }
  .recovery-actions { align-items: stretch; flex-direction: column; }
}

/* Единая изометрическая карта */
.auth-status { display: flex; align-items: center; gap: 12px; }
.world-panel { padding-bottom: 18px; background: linear-gradient(145deg, rgba(24, 52, 32, .97), rgba(11, 25, 16, .96)); }
.world-heading { align-items: flex-start; }
.world-heading .message { max-width: 520px; margin-bottom: 0; }
.world-tools { display: flex; align-items: center; gap: 7px; }
.zoom-readout { min-width: 54px; color: var(--muted-strong); font-size: 12px; font-weight: 800; text-align: center; }
.icon-button { width: 34px; height: 34px; padding: 0; border: 1px solid rgba(180, 229, 141, .2); border-radius: 10px; color: var(--green); background: rgba(9, 22, 13, .7); font-size: 21px; line-height: 1; }
.icon-button:hover { border-color: var(--green); background: rgba(45, 78, 48, .9); }
.map-viewport { position: relative; min-height: 540px; overflow: hidden; border: 1px solid rgba(180, 229, 141, .17); border-radius: 20px; background: radial-gradient(circle at 50% 45%, #224b2c, #0a1a10 82%); box-shadow: inset 0 0 50px rgba(0,0,0,.24); touch-action: manipulation; }
.map-viewport::before { position: absolute; inset: 0; pointer-events: none; content: ""; opacity: .18; background-image: radial-gradient(rgba(180,229,141,.28) 1px, transparent 1px); background-size: 24px 24px; mask-image: linear-gradient(to bottom, #000, transparent 80%); }
.iso-canvas { position: relative; z-index: 1; display: block; width: 100%; height: 540px; cursor: crosshair; touch-action: none; }
.map-hint { position: absolute; z-index: 2; right: 16px; bottom: 14px; max-width: calc(100% - 32px); padding: 8px 11px; border: 1px solid rgba(180, 229, 141, .16); border-radius: 999px; color: var(--muted-strong); background: rgba(8, 21, 12, .68); font-size: 11px; pointer-events: none; }
.world-toolbar { display: grid; gap: 10px; margin-top: 14px; }
.world-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.action-chip { cursor: pointer; padding: 9px 13px; border: 1px solid rgba(180, 229, 141, .16); border-radius: 11px; color: #c9ddc3; background: rgba(31, 61, 38, .85); font-size: 12px; font-weight: 850; transition: background .15s ease, border-color .15s ease, transform .15s ease; }
.action-chip:hover { transform: translateY(-1px); border-color: rgba(180, 229, 141, .42); }
.action-chip.active { border-color: var(--green); color: #142217; background: var(--green); }
.build-select { display: none; width: auto; min-width: 180px; padding: 9px 11px; }
.build-select:not([hidden]) { display: block; }
.world-status { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 18px; padding: 0 2px; }
.world-status .muted { font-size: 11px; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
@media (max-width: 720px) {
  .map-viewport { min-height: 410px; border-radius: 16px; }
  .iso-canvas { height: 410px; }
  .world-heading { display: block; }
  .world-tools { justify-content: flex-end; margin-top: 12px; }
  .world-actions { gap: 6px; }
  .action-chip { padding: 9px 10px; }
  .build-select { width: 100%; min-width: 0; }
  .map-hint { left: 12px; right: 12px; bottom: 12px; max-width: none; text-align: center; }
}

.iso-canvas { cursor: grab; }
.iso-canvas:active { cursor: grabbing; }

.cell-menu {
  position: absolute;
  z-index: 5;
  top: 1rem;
  left: 1rem;
  width: min(280px, calc(100% - 2rem));
  padding: 1rem;
  border: 1px solid rgba(241, 208, 126, .48);
  border-radius: 16px;
  background: rgba(16, 37, 23, .94);
  box-shadow: 0 16px 36px rgba(0, 0, 0, .32);
  backdrop-filter: blur(12px);
}
.cell-menu-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; }
.cell-menu-heading .eyebrow { margin: 0 0 .25rem; }
.cell-menu-heading strong { color: #f3e4b4; }
.cell-menu-description { margin: .65rem 0 .8rem; color: #bfd0bd; }
.cell-menu-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.cell-action { min-height: 40px; }
.cell-build-field { display: grid; gap: .35rem; margin-top: .75rem; color: #d6e0c4; font-size: .82rem; }
.cell-build-field .build-select { width: 100%; }
@media (max-width: 640px) {
  .cell-menu { top: .65rem; left: .65rem; width: min(260px, calc(100% - 1.3rem)); padding: .8rem; }
  .cell-menu-actions { grid-template-columns: 1fr; }
}
