/* ============================================================ Tokens */
:root {
  --ink-950: #050c09;
  --ink-900: #07100c;
  --ink-850: #0a1610;
  --ink-800: #0e1e17;

  --glass: rgba(13, 28, 21, .74);
  --glass-2: rgba(20, 40, 30, .55);
  --line: rgba(126, 227, 170, .13);
  --line-strong: rgba(126, 227, 170, .3);

  --text: #e9f6ee;
  --muted: #8fb0a0;
  --dim: #5d7a6c;

  --seed: #ffc95c;
  --water: #5ec2ff;
  --leaf: #5fd68e;
  --humus: #d99a63;
  --crit: #ffe066;
  --danger: #ff7f6d;

  --r-xl: 26px;
  --r-lg: 18px;
  --r-md: 13px;
  --r-sm: 9px;

  --bevel: inset 0 1px 0 rgba(255, 255, 255, .09), inset 0 -2px 0 rgba(0, 0, 0, .28);
  --lift: 0 14px 34px -16px rgba(0, 0, 0, .85);

  --font-display: 'Fredoka', ui-rounded, system-ui, sans-serif;
  --font-ui: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --topbar-h: clamp(64px, 8vh, 86px);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--font-ui);
  color: var(--text);
  background: var(--ink-900);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: manipulation;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(120vw 80vh at 50% -20%, rgba(95, 214, 142, .16), transparent 62%),
    radial-gradient(70vw 60vh at 105% 110%, rgba(94, 194, 255, .1), transparent 60%),
    linear-gradient(175deg, #0a1610 0%, #07100c 45%, #050c09 100%);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Muss nach dem Reset stehen: display-Regeln unten würden [hidden] sonst schlagen. */
[hidden] { display: none !important; }

button, input, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
svg { display: block; width: 100%; height: 100%; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--leaf); outline-offset: 2px; }

/* ============================================================== Boot */
.boot {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1rem;
  background: var(--ink-900);
  transition: opacity .5s ease, visibility .5s;
}
.boot.is-gone { opacity: 0; visibility: hidden; }
.boot__mark {
  width: 74px;
  height: 74px;
  animation: sprout 1.4s cubic-bezier(.22, 1, .3, 1) both, breathe 2.6s ease-in-out 1.2s infinite;
}
.boot__name {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  animation: fade .8s .3s both;
}
@keyframes sprout { from { transform: scale(.4) translateY(14px); opacity: 0; } }
@keyframes breathe { 50% { transform: scale(1.07); } }
@keyframes fade { from { opacity: 0; } }

/* ============================================================== Game */
.game {
  position: relative;
  z-index: 2;
  height: 100dvh;
  display: grid;
  grid-template-rows: var(--topbar-h) 1fr;
}

/* ============================================================ Topbar */
.topbar {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: clamp(.7rem, 2.2vw, 2.2rem);
  padding: 0 clamp(.8rem, 2vw, 1.6rem);
  background: linear-gradient(180deg, rgba(12, 26, 19, .92), rgba(9, 20, 15, .78));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 30px -18px #000;
}

