: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: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

@media (min-width: 640px) {
  body {
    padding: 24px;
  }
}

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: 16px;
}

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

@media (min-width: 768px) {
  .game-card {
    padding: 32px;
  }
}

.game-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: 20px;
  border-bottom: 1.5px solid #f1f5f9;
  padding-bottom: 12px;
}

.btn-back {
  background: none;
  border: none;
  color: #94a3b8;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.95rem;
}

.btn-back:hover {
  color: var(--text);
}

.score-badge {
  background: #fef9c3;
  color: #a16207;
  padding: 6px 14px;
  border-radius: 50px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
}

.game-mini-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: #0f172a;
  display: none;
}

@media (min-width: 520px) {
  .game-mini-title {
    display: block;
  }
}

.game-split {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 24px;
  align-items: center;
}

@media (min-width: 680px) {
  .game-split {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-around;
    gap: 32px;
  }
}

.game-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  flex: 1.3;
}

.game-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 280px;
  flex: 1;
}

/* Calculation Table */
.calc-container {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  width: 100%;
  display: flex;
  justify-content: center;
}

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

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

.cell {
  width: 42px;
  height: 56px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 2.25rem;
  position: relative;
}

@media (min-width: 680px) {
  .cell {
    width: 64px;
    height: 80px;
    font-size: 3.5rem;
  }
}

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

@media (min-width: 680px) {
  .cell input {
    border-radius: 14px;
    border: 4px solid var(--border);
  }
}

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

.cell input.focused {
  border-color: var(--blue);
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

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

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

/* Numpad */
.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 250px;
  margin-top: 12px;
}

@media (min-width: 680px) {
  .numpad {
    gap: 10px;
    max-width: 280px;
    margin-top: 0;
  }
}

.num-btn {
  background: white;
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  transition: all 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  touch-action: manipulation;
  height: 44px;
}

@media (min-width: 680px) {
  .num-btn {
    border-radius: 14px;
    padding: 12px;
    font-size: 1.35rem;
    height: 52px;
  }
}

.num-btn:hover {
  border-color: var(--blue);
  background: #f8fafc;
}

.num-btn:active {
  background: #eff6ff;
  transform: scale(0.95);
  border-color: var(--blue);
}

.delete-btn {
  color: var(--error);
}

.delete-btn:hover {
  background: #fef2f2;
  border-color: var(--error);
}

.enter-btn {
  background: var(--success);
  color: white;
  border-color: var(--success);
}

.enter-btn:hover {
  background: #16a34a;
  border-color: #16a34a;
}

.enter-btn:active {
  background: #15803d;
}

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

@media (min-width: 680px) {
  .operator-symbol {
    left: -80px;
    font-size: 3rem;
  }
}

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

@media (min-width: 680px) {
  .calc-line {
    height: 8px;
    margin: 14px 0;
  }
}

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

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

@media (min-width: 680px) {
  .carries-row {
    gap: 12px;
    margin-bottom: 8px;
    height: 48px;
  }
}

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

@media (min-width: 680px) {
  .carry-cell {
    width: 64px;
  }
}

.carry-input {
  width: 24px;
  height: 24px;
  text-align: center;
  border-radius: 6px;
  border: 1.5px solid #fde68a;
  background: #fffbeb;
  font-size: 0.85rem;
  outline: none;
}

@media (min-width: 680px) {
  .carry-input {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 2px solid #fde68a;
    font-size: 1.1rem;
  }
}

.borrow-top {
  position: absolute;
  left: -6px;
  top: -6px;
  width: 18px;
  height: 18px;
  font-size: 0.65rem;
  border-radius: 50%;
  border: 1.5px solid #fde68a;
  background: #fffbeb;
  text-align: center;
  z-index: 10;
  line-height: 15px;
}

@media (min-width: 680px) {
  .borrow-top {
    left: -8px;
    top: -8px;
    width: 24px;
    height: 24px;
    font-size: 0.75rem;
    border: 2px solid #fde68a;
    line-height: 20px;
  }
}

.borrow-bottom {
  position: absolute;
  left: -6px;
  bottom: -6px;
  width: 18px;
  height: 18px;
  font-size: 0.65rem;
  border-radius: 50%;
  border: 1.5px solid #fde68a;
  background: #fffbeb;
  text-align: center;
  z-index: 10;
  line-height: 15px;
}

@media (min-width: 680px) {
  .borrow-bottom {
    left: -8px;
    bottom: -8px;
    width: 24px;
    height: 24px;
    font-size: 0.75rem;
    border: 2px solid #fde68a;
    line-height: 20px;
  }
}

/* Actions */
.game-actions {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 250px;
  justify-content: center;
  margin-top: 12px;
}

@media (min-width: 680px) {
  .game-actions {
    gap: 12px;
    max-width: 280px;
    margin-top: 16px;
  }
}

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

@media (min-width: 680px) {
  .btn-action {
    padding: 12px;
    border-radius: 14px;
    font-size: 1.05rem;
    height: 48px;
  }
}

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

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

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

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

@media (min-width: 680px) {
  .feedback-card {
    padding: 16px 24px;
    border-radius: 20px;
    gap: 16px;
    margin-top: 24px;
  }
}

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

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

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

@media (min-width: 680px) {
  .feedback-icon {
    width: 40px;
    height: 40px;
  }
}

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

@media (min-width: 680px) {
  .feedback-content h3 {
    font-size: 1.15rem;
  }
}

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

@media (min-width: 680px) {
  .feedback-content button {
    margin-top: 8px;
    font-size: 1.05rem;
  }
}

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

@media (min-width: 680px) {
  footer {
    margin-top: 64px;
  }
}

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