:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #35271f;
  background: #263238;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: #263238;
}

button {
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  border: 2px solid #62402e;
  border-radius: 8px;
  color: #35271f;
  background: #fff8de;
  box-shadow: 0 2px 0 #62402e;
  font: inherit;
  font-size: 25px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
  cursor: pointer;
  touch-action: manipulation;
}

button:hover:not(:disabled) {
  background: #ffe27a;
}

button:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: none;
}

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

button:disabled {
  color: #94877d;
  border-color: #a89c93;
  background: #e5ded6;
  box-shadow: none;
  cursor: default;
}

.game-shell {
  position: relative;
  display: grid;
  grid-template-rows: 68px minmax(0, 1fr) 58px 32px;
  width: min(100%, 480px);
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  border-inline: 1px solid #62402e;
  background: #bfe9d5;
}

.game-header {
  display: grid;
  grid-template-columns: minmax(128px, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: max(7px, env(safe-area-inset-top)) 14px 7px;
  border-bottom: 2px solid #62402e;
  background: #fff8de;
}

.title-block {
  min-width: 0;
}

.title-block h1 {
  margin: 0;
  color: #d95247;
  font-size: 20px;
  line-height: 23px;
  letter-spacing: 0;
  white-space: nowrap;
}

#level-label {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: #5d6c65;
  font-size: 12px;
  line-height: 16px;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.run-stats {
  display: flex;
  gap: 8px;
  margin: 0;
}

.run-stats div {
  display: grid;
  min-width: 48px;
  text-align: center;
}

.run-stats dt,
.run-stats dd {
  margin: 0;
  letter-spacing: 0;
}

.run-stats dt {
  color: #6d665f;
  font-size: 11px;
  line-height: 15px;
}

.run-stats dd {
  color: #35271f;
  font-size: 16px;
  font-weight: 800;
  line-height: 20px;
}

.game-stage {
  display: grid;
  min-height: 0;
  place-items: center;
  overflow: hidden;
  background: #7dcfb6;
}

#game-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 390 / 650;
  background: #bfe9d5;
  touch-action: none;
}

.action-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  height: 58px;
  padding: 5px 12px;
  border-top: 2px solid #62402e;
  background: #ff7b65;
}

#feedback {
  height: 32px;
  padding: 5px 12px;
  overflow: hidden;
  color: #4b4038;
  background: #fff8de;
  font-size: 13px;
  line-height: 22px;
  letter-spacing: 0;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(38, 50, 56, 0.72);
}

.modal[hidden] {
  display: none;
}

.modal-card {
  width: min(100%, 340px);
  padding: 20px;
  border: 2px solid #62402e;
  border-radius: 8px;
  background: #fff8de;
  box-shadow: 0 8px 0 rgba(53, 39, 31, 0.28);
  text-align: center;
}

.modal-card h2 {
  margin: 0 0 16px;
  color: #d95247;
  font-size: 22px;
  line-height: 28px;
  letter-spacing: 0;
}

.summary-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin: 0 0 18px;
  overflow: hidden;
  border: 1px solid #62402e;
  border-radius: 6px;
  background: #62402e;
}

.summary-stats div {
  padding: 10px;
  background: #e0f5e9;
}

.summary-stats dt,
.summary-stats dd {
  margin: 0;
  letter-spacing: 0;
}

.summary-stats dt {
  color: #65736c;
  font-size: 12px;
  line-height: 16px;
}

.summary-stats dd {
  margin-top: 3px;
  font-size: 22px;
  font-weight: 800;
  line-height: 26px;
}

.primary-command {
  width: 100%;
  height: 48px;
  color: #fff;
  border-color: #62402e;
  background: #d95247;
  font-size: 15px;
}

.primary-command:hover:not(:disabled) {
  background: #c9443b;
}

@media (max-width: 360px) {
  .game-header {
    gap: 6px;
    padding-inline: 9px;
  }

  .run-stats {
    gap: 3px;
  }

  .action-bar {
    gap: 16px;
  }
}
