/* style.css — Grovebrook */
:root{
  color-scheme: dark;
  --bg: #141a26;
  --bg2: #1b2333;
  --surface: #232d42;
  --surface2: #2c37500;
  --surface-2: #2c3750;
  --line: #34405c;
  --text: #e9e6dc;
  --muted: #9aa3b8;
  --accent: #f0b454;
  --accent-2: #7bd1a0;
  --grass-a: #3c5a3a;
  --grass-b: #4a6b46;
  --grass-line: #35502f;
  --water: #2f5e86;
  --water-2: #3f7aa8;
  --rock: #4b4f59;
  --rock-2: #5a5f6b;
  --danger: #e07070;
  --good: #7bd1a0;
  --shadow: 0 6px 18px rgba(0,0,0,.35);
  --radius: 14px;
}
html[data-theme="dark"]{ color-scheme: dark; }
html[data-theme="light"], html[data-theme="light"] *{}
@media (prefers-color-scheme: light){
  :root:not([data-theme="dark"]){
    color-scheme: light;
    --bg: #f1ead6;
    --bg2: #f7f1e1;
    --surface: #fffaf0;
    --surface-2: #f3ead4;
    --line: #e2d8bd;
    --text: #3a3024;
    --muted: #7a6f5c;
    --accent: #c47a1e;
    --accent-2: #4f9d6a;
    --grass-a: #8cc24a;
    --grass-b: #7ab73e;
    --grass-line: #6aa035;
    --water: #62a7d4;
    --water-2: #7cbbdf;
    --rock: #a7adb8;
    --rock-2: #b9bec8;
    --shadow: 0 6px 16px rgba(80,60,30,.18);
  }
}
html[data-theme="light"]{
  color-scheme: light;
  --bg: #f1ead6;
  --bg2: #f7f1e1;
  --surface: #fffaf0;
  --surface-2: #f3ead4;
  --line: #e2d8bd;
  --text: #3a3024;
  --muted: #7a6f5c;
  --accent: #c47a1e;
  --accent-2: #4f9d6a;
  --grass-a: #8cc24a;
  --grass-b: #7ab73e;
  --grass-line: #6aa035;
  --water: #62a7d4;
  --water-2: #7cbbdf;
  --rock: #a7adb8;
  --rock-2: #b9bec8;
  --shadow: 0 6px 16px rgba(80,60,30,.18);
}

*{ box-sizing: border-box; }
html, body{ margin:0; padding:0; height:100%; }
body{
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  touch-action: manipulation;
  -webkit-font-smoothing: antialiased;
}
button{ font-family: inherit; }

.app{
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100%;
  max-width: 1100px;
  margin: 0 auto;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(240,180,84,.10), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(123,209,160,.08), transparent 60%),
    var(--bg);
}

/* ---- top bar ---- */
.topbar{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--bg2), transparent);
  flex-wrap: wrap;
}
.brand{ display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo{
  width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--surface), var(--surface-2));
  border: 1px solid var(--line);
  font-size: 22px;
  box-shadow: var(--shadow);
}
.brand h1{ font-size: 18px; margin: 0; letter-spacing: .3px; }
.tag{ margin: 2px 0 0; font-size: 11px; color: var(--muted); }

.res{ display: flex; gap: 6px; flex-wrap: wrap; }
.pill{
  position: relative;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px; font-weight: 600;
  min-width: 56px; justify-content: center;
}
.pill .ri{ font-size: 14px; }
.pill .rv{ font-variant-numeric: tabular-nums; }
.pill .float{
  position: absolute; left: 50%; top: -2px;
  transform: translateX(-50%);
  color: var(--good); font-weight: 800; font-size: 12px;
  animation: floatUp .9s ease-out forwards;
  pointer-events: none;
}
@keyframes floatUp{
  0%{ opacity: 0; transform: translate(-50%, 4px); }
  20%{ opacity: 1; }
  100%{ opacity: 0; transform: translate(-50%, -22px); }
}

