* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #1a1a2e;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #ffffff;
  user-select: none;
  touch-action: manipulation;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#game {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

#hud {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  gap: 8px;
}

#hud > div {
  flex: 1;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(6px);
  padding: 8px 10px;
  border-radius: 14px;
  font-size: clamp(13px, 3.2vw, 17px);
  font-weight: 700;
  text-align: center;
  border: 2px solid rgba(255, 204, 0, 0.35);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#problemDisplay {
  position: absolute;
  top: 22%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  text-align: center;
  width: 92%;
  max-width: 520px;
  pointer-events: none;
}

#problemText {
  display: inline-block;
  background: linear-gradient(135deg, #ffcc00, #ff9900);
  color: #1a1a2e;
  padding: 14px 28px;
  border-radius: 24px;
  font-size: clamp(26px, 6.5vw, 44px);
  font-weight: 800;
  box-shadow: 0 6px 16px rgba(255, 204, 0, 0.45);
  border: 3px solid #ffffff;
  letter-spacing: 1px;
}

#answerArea {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 14px;
  z-index: 10;
  width: 96%;
  max-width: 640px;
  justify-content: center;
}

.answer-btn {
  flex: 1;
  min-height: 68px;
  background: #ffffff;
  color: #1a1a2e;
  border: 3px solid #ffcc00;
  border-radius: 18px;
  font-size: clamp(22px, 5.5vw, 34px);
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.1s ease, box-shadow 0.08s ease;
  box-shadow: 0 5px 0 #d4a000, 0 6px 12px rgba(0, 0, 0, 0.25);
}

.answer-btn:active {
  transform: translateY(5px);
  box-shadow: 0 0 0 #d4a000, 0 2px 6px rgba(0, 0, 0, 0.2);
  background: #f5f5f5;
}

.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(26, 26, 46, 0.94);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 24px;
  text-align: center;
  animation: fadeIn 0.3s ease;
}

.overlay.hidden {
  display: none !important;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.overlay h1 {
  font-size: clamp(30px, 7.5vw, 52px);
  color: #ffcc00;
  margin-bottom: 18px;
  text-shadow: 0 3px 10px rgba(0, 0, 0, 0.6);
  line-height: 1.2;
}

.overlay p {
  font-size: clamp(16px, 4vw, 22px);
  margin-bottom: 28px;
  line-height: 1.6;
  color: #e6e6e6;
  max-width: 480px;
}

#btnStart, #btnRestart {
  background: linear-gradient(to bottom, #ffcc00, #e6b800);
  color: #1a1a2e;
  border: none;
  padding: 18px 48px;
  font-size: clamp(22px, 5.5vw, 30px);
  font-weight: 800;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 7px 0 #b38f00, 0 10px 20px rgba(0, 0, 0, 0.35);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  margin-top: 8px;
}

#btnStart:active, #btnRestart:active {
  transform: translateY(7px);
  box-shadow: 0 0 0 #b38f00, 0 3px 10px rgba(0, 0, 0, 0.3);
}

#summaryStats {
  background: rgba(255, 255, 255, 0.08);
  padding: 22px 20px;
  border-radius: 20px;
  margin-bottom: 28px;
  width: 100%;
  max-width: 340px;
  border: 2px solid rgba(255, 204, 0, 0.2);
}

#summaryStats p {
  margin: 12px 0;
  font-size: clamp(18px, 4.5vw, 24px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.25);
  padding-bottom: 10px;
  color: #ffffff;
}

#summaryStats p:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

#summaryStats span {
  color: #ffcc00;
  font-weight: 800;
  font-size: clamp(20px, 5vw, 26px);
}