:root {
  --bg: #f6f1ea;
  --bg-accent: #e9dfd2;
  --ink: #1d1b16;
  --muted: #6f6557;
  --primary: #c04a2f;
  --primary-dark: #8f3320;
  --ok: #1f7a54;
  --err: #a61b26;
  --card: #ffffff;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Noto Serif SC", "Songti SC", "STSong", serif;
  color: var(--ink);
  background: radial-gradient(circle at top, #fff8ef 0%, var(--bg) 60%, var(--bg-accent) 100%);
  min-height: 100vh;
}

.page {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 20px 48px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.hero {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.8rem, 2.6vw, 2.6rem);
}

.hero p {
  margin: 0;
  color: var(--muted);
}

.hero__status {
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow);
  font-weight: 600;
}

.hero__status.ok {
  background: #e7f6ee;
  color: var(--ok);
  border: 1px solid rgba(31, 122, 84, 0.35);
}

.hero__status.err {
  background: #fdeaea;
  color: var(--err);
  border: 1px solid rgba(166, 27, 38, 0.35);
}

.scanner {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
}

.scanner__extras {
  display: grid;
  gap: 10px;
}

.scanner__view {
  width: 100%;
  min-height: 360px;
  border-radius: 14px;
  overflow: hidden;
  background: #111;
  position: relative;
}

.scanner__reader {
  width: 100%;
  height: 100%;
  min-height: inherit;
  object-fit: cover;
  background: #000;
  display: block;
}

.is-android .scanner__reader {
  object-fit: contain;
}

.scan-guide {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: grid;
  place-items: center;
  color: #f6f0e7;
}

.scan-guide__frame {
  width: min(88%, 720px);
  height: min(55%, 360px);
  border: 2px solid rgba(255, 255, 255, 0.65);
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.18);
}

.scan-guide__text {
  position: absolute;
  bottom: 12px;
  left: 12px;
  right: 12px;
  font-size: 0.9rem;
  text-align: center;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.55);
}

.scanner__controls {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.btn {
  padding: 12px 16px;
  border-radius: 12px;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  background: #efe7dd;
  color: var(--ink);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
}

.btn--primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
}

.btn--ghost {
  background: transparent;
  border: 1px solid #d6c7b5;
}

.result {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.result__card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}

.result__label {
  color: var(--muted);
  font-weight: 600;
}

.result__code {
  font-size: 1.4rem;
  word-break: break-all;
}

.result__hint {
  color: var(--muted);
}

.result__card.ok {
  border: 2px solid rgba(31, 122, 84, 0.4);
  background: #f0faf4;
}

.result__card.err {
  border: 2px solid rgba(166, 27, 38, 0.4);
  background: #fff0f1;
}

.pulse {
  animation: pulse 0.35s ease;
}

.shake {
  animation: shake 0.4s ease;
}

.feedback-flash {
  position: fixed;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  display: grid;
  place-items: center;
  transition: opacity 0.18s ease;
  z-index: 10;
}

.feedback-flash.ok {
  background: rgba(31, 122, 84, 0.35);
}

.feedback-flash.err {
  background: rgba(166, 27, 38, 0.38);
}

.feedback-flash.show {
  opacity: 1;
}

.feedback-flash__text {
  font-size: clamp(2.2rem, 6vw, 3.5rem);
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #fff;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
  padding: 12px 22px;
  border-radius: 16px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  background: rgba(0, 0, 0, 0.25);
}

.result__list {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.result__list-title {
  font-weight: 700;
  margin-bottom: 10px;
}

#scanList {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

#scanList li {
  padding: 8px 10px;
  border-radius: 10px;
  background: #f4eee7;
  font-size: 0.95rem;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

#scanList li span {
  color: var(--muted);
  font-size: 0.85rem;
}

.tips {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.tips h2 {
  margin-top: 0;
}

.tips__note {
  color: var(--muted);
  margin-bottom: 0;
}

@media (max-width: 600px) {
  .scanner__view {
    min-height: 300px;
  }

  .scan-guide__frame {
    width: min(92%, 520px);
    height: min(60%, 320px);
  }
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}
