:root {
  color-scheme: light;
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background: #f6efe4;
  color: #24302c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100svh;
  background:
    linear-gradient(180deg, rgba(255, 252, 246, 0.94), rgba(243, 232, 215, 0.96)),
    #f6efe4;
}

button {
  min-height: 2.75rem;
  border: 0;
  border-radius: 8px;
  background: #b84036;
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

button:hover {
  background: #9f332b;
}

button:disabled {
  background: #b8aaa0;
  cursor: not-allowed;
}

button:focus-visible {
  outline: 3px solid #f7c548;
  outline-offset: 2px;
}

.game-app {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(18rem, 21rem);
  gap: 0.9rem;
  width: min(100%, 70rem);
  min-height: 100svh;
  margin: 0 auto;
  padding: 0.75rem;
}

.play-area {
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
}

.board-shell {
  width: min(100%, calc((100svh - 1.5rem) * 0.75));
  max-width: 34rem;
  min-width: 17rem;
}

#game-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  border: 1px solid rgba(75, 48, 35, 0.28);
  border-radius: 8px;
  background: #6bc7ad;
  box-shadow: 0 1.1rem 2.4rem rgba(71, 43, 30, 0.18);
  touch-action: none;
}

.hud {
  align-self: center;
  display: grid;
  gap: 0.8rem;
  border: 1px solid rgba(126, 80, 54, 0.16);
  border-radius: 8px;
  background: rgba(255, 252, 246, 0.92);
  padding: 0.95rem;
  box-shadow: 0 0.9rem 2rem rgba(71, 43, 30, 0.1);
}

.title-block {
  display: grid;
  gap: 0.35rem;
}

.eyebrow {
  margin: 0;
  color: #1f7668;
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p,
dl {
  margin: 0;
}

h1 {
  color: #2d241e;
  font-size: 1.42rem;
  line-height: 1.22;
}

.title-block p,
.help-text {
  color: #665a50;
  font-size: 0.88rem;
  line-height: 1.65;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.45rem;
}

.score-grid div {
  min-width: 0;
  border: 1px solid rgba(31, 118, 104, 0.14);
  border-radius: 8px;
  background: #edf8f2;
  padding: 0.65rem 0.55rem;
}

.score-grid dt {
  color: #65736d;
  font-size: 0.7rem;
  font-weight: 800;
}

.score-grid dd {
  margin: 0.12rem 0 0;
  color: #24302c;
  font-size: 1.22rem;
  font-weight: 950;
  line-height: 1;
  overflow-wrap: anywhere;
}

.status-text {
  border: 1px solid rgba(184, 64, 54, 0.15);
  border-radius: 8px;
  background: #fff7ec;
  padding: 0.62rem 0.7rem;
  color: #6c3b30;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.55;
}

.button-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
}

.button-row button {
  padding-inline: 0.35rem;
  font-size: 0.86rem;
}

.pull-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.pull-button {
  display: grid;
  min-height: 4.8rem;
  place-items: center;
  gap: 0.16rem;
  border: 1px solid rgba(127, 38, 34, 0.22);
  background: linear-gradient(180deg, #d9574b, #b83b33);
  box-shadow: inset 0 -0.16rem 0 rgba(86, 30, 26, 0.28);
  touch-action: none;
}

.pull-button.is-active {
  transform: translateY(1px);
  background: linear-gradient(180deg, #f06d5f, #c64037);
  box-shadow: inset 0 0.16rem 0 rgba(86, 30, 26, 0.24);
}

.pull-button small {
  color: rgba(255, 255, 255, 0.86);
  font-size: 0.72rem;
  font-weight: 700;
}

.game-modal {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(38, 27, 21, 0.38);
  backdrop-filter: blur(3px);
}

.game-modal[hidden] {
  display: none;
}

.modal-panel {
  display: grid;
  width: min(100%, 28rem);
  gap: 0.75rem;
  border: 1px solid rgba(255, 247, 236, 0.78);
  border-radius: 8px;
  background: rgba(255, 252, 246, 0.96);
  padding: 1rem;
  color: #2d241e;
  box-shadow: 0 1.4rem 3.2rem rgba(38, 27, 21, 0.25);
}

.modal-kicker {
  width: fit-content;
  border-radius: 999px;
  background: #e6f5ee;
  padding: 0.28rem 0.55rem;
  color: #1f7668;
  font-size: 0.74rem;
  font-weight: 900;
}

.modal-panel h2 {
  font-size: 1.55rem;
  line-height: 1.25;
}

#modal-message {
  color: #5b5148;
  font-size: 0.94rem;
  line-height: 1.65;
}

.modal-score {
  border-radius: 8px;
  background: #fff2dc;
  padding: 0.68rem 0.75rem;
  color: #6c3b30;
  font-size: 1.05rem;
  font-weight: 900;
}

.modal-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.55rem;
}

#modal-title-button {
  background: #2f7569;
}

#modal-title-button:hover {
  background: #25645a;
}

@media (max-width: 820px) {
  .game-app {
    grid-template-columns: 1fr;
    gap: 0.6rem;
    padding: 0.55rem;
  }

  .play-area {
    order: 1;
  }

  .hud {
    order: 2;
    align-self: stretch;
    gap: 0.65rem;
    padding: 0.72rem;
  }

  .board-shell {
    width: min(100%, calc((100svh - 15.5rem) * 0.75));
    min-width: 15rem;
  }

  .title-block p,
  .help-text {
    font-size: 0.82rem;
    line-height: 1.5;
  }

  .score-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .pull-button {
    min-height: 4.1rem;
  }
}

@media (max-width: 560px) {
  .game-app {
    padding: 0.45rem;
  }

  h1 {
    font-size: 1.16rem;
  }

  .title-block p {
    display: none;
  }

  .board-shell {
    width: min(100%, calc((100svh - 13.8rem) * 0.75));
    max-width: 18rem;
  }

  .score-grid dd {
    font-size: 1rem;
  }

  .status-text {
    padding: 0.5rem 0.58rem;
    font-size: 0.8rem;
  }

  .button-row button {
    min-height: 2.45rem;
    font-size: 0.78rem;
  }

  .help-text {
    display: none;
  }

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