* {
  box-sizing: border-box;
}

:root {
  --bg: #f3efe7;
  --paper: #fffdf8;
  --ink: #2b2722;
  --muted: #81786c;
  --line: #e7ded0;
  --soft: #faf5ec;
  --ok: #2f7d57;
  --no: #8d4a43;
  --shadow: 0 18px 45px rgba(70, 50, 30, 0.12);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.9), transparent 38rem),
    var(--bg);
  color: var(--ink);
}

.app {
  width: min(576px, 100%);
  margin: 0 auto;
  padding: 24px 14px 36px;
}

.app-header {
  text-align: center;
  margin-bottom: 18px;
}

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

.app-header h1,
.panel h2 {
  margin: 0;
  font-size: clamp(22px, 4vw, 30px);
  line-height: 1.2;
  letter-spacing: 0.02em;
}

.subtitle {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.hidden {
  display: none !important;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 21px;
  padding: 24px 18px;
  box-shadow: var(--shadow);
  text-align: center;
}

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 11px;
  padding: 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.card {
  width: 100%;
  min-height: 416px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  perspective: 1200px;
  outline: none;
}

.card:focus-visible .card-face {
  outline: 3px solid rgba(43, 39, 34, 0.75);
  outline-offset: 5px;
}

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

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

.card-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 27px 32px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(180deg, #fffdf9 0%, #fff9ef 100%);
  box-shadow: var(--shadow);
  backface-visibility: hidden;
}

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

.label,
.meaning-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.label {
  margin-bottom: 11px;
}

.main-text {
  font-size: clamp(34px, 7vw, 58px);
  font-weight: 850;
  line-height: 1.18;
  word-break: break-word;
}

.hint {
  margin-top: 22px;
  color: var(--muted);
  font-size: 12px;
}

.answer-layout {
  width: 100%;
  max-width: 448px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.answer-pinyin {
  color: var(--muted);
  font-size: clamp(15px, 2.4vw, 21px);
  font-weight: 750;
  line-height: 1.25;
  word-break: break-word;
}

.hanzi-block {
  width: 100%;
  padding: 2px 0 0;
}

.simplified {
  font-size: clamp(37px, 6.4vw, 59px);
  font-weight: 850;
  line-height: 1.1;
  letter-spacing: 0.04em;
  word-break: break-word;
}

.traditional {
  margin-top: 5px;
  color: #5f574e;
  font-size: clamp(22px, 4vw, 35px);
  font-weight: 750;
  line-height: 1.15;
  letter-spacing: 0.04em;
  word-break: break-word;
}

.meaning-block {
  width: 100%;
  margin-top: 6px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.58);
}

.meaning-label {
  margin-bottom: 8px;
}


.meaning {
  margin: 0;
  font-size: clamp(16px, 3.2vw, 22px);
  font-weight: 750;
  line-height: 1.45;
  word-break: break-word;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
  margin-top: 14px;
}

button {
  font: inherit;
}

.actions button,
#restartBtn {
  min-height: 45px;
  border: 0;
  border-radius: 999px;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 850;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(70, 50, 30, 0.12);
}

.actions button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  box-shadow: none;
}

.no {
  background: #fff8f1;
  color: var(--no);
  border: 1px solid #e5cfc4 !important;
}

.ok {
  background: var(--ok);
  color: #fff;
}

#restartBtn {
  background: var(--ink);
  color: #fff;
  margin-top: 13px;
}

.result-text {
  margin: 20px 0 8px;
  font-size: clamp(27px, 6.4vw, 46px);
  font-weight: 900;
}

.error {
  color: #8d2b24;
  text-align: left;
}

@media (max-width: 520px) {
  .app {
    padding-top: 18px;
  }

  .card,
  .card-inner {
    min-height: 400px;
  }

  .card-face {
    padding: 22px 14px;
    border-radius: 21px;
  }

  .actions {
    gap: 8px;
  }

  .actions button {
    font-size: 13px;
    padding-inline: 10px;
  }
}


@media (max-width: 420px) {
  .card,
  .card-inner {
    min-height: 416px;
  }

  .simplified {
    font-size: clamp(34px, 12vw, 50px);
  }

  .traditional {
    font-size: clamp(21px, 8vw, 30px);
  }

  .meaning-block {
    padding: 13px 11px;
  }
}
