* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 32px 16px;
  background: #fdf6ec;
  font-family: system-ui, -apple-system, sans-serif;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
}

#deck-view,
#summary-view,
#error-view {
  max-width: clamp(380px, 320px + 10vw, 460px);
  margin: 0 auto;
}

.deck-counter {
  text-align: center;
  color: #a37b4f;
  font-size: 12px;
  margin-bottom: 10px;
}

.progress-track {
  width: 100%;
  height: 5px;
  background: #f3e3cf;
  border-radius: 3px;
  margin-bottom: 16px;
}

.progress-fill {
  height: 100%;
  background: #e8823a;
  border-radius: 3px;
  transition: width 0.2s ease;
}

.card-tag {
  display: inline-block;
  background: #fff2df;
  color: #c2660a;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 16px;
  margin-bottom: 14px;
}

.card {
  background: #fffaf3;
  border: 2px solid #fbe3c4;
  border-radius: 16px;
  box-shadow: 0 3px 10px rgba(232, 130, 58, 0.15);
  padding: clamp(20px, 2px + 3vw, 44px) clamp(18px, 6px + 2vw, 34px);
  min-height: clamp(70px, 2.5px + 1.125vw, 160px);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #4a3a2a;
  font-size: clamp(14px, 8.75px + 0.875vw, 21px);
  line-height: 1.4;
  cursor: pointer;
  margin-bottom: 14px;
}

.card-frame {
  height: clamp(200px, 95px + 17.5vw, 340px);
  padding: 0;
  display: block;
  perspective: 1000px;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.5s ease;
  transform-style: preserve-3d;
}

.card-inner.flipped {
  transform: rotateY(180deg);
}

.card-inner.no-transition {
  transition: none;
}

.card-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: clamp(20px, 2px + 3vw, 44px) clamp(18px, 6px + 2vw, 34px);
  overflow-y: auto;
  text-align: center;
  color: #4a3a2a;
  font-size: clamp(14px, 8.75px + 0.875vw, 21px);
  line-height: 1.4;
  backface-visibility: hidden;
}

.card-face--back {
  transform: rotateY(180deg);
}

.card-face-content {
  width: 100%;
}

.card-face-label {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #a37b4f;
}

.card-face-label--answer {
  color: #c2660a;
}

@media (prefers-reduced-motion: reduce) {
  .card-inner {
    transition: none;
  }
}

.actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 12px;
}

.btn-unknown,
.btn-known {
  font-size: 16px;
  padding: 12px 32px;
  min-height: 48px;
  border-radius: 24px;
  cursor: pointer;
  border: 2px solid;
}

.btn-unknown {
  background: transparent;
  border-color: #f0d4b0;
  color: #a37b4f;
}

.btn-known {
  background: #e8823a;
  border-color: #e8823a;
  color: #fff;
}

.nav-arrow {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.app-title {
  text-align: center;
  color: #4a3a2a;
  font-size: 20px;
  margin: 0 0 20px;
}

#course-list,
#deck-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 640px) {
  #course-list,
  #deck-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 960px) {
  #course-list,
  #deck-list {
    grid-template-columns: repeat(3, 1fr);
  }
}

.deck-tile {
  background: #fffaf3;
  border: 2px solid #fbe3c4;
  border-radius: 16px;
  box-shadow: 0 3px 10px rgba(232, 130, 58, 0.15);
  padding: 16px 18px;
  cursor: pointer;
}

.deck-tile-name {
  margin: 0 0 6px;
  color: #4a3a2a;
  font-size: 16px;
}

.deck-tile-meta {
  margin: 0 0 6px;
  color: #a37b4f;
  font-size: 12px;
}

.deck-tile-desc {
  margin: 0;
  color: #7a6650;
  font-size: 13px;
  line-height: 1.4;
}

.btn-review {
  margin-top: 12px;
  font-size: 11px;
  padding: 5px 14px;
  border-radius: 14px;
  cursor: pointer;
  border: 2px solid #f0d4b0;
  background: #fff2df;
  color: #c2660a;
}

.deck-topbar {
  margin-bottom: 12px;
}

.katex-error {
  color: inherit;
}
