﻿:root {
  --zoo-green: #83b81d;
  --zoo-green-bright: #96d221;
  --zoo-green-deep: #74a319;
  --zoo-red: #ff0000;
  --zoo-maroon: #661818;
  --zoo-cream: #f6f5ef;
  --zoo-ink: #2f241d;
  --zoo-shadow: rgba(69, 47, 35, 0.18);
  --glass-border: rgba(255, 255, 255, 0.55);
  --glass-fill: rgba(255, 255, 255, 0.46);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "Arial", sans-serif;
  color: var(--zoo-ink);
  background:
    radial-gradient(circle at 15% 10%, rgba(150, 210, 33, 0.38), transparent 25%),
    radial-gradient(circle at 88% 14%, rgba(255, 255, 255, 0.65), transparent 20%),
    radial-gradient(circle at 82% 84%, rgba(255, 0, 0, 0.14), transparent 24%),
    linear-gradient(180deg, #f7faef 0%, #eaf5da 42%, #dbeabc 100%);
}

body.telegram-webapp {
  background: var(--tg-theme-secondary-bg-color, #f7faef);
}

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

.hero {
  margin-bottom: 18px;
  text-align: center;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  margin: 0 0 12px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.48);
  border: 1px solid rgba(255, 255, 255, 0.7);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  color: var(--zoo-green-deep);
}

h1 {
  margin: 0;
  font-size: clamp(2.2rem, 6vw, 4rem);
  line-height: 0.94;
  letter-spacing: -0.04em;
  color: #3b231d;
}

.subtitle {
  width: min(760px, 100%);
  margin: 14px auto 0;
  font-size: clamp(1rem, 2vw, 1.08rem);
  line-height: 1.5;
  color: rgba(47, 36, 29, 0.82);
}

.game-shell {
  overflow: hidden;
  padding: 18px;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.32)),
    linear-gradient(135deg, rgba(131, 184, 29, 0.12), rgba(255, 255, 255, 0.18), rgba(255, 0, 0, 0.06));
  border: 1px solid var(--glass-border);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    0 24px 70px var(--zoo-shadow);
}

.hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.stat {
  min-width: 112px;
  padding: 12px 16px;
  border-radius: 20px;
  background: var(--glass-fill);
  border: 1px solid rgba(255, 255, 255, 0.72);
}

.label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(116, 163, 25, 0.95);
}

.stat strong {
  font-size: 1.22rem;
  font-weight: 700;
}

#restart,
.send-result {
  padding: 14px 20px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

#restart {
  margin-left: auto;
  background: linear-gradient(180deg, rgba(150, 210, 33, 0.95), rgba(131, 184, 29, 0.92));
}

.send-result {
  width: 100%;
  background: linear-gradient(180deg, rgba(102, 24, 24, 0.92), rgba(70, 16, 16, 0.92));
}

.send-result:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.canvas-wrap {
  display: flex;
  justify-content: center;
  padding: 12px;
  border-radius: 30px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.54), rgba(255, 255, 255, 0.25));
  border: 1px solid rgba(255, 255, 255, 0.62);
}

.canvas-inner {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 10px;
  border-radius: 26px;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.34), transparent 30%),
    linear-gradient(180deg, rgba(244, 249, 232, 0.92), rgba(236, 244, 219, 0.84));
}

canvas {
  width: min(100%, 512px);
  height: auto;
  border-radius: 24px;
  background: #f4f8e8;
  border: 3px solid rgba(102, 24, 24, 0.6);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-top: 16px;
}

.controls span,
.result-hint {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.44);
  border: 1px solid rgba(255, 255, 255, 0.64);
  color: rgba(47, 36, 29, 0.74);
}

.control-pad {
  display: grid;
  grid-template-columns: repeat(3, minmax(52px, 60px));
  grid-template-areas:
    ". up ."
    "left down right";
  gap: 10px;
  margin-left: auto;
}

.control-key {
  min-height: 52px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(241, 236, 215, 0.92));
  color: var(--zoo-ink);
  font: inherit;
  font-weight: 800;
  font-size: 1.45rem;
  cursor: pointer;
}

.control-pad {
  display: none;
}

.control-key--up { grid-area: up; }
.control-key[data-direction="left"] { grid-area: left; }
.control-key[data-direction="down"] { grid-area: down; }
.control-key[data-direction="right"] { grid-area: right; }

.result-panel {
  margin-top: 16px;
}

.result-hint {
  margin: 10px 0 0;
  text-align: center;
}

.scoreboard {
  margin-top: 18px;
  padding: 18px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.64);
}

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

.eyebrow--small {
  margin-bottom: 8px;
  padding: 6px 10px;
  font-size: 0.72rem;
}

.scoreboard h2 {
  margin: 0;
  font-size: 1.45rem;
}

.scoreboard-count {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.56);
  color: rgba(47, 36, 29, 0.78);
  white-space: nowrap;
}

.leaderboard {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.leaderboard-item,
.leaderboard-empty {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.75);
}

.leaderboard-empty {
  grid-template-columns: 1fr;
  justify-items: center;
  color: rgba(47, 36, 29, 0.68);
}

.leaderboard-rank {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(150, 210, 33, 0.95), rgba(131, 184, 29, 0.9));
  color: #fff;
  font-weight: 800;
}

.leaderboard-meta strong,
.leaderboard-score strong {
  display: block;
}

.leaderboard-meta span,
.leaderboard-score span,
.modal-summary {
  color: rgba(47, 36, 29, 0.7);
}

.leaderboard-score {
  text-align: right;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(47, 36, 29, 0.56);
  backdrop-filter: blur(8px);
  z-index: 10;
}

.modal[hidden] {
  display: none;
}

.modal-card {
  width: min(100%, 460px);
  padding: 24px;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(247, 250, 239, 0.92)),
    linear-gradient(135deg, rgba(131, 184, 29, 0.14), rgba(255, 255, 255, 0.1));
  box-shadow: 0 24px 60px rgba(47, 36, 29, 0.24);
}

.modal-card h2 {
  margin: 0 0 10px;
  font-size: 1.8rem;
}

.modal-summary {
  margin: 0 0 16px;
  line-height: 1.5;
}

.modal-form {
  display: grid;
  gap: 14px;
}

.input-group {
  display: grid;
  gap: 8px;
  font-weight: 600;
}

.input-group span {
  color: rgba(47, 36, 29, 0.88);
}

.input-group input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid rgba(116, 163, 25, 0.24);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--zoo-ink);
  font: inherit;
}

.input-group input:focus {
  outline: 2px solid rgba(131, 184, 29, 0.4);
  border-color: rgba(131, 184, 29, 0.5);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
}

.save-score {
  padding: 14px 20px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(180deg, rgba(150, 210, 33, 0.96), rgba(116, 163, 25, 0.94));
}

@media (max-width: 700px) {
  .app {
    width: min(100% - 16px, 100%);
    padding-top: 14px;
  }

  .game-shell {
    padding: 14px;
    border-radius: 22px;
  }

  .stat {
    min-width: calc(50% - 8px);
  }

  #restart {
    width: 100%;
    margin-left: 0;
  }

  .controls span,
  .result-hint,
  .control-pad,
  .scoreboard-count {
    width: 100%;
    margin-left: 0;
  }

  .control-pad {
    display: grid;
    justify-content: center;
  }

  .scoreboard-header,
  .leaderboard-item {
    grid-template-columns: 1fr;
    text-align: left;
  }

  .leaderboard-score,
  .modal-actions {
    text-align: left;
    justify-content: stretch;
  }

  .save-score {
    width: 100%;
  }
}
