/* ── Reset ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: #05102e;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100vh;
  overflow: hidden;
  font-family: Arial, sans-serif;
  color: #fff;
}

/* ── Top UI bar ── */
#ui {
  width: 100%;
  max-width: 600px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(0, 0, 0, 0.75);
  border-bottom: 1px solid rgba(255, 215, 0, 0.25);
  z-index: 10;
  flex-shrink: 0;
}

#lives {
  color: #ff6b6b;
  font-size: clamp(12px, 3.5vw, 18px);
  letter-spacing: 1px;
  min-width: 70px;
}

#mathDisplay {
  flex: 1;
  text-align: center;
  color: #ffd700;
  font-size: clamp(16px, 4.8vw, 26px);
  font-weight: bold;
  text-shadow: 0 0 12px rgba(255, 215, 0, 0.55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#score {
  color: #90ee90;
  font-size: clamp(12px, 3.5vw, 18px);
  min-width: 55px;
  text-align: right;
}

/* ── Answer bar ── */
#answerBar {
  width: 100%;
  max-width: 600px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 5px 14px;
  background: rgba(0, 0, 0, 0.6);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 10;
  flex-shrink: 0;
}

#answerLabel {
  color: #aaa;
  font-size: clamp(12px, 3.2vw, 16px);
}

#answerValue {
  color: #fff;
  font-size: clamp(18px, 5.5vw, 30px);
  font-weight: bold;
  min-width: 44px;
  text-align: center;
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  letter-spacing: 2px;
}

#deleteBtn {
  background: rgba(255, 80, 80, 0.22);
  border: 1px solid rgba(255, 80, 80, 0.5);
  color: #ff7070;
  font-size: clamp(14px, 3.8vw, 20px);
  padding: 3px 11px 3px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
}
#deleteBtn:hover, #deleteBtn:active {
  background: rgba(255, 80, 80, 0.42);
}

/* ── Canvas ── */
canvas {
  display: block;
  max-width: 600px;
  width: 100%;
  flex: 1;
}

/* ── Start / game-over overlay ── */
#overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.82);
  z-index: 100;
  color: #fff;
  text-align: center;
  padding: 24px 20px;
}

#overlay h1 {
  font-size: clamp(30px, 9vw, 56px);
  color: #ffd700;
  margin-bottom: 18px;
  text-shadow: 2px 2px 12px rgba(0, 0, 0, 0.8);
}

#overlay p {
  font-size: clamp(15px, 4vw, 20px);
  margin-bottom: 8px;
  color: #eee;
}

#overlay p.small {
  font-size: clamp(12px, 3.2vw, 15px);
  color: #bbb;
  margin-bottom: 5px;
}

#overlay p.touch-hint {
  display: none;
}

@media (pointer: coarse) {
  #overlay p.touch-hint { display: block; }
}

.btn {
  margin-top: 24px;
  padding: clamp(10px, 2.8vw, 15px) clamp(30px, 9vw, 50px);
  font-size: clamp(17px, 4.5vw, 24px);
  background: #ffd700;
  color: #05102e;
  border: none;
  border-radius: 40px;
  cursor: pointer;
  font-weight: bold;
  transition: background 0.18s, transform 0.12s;
  box-shadow: 0 4px 18px rgba(255, 215, 0, 0.4);
}

.btn:hover  { background: #ffe566; transform: scale(1.04); }
.btn:active { transform: scale(0.97); }
