:root {
  --bg: #f6efe4;
  --bg-accent: #efe1ca;
  --card: rgba(255, 250, 242, 0.86);
  --line: rgba(87, 56, 24, 0.14);
  --text: #2f2418;
  --muted: #725b44;
  --primary: #b6542d;
  --primary-dark: #8f3f1e;
  --success: #1f7a54;
  --danger: #9c2f2f;
  --shadow: 0 24px 60px rgba(84, 46, 12, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "PingFang SC", "Noto Sans SC", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.65), transparent 30%),
    linear-gradient(160deg, var(--bg) 0%, var(--bg-accent) 100%);
}

body.settings-open {
  overflow: hidden;
}

.page {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.panel + .panel {
  margin-top: 20px;
}

.hero {
  padding: 28px 24px;
}

.eyebrow {
  margin: 0 0 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(32px, 5vw, 52px);
  line-height: 1.02;
  max-width: 12ch;
}

.intro {
  margin-top: 16px;
  max-width: 60ch;
  line-height: 1.65;
  color: var(--muted);
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.section-title span {
  color: var(--muted);
  font-size: 14px;
}

.field {
  display: block;
}

.field + .field {
  margin-top: 18px;
}

.field span {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--muted);
}

.field-spacer {
  user-select: none;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  border-radius: 16px;
  padding: 14px 16px;
  color: var(--text);
}

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 44px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 24px) calc(50% - 2px),
    calc(100% - 18px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(182, 84, 45, 0.24);
  border-color: rgba(182, 84, 45, 0.45);
}

textarea {
  resize: vertical;
  min-height: 120px;
}

.primary-button,
.secondary-button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 140ms ease, opacity 140ms ease, background 140ms ease;
  position: relative;
}

.primary-button {
  background: var(--primary);
  color: #fff9f5;
}

#start-button {
  margin-top: 18px;
}

.primary-button:hover,
.secondary-button:hover {
  transform: translateY(-1px);
}

.primary-button:disabled,
.secondary-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.secondary-button {
  background: rgba(87, 56, 24, 0.08);
  color: var(--text);
}

.button-loading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.button-loading::before {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: button-spin 0.75s linear infinite;
}

@keyframes button-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.prompt-card {
  padding: 20px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(182, 84, 45, 0.1), rgba(255, 255, 255, 0.7));
  border: 1px solid rgba(182, 84, 45, 0.12);
}

.prompt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.prompt-label {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.translation-text {
  font-size: clamp(24px, 4vw, 36px);
  line-height: 1.2;
}

.source-text {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(87, 56, 24, 0.1);
  color: var(--muted);
  font-size: 18px;
  line-height: 1.5;
}

.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(87, 56, 24, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.icon-button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(182, 84, 45, 0.28);
}

.eye-icon {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.actions {
  display: flex;
  align-items: stretch;
  gap: 12px;
  margin-top: 18px;
}

.actions .primary-button,
.actions .secondary-button {
  flex: 1;
  margin-top: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
}

.result-card {
  margin-top: 18px;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.76);
}

.result-card.correct {
  border-color: rgba(31, 122, 84, 0.24);
}

.result-card.incorrect {
  border-color: rgba(156, 47, 47, 0.24);
}

.result-card h3 {
  margin: 0 0 8px;
}

.result-card p + p,
.result-card ul {
  margin-top: 10px;
}

.result-card ul {
  padding-left: 20px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.summary-item {
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.summary-label {
  color: var(--muted);
  font-size: 14px;
}

.summary-value {
  margin-top: 10px;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1;
}

.summary-message {
  margin-top: 18px;
  color: var(--muted);
  line-height: 1.6;
}

.summary-actions {
  display: flex;
  gap: 12px;
  margin-top: 18px;
}

.summary-actions .primary-button {
  flex: 1;
  margin-top: 0;
}

.hidden {
  display: none;
}

.settings-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  color: #fff9f5;
  box-shadow: 0 20px 40px rgba(143, 63, 30, 0.24);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 20;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.settings-fab svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  stroke-width: 1.7;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.settings-fab:hover {
  transform: scale(1.04);
  box-shadow: 0 24px 48px rgba(143, 63, 30, 0.28);
}

.settings-panel {
  position: fixed;
  right: 20px;
  bottom: 90px;
  width: min(320px, calc(100% - 32px));
  padding: 18px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255, 250, 242, 0.95);
  box-shadow: 0 24px 60px rgba(84, 46, 12, 0.18);
  backdrop-filter: blur(12px);
  z-index: 21;
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity 180ms ease, transform 180ms ease;
}

.settings-panel.settings-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.settings-header h3 {
  margin: 0;
  font-size: 20px;
}

.settings-close-button {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  background: rgba(87, 56, 24, 0.08);
  color: var(--text);
  cursor: pointer;
}

@media (max-width: 640px) {
  .page {
    width: min(100% - 20px, 920px);
    padding-top: 20px;
  }

  .panel {
    padding: 18px;
    border-radius: 20px;
  }

  .actions {
    flex-direction: column;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .summary-actions {
    flex-direction: column;
  }

  .settings-panel {
    right: 10px;
    bottom: 78px;
    width: calc(100% - 20px);
  }

  .settings-fab {
    right: 10px;
    bottom: 10px;
  }
}
