:root {
  --bg1: #fff7ed;
  --bg2: #ffedd5;
  --card: #ffffff;
  --text: #7c2d12;
  --muted: #9a3412;
  --accent: #f97316;
  --accent2: #fb923c;
  --line: #fed7aa;
  --shadow: 0 16px 34px rgba(194, 65, 12, 0.15);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  background: linear-gradient(180deg, var(--bg1), var(--bg2));
  color: var(--text);
}

body {
  padding: max(18px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
}

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

.panel {
  background: rgba(255,255,255,0.88);
  border: 1px solid rgba(249,115,22,0.12);
  border-radius: 28px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.hero h1 {
  margin: 8px 0;
  font-size: 34px;
  line-height: 1.15;
}

.subtitle {
  margin: 0;
  font-size: 18px;
  line-height: 1.6;
  color: var(--muted);
}

.badge {
  display: inline-block;
  margin: 0;
  padding: 8px 12px;
  border-radius: 999px;
  background: #ffedd5;
  color: #c2410c;
  font-size: 14px;
  font-weight: 700;
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 18px 0 16px;
}

.stat {
  background: #fff7ed;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 14px;
}

.label {
  display: block;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 6px;
}

.stat strong {
  font-size: 28px;
}

.tips {
  background: #fffaf5;
  border: 1px dashed #fdba74;
  border-radius: 20px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.tips p,
.tips li,
.result-text {
  font-size: 18px;
  line-height: 1.7;
}

.tips ol {
  margin: 8px 0 0 20px;
  padding: 0;
}

.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.card {
  position: relative;
  min-height: 110px;
  border: 0;
  border-radius: 22px;
  padding: 0;
  background: transparent;
  perspective: 900px;
  cursor: pointer;
}

.card-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 22px;
  backface-visibility: hidden;
  transition: transform 0.45s ease;
  font-weight: 800;
  box-shadow: 0 10px 18px rgba(194, 65, 12, 0.12);
}

.card-front {
  background: linear-gradient(180deg, #fb923c, #f97316);
  color: #fff;
  font-size: 34px;
}

.card-back {
  background: #ffffff;
  border: 2px solid #fdba74;
  color: #7c2d12;
  font-size: 28px;
  transform: rotateY(180deg);
}

.card.flipped .card-front,
.card.matched .card-front {
  transform: rotateY(180deg);
}

.card.flipped .card-back,
.card.matched .card-back {
  transform: rotateY(0);
}

.card.matched .card-back {
  background: #dcfce7;
  border-color: #86efac;
}

.actions {
  margin-top: 18px;
}

.primary-btn {
  width: 100%;
  border: 0;
  border-radius: 20px;
  background: linear-gradient(180deg, var(--accent2), var(--accent));
  color: #fff;
  font-size: 22px;
  font-weight: 800;
  padding: 16px;
  cursor: pointer;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(124, 45, 18, 0.32);
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(100%, 460px);
  background: white;
  border-radius: 28px;
  padding: 24px 20px;
  box-shadow: 0 20px 48px rgba(124, 45, 18, 0.2);
  text-align: center;
}

.modal-card h2 {
  font-size: 32px;
  margin: 12px 0 8px;
}

@media (max-width: 460px) {
  .hero h1 { font-size: 30px; }
  .subtitle, .tips p, .tips li, .result-text { font-size: 17px; }
  .board { gap: 10px; }
  .card { min-height: 96px; }
}
