* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background: #f4f7f5;
  color: #24332b;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
}

.page {
  min-height: 100vh;
  padding: 22px 20px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.header {
  width: min(100%, 620px);
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.title-area { display: flex; align-items: center; }
h1 { margin: 0; font-size: clamp(19px, 4vw, 26px); }

.level-badge {
  margin-left: 10px;
  padding: 5px 10px;
  border-radius: 14px;
  color: white;
  background: #22a866;
  font-size: 13px;
  font-weight: 700;
}

.countdown {
  min-width: 82px;
  height: 46px;
  padding: 0 13px;
  border-radius: 25px;
  background: white;
  box-shadow: 0 5px 16px rgba(38, 75, 55, .1);
  display: flex;
  align-items: baseline;
  justify-content: center;
}

.countdown strong { color: #ef8e22; font-size: 27px; line-height: 46px; }
.countdown span { margin-left: 4px; color: #78847e; font-size: 13px; }

.canvas-wrapper {
  padding: 8px;
  border-radius: 20px;
  background: white;
  box-shadow: 0 10px 30px rgba(38, 75, 55, .12);
}

canvas { display: block; border-radius: 14px; touch-action: none; }

.action-button, .restart-button {
  border: 0;
  color: white;
  background: #22a866;
  font-weight: 700;
  cursor: pointer;
}

.action-button {
  width: min(280px, 76vw);
  height: 52px;
  margin-top: 24px;
  border-radius: 28px;
  font-size: 19px;
  box-shadow: 0 7px 18px rgba(34, 168, 102, .25);
}

.action-button.submit-button { background: #3478f6; box-shadow: 0 7px 18px rgba(52, 120, 246, .25); }
.action-button:disabled { background: #a6b7ae; box-shadow: none; cursor: default; }
.tip { margin: 15px 0 0; color: #87928c; font-size: 14px; text-align: center; }

.level-up-tip {
  position: fixed;
  z-index: 20;
  top: 15%;
  left: 50%;
  padding: 12px 24px;
  border-radius: 26px;
  color: white;
  background: linear-gradient(135deg, #ffac33, #f07c24);
  font-size: 22px;
  font-weight: 700;
  transform: translateX(-50%);
  animation: levelUp 1.2s ease both;
}

@keyframes levelUp {
  0% { opacity: 0; transform: translateX(-50%) scale(.75); }
  20% { opacity: 1; transform: translateX(-50%) scale(1.08); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-16px); }
}

.result-overlay {
  position: fixed;
  z-index: 10;
  inset: 0;
  padding: 20px;
  background: rgba(20, 31, 25, .42);
  display: flex;
  align-items: center;
  justify-content: center;
}

[hidden] { display: none !important; }

.result-dialog {
  width: min(100%, 400px);
  padding: 26px 24px 22px;
  border-radius: 22px;
  background: white;
  box-shadow: 0 16px 50px rgba(0, 0, 0, .22);
  text-align: center;
}

.result-icon {
  width: 66px;
  height: 66px;
  margin: auto;
  border-radius: 50%;
  color: white;
  background: #25ad68;
  font-size: 41px;
  font-weight: 700;
  line-height: 66px;
}

.result-icon.wrong { background: #ef5350; }
.result-dialog h2 { margin: 14px 0 0; font-size: 25px; }
.result-summary { margin-top: 18px; border-top: 1px solid #edf1ef; }
.result-row { padding: 11px 2px; border-bottom: 1px solid #edf1ef; display: flex; justify-content: space-between; }
.result-row span { color: #7b8881; }
.wrong-message { margin: 12px 0 0; color: #d8534f; font-size: 14px; }

.statistics { margin-top: 16px; padding: 15px; border-radius: 15px; background: #f4f8f6; }
.statistics h3 { margin: 0 0 12px; text-align: left; font-size: 16px; }
.statistics-grid { display: grid; grid-template-columns: repeat(4, 1fr); }
.statistics-grid div { display: flex; flex-direction: column; align-items: center; }
.statistics-grid strong { color: #1d8d57; font-size: 18px; }
.statistics-grid span { margin-top: 4px; color: #87928c; font-size: 11px; }

.restart-button { width: 100%; height: 48px; margin-top: 18px; border-radius: 25px; font-size: 17px; }

@media (max-height: 700px) {
  .page { padding-top: 12px; }
  .header { margin-bottom: 12px; }
  .action-button { margin-top: 14px; }
  .tip { margin-top: 8px; }
}
