:root {
  --bg: #f4f8f0;
  --card: #fffdf5;
  --green: #6fa65c;
  --green-dark: #416b39;
  --green-soft: #e9f5df;
  --mint: #dff3e8;
  --blue: #dff3ff;
  --cream: #fff8e8;
  --text: #263326;
  --muted: #6d7b67;
  --border: rgba(83, 130, 66, 0.22);
  --shadow: rgba(34, 60, 29, 0.16);
  --danger: #b45a50;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 10%, #ffffff 0%, transparent 32%),
    radial-gradient(circle at 80% 20%, #e3f6ff 0%, transparent 30%),
    linear-gradient(180deg, #f8fbf5 0%, #edf5e9 100%);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

button {
  font: inherit;
}

.page {
  min-height: 100vh;
  padding: 32px 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-shell {
  position: relative;
  width: min(1100px, 100%);
  aspect-ratio: 1100 / 420;
  max-height: 420px;
  min-height: 350px;
  overflow: hidden;
  user-select: none;
  touch-action: manipulation;
  outline: none;

  border: 1px solid var(--border);
  border-radius: 34px;
  background:
    linear-gradient(180deg, rgba(255, 253, 245, 0.96), rgba(246, 255, 240, 0.9));
  box-shadow:
    0 32px 90px var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.topbar {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 12;
  padding: clamp(18px, 3vw, 32px) clamp(20px, 4vw, 42px);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  pointer-events: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand h1 {
  margin: 0;
  color: var(--green-dark);
  font-size: clamp(28px, 4vw, 48px);
  letter-spacing: -1.8px;
  line-height: 0.95;
}

.brand p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: clamp(12px, 1.4vw, 15px);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-frog {
  position: relative;
  width: clamp(54px, 7vw, 76px);
  height: clamp(54px, 7vw, 76px);
  border-radius: 24px;
  background:
    radial-gradient(circle at 50% 35%, #9bdc78 0 35%, #78b963 36% 100%);
  box-shadow:
    inset 0 -10px 0 rgba(55, 104, 49, 0.12),
    0 12px 24px rgba(83, 130, 66, 0.22);
}

.brand-frog::before,
.brand-frog::after {
  content: "";
  position: absolute;
  top: 14px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #1f2f1f;
}

.brand-frog::before {
  left: 18px;
}

.brand-frog::after {
  right: 18px;
}

.brand-frog span {
  position: absolute;
  left: 50%;
  bottom: 18px;
  width: 28px;
  height: 12px;
  border-bottom: 4px solid #416b39;
  border-radius: 0 0 999px 999px;
  transform: translateX(-50%);
}

.hud {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 580px;
  color: var(--muted);
  font-size: clamp(11px, 1.15vw, 14px);
  font-weight: 700;
}

.hud span {
  padding: 8px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.58);
  box-shadow:
    inset 0 0 0 1px rgba(83, 130, 66, 0.12),
    0 8px 18px rgba(54, 86, 47, 0.06);
  backdrop-filter: blur(8px);
}

.hud strong {
  margin-left: 4px;
  color: var(--green-dark);
}

.pause-btn {
  position: absolute;
  right: 34px;
  bottom: 24px;
  z-index: 13;
  min-height: 36px;
  padding: 0 15px;
  border: 0;
  border-radius: 999px;
  color: var(--green-dark);
  background: rgba(255, 255, 255, 0.62);
  box-shadow:
    inset 0 0 0 1px rgba(83, 130, 66, 0.14),
    0 10px 24px rgba(54, 86, 47, 0.08);
  backdrop-filter: blur(8px);
  cursor: pointer;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    radial-gradient(circle at 50% 40%, rgba(255, 253, 245, 0.82), rgba(255, 253, 245, 0.32));
  backdrop-filter: blur(5px);
}

.overlay.hidden {
  display: none;
}

.panel {
  width: min(650px, 96%);
  max-height: 94%;
  overflow: auto;
  padding: clamp(20px, 3vw, 32px);
  text-align: center;
  border: 1px solid rgba(83, 130, 66, 0.16);
  border-radius: 30px;
  background: rgba(255, 253, 245, 0.86);
  box-shadow:
    0 24px 70px rgba(34, 60, 29, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.small-panel {
  width: min(480px, 96%);
}

.badge {
  display: inline-flex;
  margin-bottom: 12px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(111, 166, 92, 0.12);
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge.danger {
  background: rgba(180, 90, 80, 0.12);
  color: var(--danger);
}

.panel h2 {
  margin: 0;
  color: var(--green-dark);
  font-size: clamp(34px, 5vw, 58px);
  letter-spacing: -2.4px;
  line-height: 0.95;
}

.panel-text {
  max-width: 500px;
  margin: 14px auto 20px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 18px 0;
}

.mode-grid button,
.primary-btn,
.ghost-btn {
  min-height: 46px;
  border: 0;
  border-radius: 16px;
  cursor: pointer;
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease;
}

.mode-grid button {
  color: var(--green-dark);
  background: rgba(233, 245, 223, 0.86);
  box-shadow: inset 0 0 0 1px rgba(83, 130, 66, 0.14);
  font-weight: 800;
}

.mode-grid button.is-active {
  color: white;
  background:
    linear-gradient(135deg, #80bd65, #5b984e);
  box-shadow: 0 12px 28px rgba(83, 130, 66, 0.26);
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0 8px;
}

.info-card {
  padding: 14px;
  text-align: left;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.52);
  box-shadow:
    inset 0 0 0 1px rgba(83, 130, 66, 0.12),
    0 12px 24px rgba(54, 86, 47, 0.05);
}

.info-card h3 {
  margin: 0 0 9px;
  color: var(--green-dark);
  font-size: 14px;
}

.info-card ul,
.info-card ol {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.info-card ul {
  padding-left: 0;
  list-style: none;
}

.info-card li {
  margin: 4px 0;
}

.info-card li.done {
  color: var(--green-dark);
  font-weight: 900;
}

.panel-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
}

.primary-btn {
  padding: 0 30px;
  color: white;
  background:
    linear-gradient(135deg, #82c968, #5e9f50);
  box-shadow: 0 14px 30px rgba(83, 130, 66, 0.28);
  font-weight: 900;
}

.ghost-btn {
  padding: 0 22px;
  color: var(--green-dark);
  background: rgba(255, 255, 255, 0.68);
  box-shadow: inset 0 0 0 1px rgba(83, 130, 66, 0.16);
  font-weight: 800;
}

.primary-btn:hover,
.ghost-btn:hover,
.mode-grid button:hover,
.pause-btn:hover {
  transform: translateY(-1px);
}

.help-text {
  margin: 15px 0 0;
  color: #7b8975;
  font-size: 13px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 11px;
  margin: 18px 0;
}

.result-grid p {
  margin: 0;
  padding: 13px;
  border-radius: 18px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.56);
  box-shadow: inset 0 0 0 1px rgba(83, 130, 66, 0.12);
  font-weight: 800;
}

.result-grid strong {
  display: block;
  margin-top: 4px;
  color: var(--green-dark);
  font-size: 24px;
}

.new-record {
  margin: 10px 0;
  color: var(--danger);
  font-size: 18px;
  font-weight: 900;
}

.new-record.hidden {
  display: none;
}

.final-board {
  margin-top: 10px;
}

.tap-hint {
  position: absolute;
  left: 50%;
  bottom: 20px;
  z-index: 11;
  transform: translateX(-50%);
  padding: 8px 13px;
  border-radius: 999px;
  color: rgba(65, 107, 57, 0.72);
  background: rgba(255, 255, 255, 0.58);
  box-shadow: inset 0 0 0 1px rgba(83, 130, 66, 0.1);
  font-size: 12px;
  font-weight: 800;
  pointer-events: none;
  backdrop-filter: blur(8px);
}

@media (max-width: 780px) {
  .page {
    padding: 18px 10px;
  }

  .game-shell {
    min-height: 390px;
    border-radius: 24px;
  }

  .topbar {
    flex-direction: column;
    gap: 12px;
  }

  .hud {
    justify-content: flex-start;
  }

  .hide-mobile {
    display: none;
  }

  .pause-btn {
    right: 18px;
    bottom: 16px;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 540px) {
  .brand h1 {
    font-size: 30px;
  }

  .brand p {
    font-size: 11px;
  }

  .brand-frog {
    width: 52px;
    height: 52px;
    border-radius: 18px;
  }

  .hud {
    font-size: 12px;
  }

  .mode-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .panel-actions {
    flex-direction: column;
  }

  .result-grid {
    grid-template-columns: 1fr;
  }
}