/* ===== リセット ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ===== ベース ===== */
body {
  background-color: #0b0b0e;
  color: #e2e2e9;
  font-family: 'Consolas', 'Courier New', monospace,
               'Hiragino Mincho ProN', 'BIZ UD Mincho', 'Yu Mincho', serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 16px 12px 40px;
  /* CRT風スキャンライン */
  background-image:
    linear-gradient(rgba(0,0,0,0) 50%, rgba(0,0,0,0.15) 50%),
    linear-gradient(90deg, rgba(180,100,0,0.02), rgba(255,200,0,0.01), rgba(180,100,0,0.02));
  background-size: 100% 4px, 6px 100%;
  user-select: none;
}

.container {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ===== ヘッダー ===== */
header {
  text-align: center;
  padding: 14px 16px 12px;
  border: 2px double #d4a520;
  background-color: rgba(10, 8, 0, 0.9);
  box-shadow: 0 0 18px rgba(212, 165, 32, 0.15);
  border-radius: 4px;
}

h1 {
  font-size: 1.9rem;
  color: #d4a520;
  text-shadow: 0 0 10px rgba(212, 165, 32, 0.6);
  letter-spacing: 6px;
  font-weight: bold;
  line-height: 1;
}

.subtitle {
  font-size: 0.68rem;
  color: #6a5418;
  letter-spacing: 8px;
  margin-top: 5px;
  font-family: 'Courier New', monospace;
}

/* ===== ルール説明エリア ===== */
.rules-section {
  background-color: rgba(0, 0, 0, 0.35);
  border: 1px solid #2a2515;
  border-radius: 4px;
  overflow: hidden;
}

.rules-toggle {
  width: 100%;
  padding: 9px 14px;
  background: none;
  border: none;
  color: #8a7030;
  font-family: inherit;
  font-size: 0.78rem;
  letter-spacing: 2px;
  cursor: pointer;
  text-align: left;
  transition: color 0.2s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.rules-toggle:hover { color: #d4a520; }

.rules-body {
  padding: 10px 14px 13px;
  border-top: 1px solid #2a2515;
}

.rules-text {
  font-size: 0.8rem;
  color: #aaa;
  line-height: 1.75;
  letter-spacing: 0.3px;
}

.rules-seasons {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.rules-season {
  font-size: 0.8rem;
  font-weight: bold;
  padding: 3px 10px;
  border-radius: 3px;
  letter-spacing: 2px;
}

.rs-spring { background: #5d1535; color: #ffb3cc; border: 1px solid #ff6699; }
.rs-summer { background: #153d30; color: #b3fff5; border: 1px solid #00ccaa; }
.rs-autumn { background: #3d2000; color: #ffd0aa; border: 1px solid #ff8844; }
.rs-winter { background: #152050; color: #b3ccff; border: 1px solid #66aaff; }

.rules-note {
  font-size: 0.7rem;
  color: #665a33;
  letter-spacing: 1px;
}

/* ===== スコアパネル ===== */
.score-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #0f0f18;
  border: 1px solid #2a2a3e;
  border-radius: 6px;
  padding: 10px 14px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.4);
}

.score-block {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.score-label {
  font-size: 0.65rem;
  letter-spacing: 2px;
  color: #778;
  display: block;
  margin-bottom: 2px;
}

.score-block { flex-direction: column; align-items: center; }

.score-value {
  font-size: 1.8rem;
  font-weight: bold;
  color: #d4a520;
  text-shadow: 0 0 6px rgba(212, 165, 32, 0.4);
  line-height: 1;
  font-family: 'Courier New', monospace;
}

.score-unit {
  font-size: 0.65rem;
  color: #778;
}

.deck-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.deck-label {
  font-size: 0.6rem;
  color: #556;
  letter-spacing: 2px;
}

.deck-count {
  font-size: 1.3rem;
  font-weight: bold;
  color: #888;
  font-family: 'Courier New', monospace;
}

.deck-unit {
  font-size: 0.6rem;
  color: #556;
}

/* ===== ターン表示 ===== */
.turn-display {
  text-align: center;
  font-size: 0.82rem;
  color: #d4a520;
  letter-spacing: 3px;
  text-shadow: 0 0 6px rgba(212, 165, 32, 0.4);
  padding: 6px 0;
}

.turn-display.thinking {
  color: #45f3ff;
  text-shadow: 0 0 6px rgba(69, 243, 255, 0.4);
  animation: thinkBlink 0.9s ease-in-out infinite;
}

@keyframes thinkBlink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.25; }
}

/* ===== メッセージ ===== */
.message {
  text-align: center;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 0.8rem;
  letter-spacing: 0.5px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.6;
  border: 1px solid transparent;
  transition: all 0.2s;
  white-space: pre-line; /* \n で改行 */
}

.message-normal { color: #778; border-color: #222; background-color: rgba(255,255,255,0.02); }
.message-player { color: #d4a520; border-color: rgba(212,165,32,0.3); background-color: rgba(212,165,32,0.06); }
.message-cpu    { color: #7a8a9a; border-color: rgba(100,120,150,0.3); background-color: rgba(100,120,150,0.04); }

.message-win {
  color: #d4a520;
  border-color: rgba(212,165,32,0.5);
  background-color: rgba(212,165,32,0.07);
  font-size: 0.9rem;
  font-weight: bold;
  text-shadow: 0 0 8px rgba(212,165,32,0.4);
  animation: pulseGold 1.2s ease-in-out infinite;
}

.message-lose {
  color: #ff4444;
  border-color: rgba(255,60,60,0.4);
  background-color: rgba(255,60,60,0.06);
  font-size: 0.9rem;
}

.message-draw {
  color: #aaa;
  border-color: rgba(150,150,150,0.35);
  background-color: rgba(150,150,150,0.05);
  font-size: 0.9rem;
}

@keyframes pulseGold {
  0%, 100% { box-shadow: 0 0 6px rgba(212,165,32,0.2); }
  50%       { box-shadow: 0 0 16px rgba(212,165,32,0.5); }
}

/* ===== エリア ===== */
.area {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.area-label {
  font-size: 0.65rem;
  color: #556;
  letter-spacing: 3px;
  padding: 0 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.hand-count {
  color: #445;
  font-size: 0.6rem;
}

/* ===== 手札・場札の行 ===== */
.hand-row {
  display: flex;
  gap: 6px;
  min-height: 96px;
  align-items: center;
}

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 96px;
  align-items: flex-start;
  padding: 6px;
  background-color: rgba(0,0,0,0.25);
  border: 1px solid #222;
  border-radius: 4px;
}

.empty-label {
  color: #333;
  font-size: 0.7rem;
  letter-spacing: 2px;
  align-self: center;
  margin: auto;
}

/* ===== カード（共通） ===== */
.card {
  width: 68px;
  height: 96px;
  border-radius: 6px;
  border: 2px solid;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 5px 4px 4px;
  flex-shrink: 0;
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* カード裏面（CPU手札） */
.card-back {
  background: repeating-linear-gradient(
    45deg,
    #181830 0px, #181830 6px,
    #121228 6px, #121228 12px
  );
  border-color: #334;
  cursor: default;
}

.card-back-mark {
  color: #334;
  font-size: 22px;
  opacity: 0.5;
}

/* カード表面（共通） */
.card-face {
  cursor: default;
}

/* プレイヤー手札はタップ可能 */
.card-face.clickable {
  cursor: pointer;
}

.card-face.clickable:hover {
  transform: translateY(-8px);
}

.card-face.clickable:active {
  transform: translateY(-4px) scale(0.96);
}

/* ===== カード内部 ===== */
.card-season-bar {
  font-size: 14px;
  font-weight: bold;
  letter-spacing: 4px;
  text-align: center;
  width: 100%;
  padding: 2px 0 3px;
  border-bottom: 1px solid rgba(255,255,255,0.18);
  font-family: 'Hiragino Mincho ProN', 'BIZ UD Mincho', 'Yu Mincho', serif;
  text-shadow: 0 0 8px currentColor;
}

.card-main-kanji {
  font-size: 30px;
  font-weight: bold;
  line-height: 1;
  font-family: 'Hiragino Mincho ProN', 'BIZ UD Mincho', 'Yu Mincho', serif;
  text-shadow: 0 0 8px currentColor;
}

.card-pts-badge {
  font-size: 9px;
  font-weight: bold;
  font-family: 'Courier New', monospace;
  background-color: rgba(0,0,0,0.35);
  padding: 1px 5px;
  border-radius: 2px;
  letter-spacing: 1px;
}

/* ===== 季節別カラー ===== */
.card-face[data-season="春"] {
  background: linear-gradient(150deg, #3d0a1e 0%, #5d1535 100%);
  border-color: #ff6699;
  color: #ffb3cc;
}
.card-face[data-season="春"] .card-main-kanji { text-shadow: 0 0 10px #ff6699; }
.card-face[data-season="春"].clickable:hover { box-shadow: 0 8px 20px rgba(255,102,153,0.5); }

.card-face[data-season="夏"] {
  background: linear-gradient(150deg, #0a2a20 0%, #153d30 100%);
  border-color: #00ccaa;
  color: #b3fff5;
}
.card-face[data-season="夏"] .card-main-kanji { text-shadow: 0 0 10px #00ccaa; }
.card-face[data-season="夏"].clickable:hover { box-shadow: 0 8px 20px rgba(0,204,170,0.5); }

.card-face[data-season="秋"] {
  background: linear-gradient(150deg, #2a1000 0%, #3d2000 100%);
  border-color: #ff8844;
  color: #ffd0aa;
}
.card-face[data-season="秋"] .card-main-kanji { text-shadow: 0 0 10px #ff8844; }
.card-face[data-season="秋"].clickable:hover { box-shadow: 0 8px 20px rgba(255,136,68,0.5); }

.card-face[data-season="冬"] {
  background: linear-gradient(150deg, #0a1535 0%, #152050 100%);
  border-color: #66aaff;
  color: #b3ccff;
}
.card-face[data-season="冬"] .card-main-kanji { text-shadow: 0 0 10px #66aaff; }
.card-face[data-season="冬"].clickable:hover { box-shadow: 0 8px 20px rgba(102,170,255,0.5); }

/* 取得演出（獲得した札をフラッシュさせる） */
@keyframes captureFlash {
  0%   { transform: scale(1.15); opacity: 1; }
  40%  { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

.card-face.captured {
  animation: captureFlash 0.3s ease-out forwards;
}

/* 新規配置アニメーション */
@keyframes cardAppear {
  0%   { transform: scale(0.6) translateY(10px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

.card.appear {
  animation: cardAppear 0.2s ease-out forwards;
}

/* ===== コントロール ===== */
.controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  padding-top: 4px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 22px;
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  font-weight: bold;
  letter-spacing: 2px;
  cursor: pointer;
  border-radius: 4px;
  text-decoration: none;
  transition: background-color 0.2s, box-shadow 0.2s, transform 0.1s;
  white-space: nowrap;
}

.btn-reset {
  background-color: transparent;
  border: 2px solid #d4a520;
  color: #d4a520;
}

.btn-reset:hover {
  background-color: rgba(212,165,32,0.1);
  box-shadow: 0 0 12px rgba(212,165,32,0.3);
}

.btn-reset:active {
  transform: scale(0.96);
}

.btn-back {
  background-color: transparent;
  border: 2px solid #45f3ff;
  color: #45f3ff;
}

.btn-back:hover {
  background-color: rgba(69,243,255,0.1);
  box-shadow: 0 0 12px rgba(69,243,255,0.3);
}

.btn-back:active {
  transform: scale(0.96);
}

/* ===== レスポンシブ：スマートフォン ===== */
@media (max-width: 400px) {
  body { padding: 12px 8px 30px; }

  h1 { font-size: 1.55rem; letter-spacing: 4px; }

  .card {
    width: 58px;
    height: 84px;
  }

  .card-main-kanji { font-size: 25px; }

  .score-value { font-size: 1.5rem; }

  .btn { font-size: 0.78rem; padding: 10px 16px; }
}

@media (max-width: 340px) {
  .card { width: 52px; height: 76px; }
  .card-main-kanji { font-size: 22px; }

  .controls { flex-direction: column; align-items: stretch; }
  .btn { text-align: center; }
}
