:root {
  --ratio: 0.7072; /* 幅/高さ (413.5 / 584.7) */
  --accent: #e8913a;
  --bg: #2b2a33;
  --panel: #3a3944;
  --text: #f2f0ea;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: system-ui, "Hiragino Sans", "Yu Gothic", sans-serif; }
header { display: flex; align-items: center; gap: 16px; padding: 8px 16px; background: var(--panel); flex-wrap: wrap; }
h1 { font-size: 20px; margin: 0; }
button { font: inherit; padding: 6px 14px; border-radius: 6px; border: 1px solid #666; background: #4a4955; color: var(--text); cursor: pointer; }
button:hover { background: #5a5966; }
button.primary { background: var(--accent); color: #222; border-color: var(--accent); font-weight: bold; }
button.active { background: var(--accent); color: #222; border-color: var(--accent); }
#modeTabs { display: flex; gap: 8px; }

#setup { padding: 12px 16px; }
.setup-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
#picker { display: grid; grid-template-columns: repeat(6, minmax(0, 90px)); gap: 6px; margin-bottom: 14px; }
.pick { position: relative; aspect-ratio: var(--ratio); border-radius: 4px; cursor: pointer; opacity: .35; outline: 2px solid transparent; }
.pick.on { opacity: 1; outline-color: var(--accent); }
.pick::after { content: attr(data-n); position: absolute; left: 3px; top: 2px; font-size: 11px; background: #000a; padding: 0 4px; border-radius: 3px; }

#game { padding: 8px 12px; }
.game-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
#status { margin-left: auto; font-variant-numeric: tabular-nums; }
#reader { display: flex; align-items: center; justify-content: center; gap: 24px; margin-bottom: 8px; }
#reader .slot { width: var(--rw); aspect-ratio: var(--ratio); }
#reader .hint { font-size: 14px; opacity: .8; }
#board { display: grid; justify-content: center; gap: 6px; }

/* カード */
.card { position: relative; width: 100%; aspect-ratio: var(--ratio); perspective: 600px; cursor: pointer; }
.card .inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .35s; }
.card.flipped .inner { transform: rotateY(180deg); }
.card .face, .card .back { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 5px; background-color: #fff; }
.card .back { background-image: url(back.jpg); background-size: 100% 100%; }
.card .face { transform: rotateY(180deg); }
.face-img { background-image: url(cat36.jpg); background-size: 600% 600%; background-repeat: no-repeat; border-radius: 5px; }
.pick, .face-img { background-color: #fff; }
.card.matched { cursor: default; }
.card.matched .face { outline: 4px solid #4cd964; outline-offset: -4px; box-shadow: 0 0 10px #4cd964; }
.card.matched .face::after { content: "✓"; position: absolute; right: 4px; top: 2px; color: #fff; background: #4cd964; border-radius: 50%; width: 22px; height: 22px; text-align: center; line-height: 22px; font-size: 14px; }
.card.wrong .face { outline: 4px solid #ff4d4d; outline-offset: -4px; }
.card.shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.card.locked { pointer-events: none; }

#clear { position: fixed; inset: 0; background: #000a; display: flex; align-items: center; justify-content: center; }
#clear[hidden], [hidden] { display: none !important; }
.clear-box { background: var(--panel); padding: 28px 40px; border-radius: 12px; text-align: center; }
.clear-box h2 { margin-top: 0; }
