/* ================================
   基本レイアウト
================================ */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #f4f6fb;
  color: #333;
}

.hidden {
  display: none !important;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 16px;
}

/* ================================
   ヘッダー
================================ */
.header {
  text-align: center;
  margin-bottom: 12px;
}

.header h1 {
  margin: 0;
  font-size: 1.8rem;
}

.subtitle {
  margin: 6px 0 0;
  font-size: 0.95rem;
  color: #555;
}

/* ================================
   メインコンテナ
================================ */
.main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 左カラム（現在のカード・ボタン・残りカード） */
.left-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ================================
   現在のカード
================================ */
.current-card {
  background: #ffffff;
  border-radius: 14px;
  padding: 14px 18px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

.current-label {
  font-weight: 600;
  margin-bottom: 8px;
}

.current-visual {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.current-image-frame {
  width: min(260px, 40vw);
  aspect-ratio: 3 / 4;
  background: #e0e0e0;
  border-radius: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.current-image-frame img {
  max-width: 90%;
  max-height: 90%;
}

.current-text {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.current-en {
  font-size: 1.6rem;
  font-weight: 700;
}

.current-count {
  font-size: 0.95rem;
  color: #555;
}

/* ================================
   ボタン群
================================ */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.btn {
  padding: 10px 18px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  transition: transform 0.06s ease, box-shadow 0.06s ease, filter 0.06s ease;
}

.btn:active {
  transform: translateY(1px);
  box-shadow: none;
  filter: brightness(0.96);
}

.btn.primary {
  background: #1e88e5;
  color: #fff;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.btn.secondary {
  background: #43a047;
  color: #fff;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.btn.outline {
  background: transparent;
  color: #555;
  border: 2px solid #bbb;
}

/* ================================
   残りカード一覧（左下）
================================ */
.remaining {
  background: #ffffff;
  border-radius: 14px;
  padding: 10px 14px 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.remaining h2 {
  margin: 0;
  font-size: 1.1rem;
}

.remaining-note {
  margin: 0;
  font-size: 0.85rem;
  color: #666;
}

.remaining-grid {
  margin-top: 4px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
}

.remaining-item {
  background: #f5f5f5;
  border-radius: 8px;
  padding: 2px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.remaining-item img {
  max-width: 80%;
  max-height: 40px;
}

/* ================================
   出たカード（右カラム）
================================ */
.history {
  background: #ffffff;
  border-radius: 14px;
  padding: 16px 20px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.history h2 {
  margin: 0 0 6px;
  font-size: 1.3rem;
}

.history-note {
  margin: 0 0 12px;
  font-size: 0.9rem;
  color: #666;
}

/* 出たカードを大きく見やすく配置 */
.history-grid {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr)); /* 大きい表示 */
  gap: 16px;
  padding-bottom: 10px;
  overflow-y: auto;
}

.history-item {
  background: #ffffff;
  border-radius: 12px;
  padding: 10px 6px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
  border: 2px solid #eee;
}

.history-item img {
  max-width: 85%;
  max-height: 140px;
}

.history-item div {
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
}

/* ================================
   最新カード特大オーバーレイ
================================ */
.big-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 3000;
}

.big-card {
  background: #ffffff;
  border-radius: 24px;
  padding: 18px 24px 22px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  max-width: min(90vw, 480px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  animation: pop-in 0.5s ease-out;
}

.big-image-frame {
  width: min(360px, 70vw);
  aspect-ratio: 3 / 4;
  background: #e0e0e0;
  border-radius: 18px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.big-image-frame img {
  max-width: 92%;
  max-height: 92%;
}

.big-label {
  font-size: 2rem;
  font-weight: 800;
}

/* ポップインアニメーション */
@keyframes pop-in {
  0% {
    transform: scale(0.1);
    opacity: 0;
  }
  60% {
    transform: scale(1.05);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ================================
   レスポンシブ調整
================================ */
@media (min-width: 960px) {
  .main {
    flex-direction: row;
    align-items: stretch;
  }

  .left-column {
    flex: 0 0 360px;
  }

  .history {
    flex: 1 1 auto;
  }
}

/* 中画面の時は3列に */
@media (max-width: 1200px) {
  .history-grid {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }
}

/* スマホは2列に */
@media (max-width: 800px) {
  .history-grid {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

  .big-label {
    font-size: 1.6rem;
  }
}
