:root {
  --bg-primary: #000000; /* 純黒 = 加算式ディスプレイで透明 */
  --bg-secondary: #0a0a0f;
  --bg-tertiary: #14141f;
  --bg-card: #1a1a2e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --accent-primary: #4dd0ff;
  --accent-warm: #ffd23f;
  --focus-ring: #4dd0ff;
  --focus-glow: rgba(77, 208, 255, 0.4);
  --match-glow: rgba(255, 210, 63, 0.35);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  width: 600px;
  height: 600px;
  overflow: hidden;
}

#app { width: 100%; height: 100%; position: relative; }

/* --- Screens --- */
.screen {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: absolute;
  top: 0;
  left: 0;
}
.screen.hidden { display: none; }

/* --- Header --- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-secondary);
  gap: 12px;
  flex-shrink: 0;
}
.header h1 { font-size: 22px; font-weight: 600; }
.header-meta { font-size: 14px; color: var(--text-secondary); }

/* --- Content Area --- */
.content {
  flex: 1;
  padding: 16px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* --- Intro --- */
.intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px 0 8px;
  text-align: center;
}
.intro-icon { font-size: 56px; line-height: 1; }
.intro-text { font-size: 17px; line-height: 1.7; color: var(--text-primary); }
.record-badge {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-warm);
  padding: 6px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
}
.record-badge.hidden { display: none; }

/* --- Mini cards (stats) --- */
.data-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.mini-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  text-align: center;
}
.mini-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.mini-value { font-size: 26px; font-weight: 700; }

/* --- Focus States --- */
.focusable {
  transition: all 0.15s ease;
  border: 2px solid transparent;
  cursor: pointer;
  min-height: 44px;
}
.focusable:focus {
  outline: none;
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
}

/* --- Navigation Bar --- */
.nav-bar {
  display: flex;
  gap: 12px;
  padding: 14px 20px 18px;
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.nav-item {
  flex: 1;
  padding: 14px 12px;
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  font-family: inherit;
}
.nav-item.primary { background: #103246; color: var(--accent-primary); }

/* --- Help --- */
.help-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--text-primary);
}
.help-list li {
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.help-list b { color: var(--accent-primary); }

/* ==================== ゲーム画面 ==================== */
.game-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.status-title { font-size: 15px; color: var(--text-secondary); font-weight: 600; }
.status-chip {
  font-size: 15px;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  min-width: 84px;
  text-align: center;
}
.status-chip b { color: var(--text-primary); font-size: 17px; }

.board {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 104px);
  grid-template-rows: repeat(4, 104px);
  gap: 10px;
  justify-content: center;
  align-content: center;
}

.card {
  width: 104px;
  height: 104px;
  border-radius: var(--radius-md);
  background: transparent;
  perspective: 500px;
  padding: 0;
  font-family: inherit;
}
.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.3s cubic-bezier(0.4, 0.04, 0.5, 1);
}
.card.open .card-inner,
.card.matched .card-inner { transform: rotateY(180deg); }

.card-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.card-back {
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 30px;
  font-weight: 700;
}
.card-front {
  background: var(--bg-tertiary);
  font-size: 50px;
  transform: rotateY(180deg);
}
.card.matched .card-front {
  background: #1f1d10;
  box-shadow: inset 0 0 0 2px var(--accent-warm), 0 0 14px var(--match-glow);
}
.card.matched { opacity: 0.85; }

.game-footer {
  display: flex;
  justify-content: center;
  padding: 8px 20px 12px;
  flex-shrink: 0;
}
.quit-btn {
  padding: 10px 28px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  font-family: inherit;
  min-height: 44px;
}
