:root {
  color-scheme: dark;
  --ink: #f8f2d3;
  --muted: #bfb783;
  --bg: #15130f;
  --panel: rgba(32, 28, 22, 0.92);
  --panel-strong: rgba(45, 37, 25, 0.96);
  --line: rgba(255, 222, 91, 0.24);
  --yellow: #ffd83d;
  --gold: #f2a81d;
  --green: #62d68a;
  --blue: #5ab4ff;
  --red: #ff6262;
  --shadow: rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(255, 216, 61, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(98, 214, 138, 0.06) 1px, transparent 1px),
    linear-gradient(135deg, #15130f 0%, #202219 46%, #101923 100%);
  background-size: 28px 28px, 28px 28px, 100% 100%;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

.game-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
  gap: 20px;
  padding: 18px;
}

.banana-zone {
  position: relative;
  min-height: calc(100vh - 36px);
  display: grid;
  grid-template-rows: auto auto minmax(280px, 1fr) auto;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 216, 61, 0.2), transparent 42%),
    linear-gradient(160deg, rgba(33, 43, 30, 0.7), rgba(17, 17, 17, 0.88));
  box-shadow: 0 18px 50px var(--shadow);
}

.top-bar,
.score-board,
.stage-strip {
  width: min(760px, calc(100% - 32px));
  margin: 0 auto;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 18px;
}

.top-bar a {
  color: var(--yellow);
  text-decoration: none;
  font-weight: 800;
}

.profile-line {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 14px;
  min-width: 0;
}

.profile-line span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-board {
  text-align: center;
  padding: 22px 0 4px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.score-board strong {
  display: block;
  font-size: clamp(42px, 7vw, 92px);
  line-height: 0.95;
  color: var(--yellow);
  text-shadow: 0 5px 0 rgba(73, 48, 0, 0.75), 0 0 32px rgba(255, 216, 61, 0.28);
}

.score-board span {
  display: inline-block;
  margin-top: 10px;
  color: var(--blue);
  font-weight: 800;
}

.banana-button {
  justify-self: center;
  align-self: center;
  width: min(68vh, 78vw, 520px);
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
  filter: drop-shadow(0 22px 28px rgba(0, 0, 0, 0.42));
  transition: transform 140ms ease, filter 140ms ease;
}

.banana-button:hover {
  transform: translateY(-3px) scale(1.012);
  filter: drop-shadow(0 25px 32px rgba(0, 0, 0, 0.46));
}

.banana-button:active,
.banana-button.clicked {
  animation: banana-press 240ms ease-out;
}

.banana-button img {
  display: block;
  width: min(82%, 440px);
  max-height: 82%;
  object-fit: contain;
  user-select: none;
  image-rendering: auto;
  pointer-events: none;
}

.banana-button.pixel img {
  image-rendering: pixelated;
}

@keyframes banana-press {
  0% { transform: scale(1); }
  38% { transform: scale(0.88) rotate(-2deg); }
  72% { transform: scale(1.08) rotate(2deg); }
  100% { transform: scale(1); }
}

.stage-strip {
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(10, 10, 8, 0.58);
}

.stage-strip > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.stage-strip span,
.stage-strip strong {
  font-weight: 900;
}

.stage-strip small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.stage-meter {
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.stage-meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--yellow), var(--gold));
  transition: width 220ms ease;
}

.panel-stack {
  min-height: calc(100vh - 36px);
  display: grid;
  align-content: start;
  gap: 12px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.22);
  padding: 14px;
}

.profile-panel h1,
.panel h2 {
  margin: 0;
  line-height: 1.05;
}

.profile-panel h1 {
  font-size: clamp(28px, 4vw, 42px);
  color: var(--yellow);
}

.field-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  margin-top: 14px;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(255, 216, 61, 0.28);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.28);
  color: var(--ink);
  padding: 0 10px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--yellow);
  box-shadow: 0 0 0 3px rgba(255, 216, 61, 0.14);
}

.stats-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.stats-panel div {
  min-width: 0;
  border-radius: 6px;
  background: var(--panel-strong);
  padding: 10px;
}

.stats-panel span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.stats-panel strong {
  display: block;
  margin-top: 5px;
  color: var(--yellow);
  font-size: 20px;
  overflow-wrap: anywhere;
}

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

.panel-title span {
  color: var(--green);
  font-weight: 900;
}

