:root {
  --bg: #f5f6fa;
  --card: #ffffff;
  --text: #222222;
  --muted: #666a73;
  --accent: #ff4757;
  --accent-2: #3742fa;
  --border: #e6e9ef;
  --shadow: 0 8px 24px rgba(0,0,0,0.08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0f;
    --card: #12151c;
    --text: #eaeaea;
    --muted: #a0a6b6;
    --accent: #ff6b81;
    --accent-2: #7aa2ff;
    --border: #1e2330;
    --shadow: 0 12px 28px rgba(0,0,0,0.35);
  }
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Meiryo", sans-serif;
}
* { box-sizing: border-box; }

.page {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: calc(env(safe-area-inset-top, 0px)) 12px calc(env(safe-area-inset-bottom, 12px));
}

.card {
  width: 100%;
  max-width: 640px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: fadeInUp 600ms ease both;
}

.header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.subtitle {
  font-size: 0.9rem;
  color: var(--muted);
}

.body {
  padding: 22px;
  display: grid;
  gap: 20px;
}

/* レバーエリア */
.lever-area {
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  gap: 16px;
  padding: 10px;
  position: relative;
}

.lever-btn {
  appearance: none;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 6px;
  border-radius: 14px;
  transition: transform 120ms ease, box-shadow 200ms ease, background 200ms ease;
  position: relative;
  outline: none;
}
.lever-btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 71, 87, 0.06);
  box-shadow: 0 8px 18px rgba(0,0,0,0.08);
}
.lever-btn:active {
  transform: translateY(1px) scale(0.99);
}
.lever-img {
  display: block;
  width: min(220px, 60vw);
  max-width: 320px;
  height: auto;
  filter: drop-shadow(0 6px 12px rgba(0,0,0,0.15));
  transition: transform 300ms ease;
  transform-origin: top right;
}
.lever-btn.hit .lever-img {
  transform: rotate(-28deg) translateY(4px);
}
.lever-fallback {
  display: none;
  font-size: 48px;
}
.lever-caption {
  font-size: 0.95rem;
  color: var(--muted);
  text-align: center;
}

/* 結果エリア（画像は自然サイズ） */
.result-area {
  display: none;
  grid-template-columns: 1fr;
  place-items: center;
  gap: 12px;
  padding: 10px;
  text-align: center;
  animation: fadeIn 380ms ease both;
}
.result-area.show {
  display: grid;
}
.result-img-wrap {
  display: inline-block;
  max-width: 100%;
  border-radius: 16px;
  background: rgba(128,128,128,0.08);
  border: 1px solid var(--border);
  padding: 8px;
  box-sizing: border-box;
}
.result-img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 65vh;
  animation: popIn 400ms ease both;
}
.status {
  font-size: 0.95rem;
  color: var(--muted);
}
.result-rec {
  font-size: 0.95rem;
  color: var(--text);
}

/* ボタン群 */
.actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  padding-top: 4px;
}
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(55, 66, 250, 0.12);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms ease, background 180ms ease, border-color 180ms ease;
}
.btn:hover {
  transform: translateY(-1px);
  background: rgba(55, 66, 250, 0.18);
}
.btn:active {
  transform: translateY(1px);
}
.btn.secondary {
  background: transparent;
}

/* ローディング */
.loading {
  display: none;
  place-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.92rem;
  animation: fadeIn 200ms ease both;
}
.loading.show {
  display: grid;
}
.spinner {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 3px solid rgba(128,128,128,0.18);
  border-top-color: var(--accent);
  animation: spin 860ms linear infinite;
}

/* アクセシビリティ */
.sr-live {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  border: 0;
}

/* アニメーション */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; } to { opacity: 1; }
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 開始時演出（軽くグロー） */
.glow {
  position: absolute;
  inset: -20% -10%;
  pointer-events: none;
  filter: blur(22px);
  opacity: 0.25;
  background:
    radial-gradient(120px 80px at 20% 20%, rgba(255, 71, 87, 0.35), transparent 70%),
    radial-gradient(120px 80px at 80% 30%, rgba(55, 66, 250, 0.35), transparent 70%);
}

/* 視覚過敏対応 */
@media (prefers-reduced-motion: reduce) {
  .card, .result-img { animation: none; }
  .lever-img { transition: none; }
  .spinner { animation-duration: 1.6s; }
}

/* 小さい画面向け調整 */
@media (max-width: 420px) {
  .title { font-size: 1rem; }
  .subtitle { font-size: 0.85rem; }
  .lever-caption { font-size: 0.9rem; }
}