/* ---- stage ---- */
.stage{
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 14px;
  padding: 14px 16px;
  min-height: 0;
}
.board-wrap{
  position: relative;
  display: flex; align-items: center; justify-content: center;
  min-height: 0;
}
.board{
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 6px;
  width: 100%;
  max-width: min(72vh, 560px);
  aspect-ratio: 1 / 1;
  padding: 10px;
  background: linear-gradient(160deg, var(--surface), var(--surface-2));
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.tile{
  position: relative;
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: clamp(16px, 4.2vw, 30px);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
  user-select: none;
}
.tile.grass{
  background: linear-gradient(150deg, var(--grass-a), var(--grass-b));
  box-shadow: inset 0 0 0 1px var(--grass-line);
}
.tile.grass::after{
  content:""; position:absolute; inset:0; border-radius:10px;
  background: radial-gradient(120% 80% at 50% 120%, rgba(0,0,0,.18), transparent 60%);
  pointer-events:none;
}
.tile.water{
  background: linear-gradient(150deg, var(--water), var(--water-2));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
  cursor: default;
}
.tile.water .ter{ filter: drop-shadow(0 1px 1px rgba(0,0,0,.25)); animation: bob 3.2s ease-in-out infinite; }
.tile.rock{
  background: linear-gradient(150deg, var(--rock), var(--rock-2));
  cursor: default;
}
.tile.rock .ter{ font-size: .8em; opacity: .9; }
.tile.built{
  background: linear-gradient(150deg, var(--grass-a), var(--grass-b));
  box-shadow: inset 0 0 0 1px var(--grass-line), inset 0 -8px 12px rgba(0,0,0,.18);
}
.tile.built .bi{
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.35));
  animation: bob 3.6s ease-in-out infinite;
  animation-delay: var(--d, 0s);
}
.tile.built:nth-child(odd) .bi{ animation-delay: .4s; }
.tile.built:nth-child(3n) .bi{ animation-delay: .8s; }
.tile.boosted{ box-shadow: inset 0 0 0 2px var(--accent), inset 0 -8px 12px rgba(0,0,0,.18); }
.tile.hall{ background: linear-gradient(150deg, #4a4030, #5a4d38); }
.tile.aura{ box-shadow: inset 0 0 0 2px #d68fb8, inset 0 -8px 12px rgba(0,0,0,.18); }
.tile.placeable{ outline: 2px dashed var(--accent); outline-offset: -6px; }
.tile.placeable:hover{ transform: translateY(-2px); filter: brightness(1.08); }
.tile.unaffordable{ outline: 2px dashed var(--danger); outline-offset: -6px; opacity:.85; }
.tile.demolishable{ outline: 2px dashed var(--danger); outline-offset: -6px; }
.tile.demolishable:hover{ filter: brightness(1.1) hue-rotate(-10deg); }
.tile.built:hover{ transform: translateY(-2px); }

@keyframes bob{
  0%,100%{ transform: translateY(0); }
  50%{ transform: translateY(-3px); }
}

/* ---- info panel ---- */
.info{
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  overflow: auto;
  box-shadow: var(--shadow);
  font-size: 13px;
}
.info-sec{ padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.info-sec:last-of-type{ border-bottom: none; }
.info h3{ margin: 0 0 8px; font-size: 13px; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); }
.kpis{ display: flex; gap: 8px; }
.kpi{ flex:1; background: var(--surface-2); border-radius: 10px; padding: 8px; text-align: center; }
.kpi .kv{ display:block; font-size: 18px; font-weight: 800; color: var(--accent); }
.kpi .kl{ display:block; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing:.5px; }
.rates{ display:flex; flex-wrap: wrap; gap: 6px; }
.rate{ background: var(--surface-2); padding: 4px 8px; border-radius: 8px; font-weight: 600; font-size: 12px; }
.rate.muted{ color: var(--muted); font-weight: 500; }
.desc{ margin: 0 0 8px; color: var(--muted); line-height: 1.5; font-size: 12px; }
.selected-info h3{ color: var(--accent); text-transform: none; font-size: 15px; letter-spacing: 0; }
.cost-line, .out-line{ font-size: 13px; margin-top: 4px; }
.out-line{ color: var(--muted); }
.note{ margin-top: 6px; font-size: 11px; color: var(--accent-2); }
.info-sec.warn h3{ color: var(--danger); }
.info-sec.hint h3{ color: var(--accent-2); }
.actions{ display:flex; gap: 8px; margin-top: 4px; }
.btn{
  flex:1; padding: 9px 10px; border-radius: 10px; cursor: pointer;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); font-size: 12px; font-weight: 600;
  transition: transform .1s ease, background .15s ease, border-color .15s ease;
}
.btn:hover{ transform: translateY(-1px); }
.btn:active{ transform: translateY(0); }
.btn.on{ background: var(--danger); border-color: var(--danger); color:#fff; }
.btn.ghost{ background: transparent; }

/* cost & out chips */
.cost-item{ display:inline-flex; align-items:center; gap:2px; font-size:12px; margin-right:6px; }
.cost-item b{ font-weight: 700; }
.cost-item.short{ color: var(--danger); }
.out-item{ display:inline-flex; align-items:center; gap:2px; font-size:11px; margin-right:6px; color: var(--good); }

/* ---- toast ---- */
.toast{
  position: absolute; left: 50%; bottom: 14px; transform: translate(-50%, 12px);
  background: rgba(20,26,38,.92); color: #fff;
  border: 1px solid var(--line);
  padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  box-shadow: var(--shadow); white-space: nowrap;
}
.toast.show{ opacity: 1; transform: translate(-50%, 0); }

/* ---- shop ---- */
.shop-wrap{
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, transparent, var(--bg2));
  padding: 10px 16px 14px;
}
.shop-head{
  display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px;
  flex-wrap: wrap;
}
.sh-title{ font-weight: 800; font-size: 14px; letter-spacing: .4px; text-transform: uppercase; }
.hint-small{ font-size: 12px; color: var(--muted); }
.stats{ margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 600; }
.shop{
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(140px, 1fr);
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}
.shop::-webkit-scrollbar{ height: 6px; }
.shop::-webkit-scrollbar-thumb{ background: var(--line); border-radius: 3px; }

.card{
  text-align: left; cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px; padding: 10px;
  color: var(--text);
  transition: transform .12s ease, border-color .12s ease, background .15s ease;
}
.card:hover{ transform: translateY(-2px); border-color: var(--accent); }
.card.selected{ border-color: var(--accent); background: linear-gradient(160deg, var(--surface), rgba(240,180,84,.14)); box-shadow: 0 0 0 2px var(--accent); }
.card.disabled{ opacity: .55; filter: grayscale(.4); }
.card-top{ display:flex; align-items:center; gap:6px; margin-bottom:6px; }
.card-icon{ font-size: 18px; }
.card-name{ font-weight: 700; font-size: 13px; }
.card-cost{ display:flex; flex-wrap: wrap; gap: 2px; margin-bottom: 4px; }
.card-out{ display:flex; flex-wrap: wrap; gap: 2px; }

/* ---- responsive ---- */
@media (max-width: 720px){
  .stage{ grid-template-columns: 1fr; grid-template-rows: 1fr auto; padding: 10px; gap: 10px; }
  .info{ max-height: 180px; order: 2; }
  .board{ max-width: min(92vw, 60vh); }
  .brand h1{ font-size: 16px; }
  .tag{ display: none; }
  .topbar{ padding: 10px 12px; }
  .pill{ padding: 5px 8px; font-size: 12px; min-width: 48px; }
  .res{ gap: 4px; }
}
@media (max-width: 420px){
  .res{ width: 100%; justify-content: space-between; }
  .pill{ flex: 1; min-width: 0; }
  .shop{ grid-auto-columns: minmax(120px, 1fr); }
}