.brand { display: flex; align-items: center; gap: .55rem; }
.brand__mark { width: 26px; height: 26px; color: var(--leaf); filter: drop-shadow(0 0 10px rgba(95, 214, 142, .5)); }
.brand__name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  background: linear-gradient(180deg, #eafaf0, #8fd6ab);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.wallet { display: grid; gap: .1rem; }
.wallet__amount { display: flex; align-items: baseline; gap: .4rem; }
.wallet__value {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.4rem, 2.9vw, 2.3rem);
  line-height: 1;
  color: var(--seed);
  text-shadow: 0 0 24px rgba(255, 201, 92, .35);
  font-variant-numeric: tabular-nums;
  transition: transform .12s cubic-bezier(.2, 1.6, .4, 1);
}
.wallet__value.is-bump { transform: scale(1.055); }
.wallet__unit { font-size: .8rem; font-weight: 600; color: var(--dim); letter-spacing: .04em; }
.wallet__rate { font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.gauge { max-width: 340px; display: grid; gap: .28rem; }
.gauge__head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.gauge__label { font-size: .66rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); }
.gauge__net { font-size: .7rem; font-variant-numeric: tabular-nums; color: var(--water); }
.gauge__net.is-negative { color: #ff9a7d; }
.gauge__track {
  position: relative;
  height: 18px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .45);
  border: 1px solid rgba(94, 194, 255, .18);
  overflow: hidden;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, .6);
}
.gauge__fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #2b8fd0, #5ec2ff 60%, #a5e5ff);
  box-shadow: 0 0 18px rgba(94, 194, 255, .5);
  transition: width .18s ease-out;
}
.gauge__fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 35%, rgba(255, 255, 255, .45) 50%, transparent 65%);
  background-size: 240% 100%;
  animation: shimmer 2.6s linear infinite;
}
@keyframes shimmer { to { background-position: -240% 0; } }
.gauge__mark { position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(255, 255, 255, .28); }
.gauge__text {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  font-size: .68rem;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .8);
  font-variant-numeric: tabular-nums;
}
.gauge__hint { font-size: .68rem; color: var(--dim); }
.gauge.is-dry .gauge__track { border-color: rgba(255, 122, 109, .5); animation: dry 1.6s ease-in-out infinite; }
@keyframes dry { 50% { box-shadow: inset 0 2px 6px rgba(0, 0, 0, .6), 0 0 14px rgba(255, 122, 109, .4); } }

.chips { display: flex; align-items: center; gap: .45rem; }
.chip {
  display: flex;
  align-items: center;
  gap: .35rem;
  height: 36px;
  padding: 0 .7rem;
  border-radius: 999px;
  background: var(--glass-2);
  border: 1px solid var(--line);
  font-size: .82rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.chip svg { width: 15px; height: 15px; }
.chip--humus { color: var(--humus); }
.chip--ach { color: var(--seed); }

.iconbtn {
  width: 36px;
  height: 36px;
  display: grid;
  place-content: center;
  border-radius: var(--r-md);
  background: var(--glass-2);
  border: 1px solid var(--line);
  color: var(--muted);
  transition: transform .14s, color .14s, border-color .14s;
}
.iconbtn svg { width: 17px; height: 17px; }
.iconbtn:hover { color: var(--text); border-color: var(--line-strong); transform: translateY(-1px); }
.iconbtn.is-off { color: var(--dim); opacity: .6; }

/* ============================================================= Board */
.board {
  display: grid;
  grid-template-columns: 1fr min(30vw, 430px);
  gap: clamp(.6rem, 1.2vw, 1rem);
  padding: clamp(.6rem, 1.2vw, 1rem);
  min-height: 0;
}

/* ============================================================ Button */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .62rem 1.1rem;
  border-radius: var(--r-md);
  font-family: var(--font-display);
  font-weight: 500;
  font-size: .92rem;
  color: var(--text);
  background: linear-gradient(180deg, rgba(255, 255, 255, .08), rgba(255, 255, 255, .02));
  border: 1px solid var(--line-strong);
  box-shadow: var(--bevel);
  transition: transform .1s, filter .15s, box-shadow .15s;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: translateY(2px); box-shadow: inset 0 2px 6px rgba(0, 0, 0, .4); }