.evolution-preview {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.stage-chip {
  min-height: 70px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  opacity: 0.55;
  overflow: hidden;
}

.stage-chip.active {
  opacity: 1;
  border-color: var(--yellow);
  box-shadow: 0 0 18px rgba(255, 216, 61, 0.16);
}

.stage-chip img {
  max-width: 92%;
  max-height: 60px;
  object-fit: contain;
}

.stage-chip.pixel img {
  image-rendering: pixelated;
}

.buy-button,
.rebirth-button,
.text-button {
  min-height: 42px;
  border: 1px solid rgba(255, 216, 61, 0.35);
  border-radius: 6px;
  background: linear-gradient(180deg, #ffe25f, #d78b16);
  color: #241806;
  font-weight: 950;
  cursor: pointer;
  box-shadow: 0 6px 0 #6d470a;
  transition: transform 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
}

.buy-button,
.rebirth-button {
  width: 100%;
}

.buy-button:active,
.rebirth-button:active,
.text-button:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #6d470a;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.text-button {
  min-height: 34px;
  padding: 0 12px;
  background: rgba(90, 180, 255, 0.14);
  color: var(--blue);
  box-shadow: none;
  border-color: rgba(90, 180, 255, 0.42);
}

.text-button.danger {
  color: var(--red);
  border-color: rgba(255, 98, 98, 0.38);
  background: rgba(255, 98, 98, 0.1);
}

.upgrade-list {
  display: grid;
  gap: 9px;
}

.upgrade-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 11px;
  border-radius: 6px;
  background: var(--panel-strong);
}

.upgrade-row h3 {
  margin: 0;
  font-size: 16px;
}

.upgrade-row p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.upgrade-row .level {
  display: inline-block;
  margin-top: 7px;
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
}

.upgrade-row button {
  min-width: 110px;
  padding: 0 10px;
}

.rebirth-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 0.7fr);
  gap: 12px;
  align-items: center;
}

.rebirth-panel p {
  margin: 7px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.reset-panel {
  text-align: right;
}

.cheat-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.72);
}

.cheat-overlay.hidden {
  display: none;
}

.cheat-panel {
  width: min(520px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 16px;
  border: 1px solid rgba(255, 216, 61, 0.52);
  border-radius: 8px;
  background: #201c16;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.62);
}

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

.cheat-head h2 {
  margin: 0;
  color: var(--yellow);
}

.cheat-head button {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 98, 98, 0.45);
  border-radius: 6px;
  background: rgba(255, 98, 98, 0.12);
  color: var(--red);
  font-weight: 950;
  cursor: pointer;
}

.cheat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.cheat-grid button {
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid rgba(98, 214, 138, 0.38);
  border-radius: 6px;
  background: rgba(98, 214, 138, 0.11);
  color: var(--green);
  font-weight: 900;
  cursor: pointer;
}

.cheat-grid button.wide {
  grid-column: 1 / -1;
  color: var(--blue);
  border-color: rgba(90, 180, 255, 0.42);
  background: rgba(90, 180, 255, 0.12);
}

.cheat-grid button.active {
  color: #171109;
  border-color: var(--yellow);
  background: var(--yellow);
}

.cheat-status {
  min-height: 20px;
  margin: 13px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.fall-layer {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 10;
}

.mini-banana {
  position: fixed;
  top: -90px;
  left: 0;
  width: var(--size, 54px);
  height: var(--size, 54px);
  object-fit: contain;
  pointer-events: none;
  animation: banana-fall var(--duration, 1800ms) linear forwards;
  transform: translate3d(0, 0, 0);
  filter: drop-shadow(0 8px 8px rgba(0, 0, 0, 0.32));
}

.mini-banana.pixel {
  image-rendering: pixelated;
}

@keyframes banana-fall {
  0% {
    transform: translate3d(0, -20px, 0) rotate(0deg) scale(0.88);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  100% {
    transform: translate3d(var(--drift, 0px), calc(100vh + 130px), 0) rotate(var(--spin, 240deg)) scale(1);
    opacity: 0.85;
  }
}

.pop-text {
  position: fixed;
  z-index: 11;
  pointer-events: none;
  color: var(--yellow);
  font-weight: 950;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.55);
  animation: pop-score 850ms ease-out forwards;
}

@keyframes pop-score {
  0% {
    opacity: 0;
    transform: translate(-50%, 6px) scale(0.8);
  }
  18% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -78px) scale(1.2);
  }
}

@media (max-width: 940px) {
  .game-shell {
    grid-template-columns: 1fr;
  }

  .banana-zone,
  .panel-stack {
    min-height: auto;
  }

  .banana-zone {
    min-height: 620px;
  }
}

@media (max-width: 620px) {
  .game-shell {
    padding: 10px;
    gap: 10px;
  }

  .banana-zone {
    min-height: 540px;
  }

  .top-bar,
  .score-board,
  .stage-strip {
    width: calc(100% - 20px);
  }

  .top-bar,
  .field-grid,
  .rebirth-panel {
    grid-template-columns: 1fr;
  }

  .top-bar {
    display: grid;
  }

  .field-grid,
  .stats-panel {
    grid-template-columns: 1fr;
  }

  .upgrade-row {
    grid-template-columns: 1fr;
  }

  .upgrade-row button {
    width: 100%;
  }

  .cheat-grid {
    grid-template-columns: 1fr;
  }

  .cheat-grid button.wide {
    grid-column: auto;
  }
}
