* {
  box-sizing: border-box;
}

:root {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #16302a;
  background: #f4fbf7;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, #ffffff 0, #f4fbf7 45%, #e8f6ee 100%);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior: none;
}

button {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 900px;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
}

.screen {
  display: none;
  min-height: calc(100vh - 48px);
  min-height: calc(100dvh - 48px);
}

.screen.active {
  display: flex;
}

#home-screen {
  position: relative;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.school-link {
  position: absolute;
  top: 0;
  left: 0;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, .88);
  color: #2f6f53;
  box-shadow: 0 6px 18px rgba(25, 80, 60, .08);
  text-decoration: none;
  font-weight: 800;
}

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

.app-icon {
  font-size: clamp(68px, 10vw, 110px);
  line-height: 1;
  margin-bottom: 10px;
}

h1 {
  font-size: clamp(40px, 6vw, 64px);
  margin: 0;
  letter-spacing: -0.04em;
}

.subtitle {
  font-size: clamp(20px, 3vw, 28px);
  margin: 12px 0 0;
  color: #526e65;
}

.home-actions {
  width: min(100%, 720px);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.mode-card {
  border: 0;
  border-radius: 28px;
  background: white;
  padding: 34px 24px;
  box-shadow: 0 14px 36px rgba(25, 80, 60, 0.12);
  cursor: pointer;
  min-height: 230px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.mode-card:active {
  transform: scale(0.98);
  box-shadow: 0 8px 22px rgba(25, 80, 60, 0.12);
}

.mode-emoji {
  font-size: 58px;
  margin-bottom: 12px;
}

.mode-title {
  font-size: 34px;
  font-weight: 800;
}

.mode-description {
  font-size: 19px;
  margin-top: 8px;
  color: #607a72;
  text-align: center;
}

.small-note {
  color: #6f877f;
  margin-top: 26px;
  font-size: 16px;
}

#game-screen {
  flex-direction: column;
}

.game-header {
  display: grid;
  grid-template-columns: 72px 1fr 92px;
  align-items: center;
  min-height: 76px;
  margin-bottom: 14px;
}

.icon-button {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 0;
  background: white;
  box-shadow: 0 8px 20px rgba(25, 80, 60, 0.1);
  font-size: 32px;
  cursor: pointer;
}

.status {
  text-align: center;
}

.status-title {
  font-size: 24px;
  font-weight: 800;
}

.status-subtitle {
  font-size: 17px;
  color: #657e75;
  margin-top: 3px;
}

.timer {
  justify-self: end;
  min-width: 82px;
  padding: 12px 14px;
  border-radius: 18px;
  background: #16302a;
  color: white;
  text-align: center;
  font-size: 25px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.hidden {
  visibility: hidden;
}

.question-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.split-tree {
  width: min(92vw, 520px);
  height: 330px;
  position: relative;
  margin-top: -10px;
}

.number {
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border: 5px solid #2f855a;
  border-radius: 50%;
  font-weight: 900;
  color: #16302a;
  box-shadow: 0 10px 24px rgba(25, 80, 60, 0.11);
  z-index: 2;
}

.top-number {
  position: absolute;
  left: 50%;
  top: 10px;
  transform: translateX(-50%);
  width: 118px;
  height: 118px;
  font-size: 58px;
}

.bottom-row {
  position: absolute;
  left: 9%;
  right: 9%;
  bottom: 12px;
  display: flex;
  justify-content: space-between;
}

.child-number {
  width: 108px;
  height: 108px;
  font-size: 50px;
}

.child-number.missing {
  border-style: dashed;
  color: #2f855a;
}

.branches {
  position: absolute;
  left: 50%;
  top: 122px;
  width: 78%;
  height: 120px;
  transform: translateX(-50%);
}

.branch {
  position: absolute;
  top: 0;
  width: 8px;
  height: 150px;
  border-radius: 999px;
  background: #6f9d82;
  transform-origin: top center;
  z-index: 1;
}

.branch-left {
  left: calc(50% - 4px);
  transform: rotate(48deg);
}

.branch-right {
  left: calc(50% - 4px);
  transform: rotate(-48deg);
}

.feedback {
  min-height: 44px;
  margin: 4px 0 18px;
  font-size: 28px;
  font-weight: 800;
  text-align: center;
}

.feedback.correct {
  color: #23754f;
}

.feedback.wrong {
  color: #ba3c3c;
}

/*
  Altijd exact dezelfde nummerlayout:
          0
    1 2 3 4 5
    6 7 8 9 10
*/
.answer-grid {
  width: min(100%, 700px);
  display: grid;
  grid-template-columns: repeat(5, minmax(66px, 1fr));
  grid-template-rows: repeat(3, auto);
  gap: 12px;
}

.answer-button:first-child {
  grid-column: 3;
  grid-row: 1;
}

.answer-button:nth-child(2) {
  grid-column: 1;
  grid-row: 2;
}

.answer-button:nth-child(3) {
  grid-column: 2;
  grid-row: 2;
}

.answer-button:nth-child(4) {
  grid-column: 3;
  grid-row: 2;
}

.answer-button:nth-child(5) {
  grid-column: 4;
  grid-row: 2;
}

.answer-button:nth-child(6) {
  grid-column: 5;
  grid-row: 2;
}

/* 6 - 10 */
.answer-button:nth-child(7) {
  grid-column: 1;
  grid-row: 3;
}

.answer-button:nth-child(8) {
  grid-column: 2;
  grid-row: 3;
}

.answer-button:nth-child(9) {
  grid-column: 3;
  grid-row: 3;
}

.answer-button:nth-child(10) {
  grid-column: 4;
  grid-row: 3;
}

.answer-button:nth-child(11) {
  grid-column: 5;
  grid-row: 3;
}

.answer-button {
  border: 0;
  border-radius: 20px;
  min-height: 74px;
  background: white;
  color: #16302a;
  font-size: 32px;
  font-weight: 900;
  box-shadow: 0 8px 20px rgba(25, 80, 60, 0.1);
  cursor: pointer;
}

.answer-button:active {
  transform: scale(0.96);
  background: #eaf7ef;
}

.answer-button:disabled {
  opacity: 0.55;
}

.tree-shake {
  animation: shake 230ms ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

#result-screen {
  align-items: center;
  justify-content: center;
}

.result-card {
  width: min(100%, 620px);
  background: white;
  border-radius: 32px;
  padding: 46px 36px;
  text-align: center;
  box-shadow: 0 16px 40px rgba(25, 80, 60, 0.13);
}

.result-emoji {
  font-size: 76px;
}

.result-card h2 {
  font-size: 42px;
  margin: 10px 0 18px;
}

.result-score {
  font-size: clamp(48px, 8vw, 78px);
  font-weight: 900;
  color: #2f855a;
}

.result-detail {
  min-height: 52px;
  font-size: 21px;
  line-height: 1.45;
  color: #5a736b;
}

.result-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 28px;
}

.primary-button,
.secondary-button {
  min-height: 70px;
  border-radius: 22px;
  font-size: 24px;
  font-weight: 800;
  cursor: pointer;
}

.primary-button {
  border: 0;
  background: #2f855a;
  color: white;
}

.secondary-button {
  border: 2px solid #b8d8c5;
  background: white;
  color: #244d3f;
}

@media (max-width: 650px) {
  .app-shell {
    padding-left: 16px;
    padding-right: 16px;
  }

  .home-actions {
    grid-template-columns: 1fr;
  }

  .mode-card {
    min-height: 175px;
    padding: 24px;
  }

  .game-header {
    grid-template-columns: 60px 1fr 82px;
  }

  .icon-button {
    width: 52px;
    height: 52px;
  }

  .answer-grid {
    grid-template-columns: repeat(5, minmax(52px, 1fr));
    gap: 10px;
  }

  .answer-button {
    min-height: 68px;
  }

  .split-tree {
    height: 300px;
  }
}

@media (orientation: landscape) and (max-height: 700px) {
  .app-shell {
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .game-header {
    min-height: 62px;
    margin-bottom: 0;
  }

  .split-tree {
    height: 245px;
    width: min(65vw, 480px);
  }

  .top-number {
    width: 94px;
    height: 94px;
    font-size: 48px;
  }

  .bottom-row {
    bottom: 0;
  }

  .child-number {
    width: 88px;
    height: 88px;
    font-size: 42px;
  }

  .branches {
    top: 100px;
  }

  .branch {
    height: 115px;
  }

  .feedback {
    margin: 0 0 8px;
    min-height: 34px;
    font-size: 24px;
  }

  .answer-button {
    min-height: 58px;
  }
}