.btn--primary {
  background: linear-gradient(180deg, #63dd94, #2f9b5d);
  border-color: #7ff0ab;
  color: #052014;
  box-shadow: var(--bevel), 0 8px 22px -10px rgba(95, 214, 142, .9);
}
.btn--humus {
  background: linear-gradient(180deg, #e2a973, #a9683a);
  border-color: #f0c39a;
  color: #22110a;
  box-shadow: var(--bevel), 0 8px 22px -10px rgba(217, 154, 99, .9);
}
.btn--ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn--danger { border-color: rgba(255, 127, 109, .45); color: var(--danger); }
.btn:disabled { opacity: .4; pointer-events: none; }

/* ============================================================ Toasts */
.toasts {
  position: fixed;
  right: clamp(.7rem, 2vw, 1.4rem);
  bottom: clamp(.7rem, 2vw, 1.4rem);
  z-index: 60;
  display: flex;
  flex-direction: column-reverse;
  gap: .5rem;
  pointer-events: none;
  max-width: min(92vw, 360px);
}
.toast {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .7rem .9rem;
  border-radius: var(--r-md);
  background: linear-gradient(180deg, rgba(24, 48, 36, .96), rgba(14, 30, 22, .96));
  border: 1px solid var(--line-strong);
  box-shadow: var(--lift);
  backdrop-filter: blur(10px);
  animation: toastIn .42s cubic-bezier(.2, 1.3, .4, 1) both;
}
.toast.is-out { animation: toastOut .32s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px) scale(.94); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px) scale(.96); } }
.toast__icon {
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-content: center;
  border-radius: 10px;
  background: rgba(255, 201, 92, .14);
  color: var(--seed);
}
.toast__icon svg { width: 19px; height: 19px; }
.toast__kicker { font-size: .64rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--seed); }
.toast__title { font-family: var(--font-display); font-size: .95rem; font-weight: 500; }
.toast__sub { font-size: .75rem; color: var(--muted); }

/* ============================================================= Modal */
.modal { position: fixed; inset: 0; z-index: 70; display: grid; place-content: center; padding: 1rem; }
.modal__scrim { position: absolute; inset: 0; background: rgba(3, 8, 6, .74); backdrop-filter: blur(8px); animation: fade .25s both; }
.modal__box {
  position: relative;
  width: min(94vw, 540px);
  max-height: 86dvh;
  overflow: auto;
  padding: clamp(1.3rem, 3vw, 2rem);
  border-radius: var(--r-xl);
  background: linear-gradient(180deg, rgba(22, 44, 33, .98), rgba(11, 24, 18, .98));
  border: 1px solid var(--line-strong);
  box-shadow: var(--lift), 0 0 90px -30px rgba(95, 214, 142, .5);
  animation: modalIn .35s cubic-bezier(.2, 1.2, .35, 1) both;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(18px) scale(.96); } }
.modal__x { position: absolute; top: .8rem; right: .8rem; width: 30px; height: 30px; color: var(--dim); }
.modal__x:hover { color: var(--text); }
.modal__x svg { width: 18px; height: 18px; }
.modal h2 { font-family: var(--font-display); font-weight: 600; font-size: 1.4rem; margin-bottom: .3rem; }
.modal p { color: var(--muted); font-size: .9rem; line-height: 1.55; }
.modal__row { display: flex; gap: .6rem; margin-top: 1.3rem; flex-wrap: wrap; }
.modal__stat {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: .5rem 0; border-bottom: 1px solid var(--line);
  font-size: .86rem;
}
.modal__stat span:last-child { font-family: var(--font-display); color: var(--text); font-variant-numeric: tabular-nums; }
.modal__stat span:first-child { color: var(--muted); }
.modal textarea {
  width: 100%; height: 120px; margin-top: .8rem; padding: .6rem;
  border-radius: var(--r-sm); border: 1px solid var(--line);
  background: rgba(0, 0, 0, .35); font-family: monospace; font-size: .72rem;
  resize: none; user-select: text;
}
.modal__big {
  font-family: var(--font-display); font-size: 2.4rem; font-weight: 600;
  color: var(--seed); text-align: center; margin: .8rem 0 .2rem;
  text-shadow: 0 0 30px rgba(255, 201, 92, .4);
}

/* ======================================================== Responsive */
@media (max-width: 1000px) {
  .board { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) minmax(0, 46dvh); }
  .gauge { max-width: none; }
  .brand__name { display: none; }
}
@media (max-width: 640px) {
  .topbar { grid-template-columns: auto 1fr auto; grid-template-areas: "brand wallet chips" "gauge gauge gauge"; height: auto; padding: .5rem .7rem .6rem; gap: .4rem .7rem; }
  .game { grid-template-rows: auto 1fr; }
  .brand { grid-area: brand; }
  .wallet { grid-area: wallet; }
  .gauge { grid-area: gauge; }
  .chips { grid-area: chips; }
  .gauge__hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .01s !important; }
}
