* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: #f0f4ff;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

#app {
  background: white;
  border-radius: 16px;
  padding: 32px 40px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.12);
  max-width: 480px;
  width: 95vw;
  text-align: center;
}

h1 {
  font-size: 1.6rem;
  color: #3a3a8c;
  margin-bottom: 8px;
}

#progress-bar {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
}

.dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #dde0ff;
  transition: background 0.3s;
}

.dot.filled {
  background: #3a3a8c;
}

.finish-screen {
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.finish-emoji {
  font-size: 3rem;
}

.finish-text {
  font-size: 1.2rem;
  color: #3a3a8c;
  font-weight: bold;
}

.finish-screen button {
  background: #3a3a8c;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 28px;
  font-size: 1.1rem;
  cursor: pointer;
}

.finish-screen button:hover {
  background: #5050c0;
}

#step-info {
  font-size: 0.9rem;
  color: #888;
  min-height: 1.4rem;
  margin-bottom: 16px;
}

/* The long-multiplication layout */
#problem-area {
  display: inline-block;
  text-align: right;
  margin: 0 auto 24px;
  min-width: 220px;
}

.problem-numbers {
  font-size: 2.2rem;
  font-family: 'Courier New', monospace;
  font-weight: bold;
  color: #222;
}

.problem-numbers .top-number,
.problem-numbers .bottom-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
}

.problem-numbers .bottom-row {
  margin-top: 4px;
  border-bottom: 3px solid #333;
  padding-bottom: 4px;
}

.multiply-sign {
  font-size: 2.2rem;
  color: #555;
  margin-right: 6px;
}

.digit-cell {
  width: 2.2rem;
  text-align: center;
}

.digit-cell.highlighted {
  background: #fff0a0;
  border-radius: 4px;
  color: #b86000;
}

/* Partial products rows */
.partial-rows {
  margin-top: 8px;
}

.partial-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-height: 3rem;
  gap: 4px;
  font-family: 'Courier New', monospace;
  font-size: 2.2rem;
}

.partial-row.has-border {
  border-top: 3px solid #333;
}

.carry-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  font-family: 'Courier New', monospace;
  font-size: 1.1rem;
  color: #3a3a8c;
  min-height: 1.4rem;
}

.carry-cell {
  width: 2.2rem;
  text-align: center;
}

.carry-wrapper {
  display: inline-flex;
  align-items: center;
  width: 2.2rem;
  justify-content: center;
  gap: 1px;
}

.carry-plus {
  font-size: 1rem;
  font-family: 'Courier New', monospace;
  font-weight: bold;
  color: #3a3a8c;
  line-height: 1;
}

/* Input cells */
input.answer-input {
  width: 2.2rem;
  height: 2.6rem;
  font-size: 2rem;
  font-family: 'Courier New', monospace;
  font-weight: bold;
  text-align: center;
  border: 2px solid #aaa;
  border-radius: 6px;
  background: #fffde7;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
  padding: 0;
}

input.answer-input:focus {
  border-color: #3a3a8c;
  background: #e8eaff;
}

input.answer-input.correct {
  border-color: #2e7d32;
  background: #e8f5e9;
  color: #2e7d32;
}

input.answer-input.wrong {
  border-color: #c62828;
  background: #ffebee;
  color: #c62828;
  animation: shake 0.3s;
}

input.answer-input[readonly] {
  background: #f5f5f5;
  border-color: #ccc;
  color: #444;
}

/* Carry input (interactive) */
input.carry-input {
  width: 2.2rem;
  height: 1.4rem;
  font-size: 1.1rem;
  font-family: 'Courier New', monospace;
  font-weight: bold;
  text-align: center;
  border: 2px solid #3a3a8c;
  border-radius: 4px;
  background: #eef0ff;
  outline: none;
  color: #3a3a8c;
  padding: 0;
  transition: border-color 0.15s, background 0.15s;
}

input.carry-input:focus {
  border-color: #1a1a6c;
  background: #d8dbff;
}

input.carry-input.correct {
  border-color: #3a3a8c;
  background: #eef0ff;
  color: #3a3a8c;
}

input.carry-input.wrong {
  border-color: #c62828;
  background: #ffebee;
  color: #c62828;
  animation: shake 0.3s;
}

/* Zero placeholder */
.zero-placeholder {
  width: 2.2rem;
  height: 2.6rem;
  font-size: 2rem;
  font-family: 'Courier New', monospace;
  font-weight: bold;
  text-align: center;
  color: #aaa;
  line-height: 2.6rem;
  display: inline-block;
}

/* Final answer section */
.final-border {
  border-top: 3px solid #333;
  margin-top: 4px;
}

#feedback {
  font-size: 1.3rem;
  min-height: 2rem;
  margin-bottom: 16px;
  font-weight: bold;
}

#feedback.success { color: #2e7d32; }
#feedback.error { color: #c62828; }

#new-problem {
  background: #3a3a8c;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 28px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: background 0.15s;
}

#new-problem:hover { background: #5050c0; }

@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.step-label {
  font-size: 0.9rem;
  color: #888;
  text-align: left;
  margin-bottom: 2px;
}

.row-group {
  margin-bottom: 4px;
}

.completed-final {
  font-size: 2.2rem;
  font-family: 'Courier New', monospace;
  font-weight: bold;
  color: #2e7d32;
  min-height: 2.6rem;
  display: flex;
  justify-content: flex-end;
  gap: 4px;
}

.digit-display {
  width: 2.2rem;
  text-align: center;
}
