:root {
  --primary: #f59e0b;
  --primary-hover: #d97706;
  --bg: #fffbeb;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --success: #22c55e;
  --error: #ef4444;
  --blue: #2563eb;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

header {
  max-width: 600px;
  width: 100%;
  text-align: center;
  margin-bottom: 40px;
}

.title-container {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: white;
  padding: 12px 24px;
  border-radius: 50px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  border: 1px solid #fef3c7;
}

.title-container h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: #0f172a;
}

main {
  max-width: 800px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.card {
  background: white;
  padding: 32px;
  border-radius: 24px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 500px;
  border: 1px solid var(--border);
}

.hidden {
  display: none !important;
}

/* Config View */
.config-section h2 {
  font-size: 1.25rem;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #475569;
}

.option-group {
  margin-bottom: 24px;
}

.option-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
  display: block;
}

.btn-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn-row {
  display: flex;
  gap: 12px;
}

.btn-option {
  padding: 16px;
  border-radius: 16px;
  border: 2px solid var(--border);
  background: white;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  flex: 1;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn-option.active {
  border-color: var(--primary);
  background: #fffbeb;
  color: #b45309;
}

.btn-primary {
  width: 100%;
  background: #0f172a;
  color: white;
  padding: 20px;
  border-radius: 16px;
  font-size: 1.25rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  margin-top: 24px;
  box-shadow: 0 10px 15px -3px rgba(15, 23, 42, 0.2);
  transition: transform 0.1s;
}

.btn-primary:active {
  transform: scale(0.98);
}

/* Game View */
.game-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.game-card {
  background: white;
  padding: 40px;
  border-radius: 48px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 700px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.btn-back {
  position: absolute;
  left: 24px;
  top: 24px;
  background: none;
  border: none;
  color: #94a3b8;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.score-badge {
  position: absolute;
  right: 32px;
  top: 32px;
  background: #fef9c3;
  color: #a16207;
  padding: 8px 16px;
  border-radius: 50px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Calculation Table */
.calc-container {
  margin-top: 40px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
}

.calc-grid {
  display: grid;
  gap: 12px;
  justify-content: end;
}

.calc-row {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  align-items: center;
  position: relative;
}

.cell {
  width: 48px;
  height: 64px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 3rem;
  position: relative;
}

@media (min-width: 768px) {
  .cell {
    width: 80px;
    height: 96px;
    font-size: 4.5rem;
  }
}

.cell input {
  width: 100%;
  height: 100%;
  text-align: center;
  border-radius: 12px;
  border: 4px solid var(--border);
  font-size: inherit;
  font-family: inherit;
  font-weight: inherit;
  background: #f8fafc;
  outline: none;
  transition: all 0.2s;
}

.cell input:focus {
  border-color: var(--blue);
}

.cell input.correct {
  border-color: var(--success);
  background: #f0fdf4;
}

.cell input.error {
  border-color: var(--error);
  background: #fef2f2;
}

.operator-symbol {
  position: absolute;
  left: -60px;
  font-size: 2.5rem;
  color: #cbd5e1;
}

@media (min-width: 768px) {
  .operator-symbol {
    left: -100px;
    font-size: 4rem;
  }
}

.calc-line {
  height: 8px;
  background: #1e293b;
  border-radius: 4px;
  width: 100%;
  margin: 16px 0;
}

.result-text {
  color: var(--blue);
}

/* Carries & Borrows */
.carries-row {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-bottom: 8px;
  height: 48px;
}

.carry-cell {
  width: 48px;
  display: flex;
  justify-content: center;
  align-items: center;
}

@media (min-width: 768px) {
  .carry-cell {
    width: 80px;
  }
}

.carry-input {
  width: 32px;
  height: 32px;
  text-align: center;
  border-radius: 8px;
  border: 2px solid #fde68a;
  background: #fffbeb;
  font-size: 1rem;
  outline: none;
}

@media (min-width: 768px) {
  .carry-input {
    width: 48px;
    height: 48px;
    font-size: 1.5rem;
  }
}

.borrow-top {
  position: absolute;
  left: -8px;
  top: -8px;
  width: 24px;
  height: 24px;
  font-size: 0.75rem;
  border-radius: 50%;
  border: 2px solid #fde68a;
  background: #fffbeb;
  text-align: center;
  z-index: 10;
}

.borrow-bottom {
  position: absolute;
  left: -8px;
  bottom: -8px;
  width: 24px;
  height: 24px;
  font-size: 0.75rem;
  border-radius: 50%;
  border: 2px solid #fde68a;
  background: #fffbeb;
  text-align: center;
  z-index: 10;
}

/* Actions */
.game-actions {
  display: flex;
  gap: 16px;
  width: 100%;
  justify-content: center;
  margin-top: 40px;
}

.btn-action {
  flex: 1;
  padding: 20px;
  border-radius: 16px;
  font-size: 1.25rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.1s;
}

.btn-verify {
  background: var(--blue);
  color: white;
  box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.3);
}

.btn-new {
  background: #0f172a;
  color: white;
  box-shadow: 0 10px 15px -3px rgba(15, 23, 42, 0.2);
}

.btn-action:active {
  transform: scale(0.95);
}

/* Feedback */
.feedback-card {
  width: 100%;
  max-width: 700px;
  padding: 32px;
  border-radius: 32px;
  display: flex;
  align-items: center;
  gap: 24px;
  border: 2px solid transparent;
  margin-top: 24px;
}

.feedback-success {
  background: #f0fdf4;
  border-color: #dcfce7;
  color: #166534;
}

.feedback-error {
  background: #fef2f2;
  border-color: #fee2e2;
  color: #991b1b;
}

.feedback-icon {
  width: 40px;
  height: 40px;
}

.feedback-content h3 {
  font-size: 1.25rem;
  font-weight: 700;
}

.feedback-content button {
  background: none;
  border: none;
  color: inherit;
  text-decoration: underline;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  font-size: 1.1rem;
}

footer {
  margin-top: 64px;
  color: #94a3b8;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 16px;
}

.dot {
  width: 4px;
  height: 4px;
  background: #cbd5e1;
  border-radius: 50%;
}
