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

body {
  font-family: 'Hiragino Sans', 'Meiryo', sans-serif;
  background: #1a472a;
  color: #fff;
  min-height: 100vh;
}

.screen { display: none; }
.screen.active { display: block; }
.hidden { display: none !important; }

/* ロビー */
.lobby-container {
  max-width: 420px;
  margin: 0 auto;
  padding: 60px 20px;
  text-align: center;
}

.lobby-container h1 {
  font-size: 2.8rem;
  margin-bottom: 8px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.subtitle {
  color: #a8d5b5;
  margin-bottom: 36px;
  font-size: 1rem;
}

.form-group {
  margin-bottom: 16px;
  text-align: left;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  color: #c8e6c9;
  font-size: 0.9rem;
}

.form-group input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 8px;
  border: 2px solid #4caf50;
  background: #2d6a3f;
  color: #fff;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: #81c784;
}

/* ボタン */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: bold;
  transition: all 0.2s;
}

.btn-primary {
  background: #4caf50;
  color: #fff;
  width: 100%;
  margin-top: 8px;
}
.btn-primary:hover { background: #66bb6a; transform: translateY(-1px); }

.btn-secondary {
  background: #666;
  color: #fff;
  width: 100%;
  margin-top: 8px;
}
.btn-secondary:hover { background: #888; }

.btn-action {
  width: 100%;
  margin: 4px 0;
  font-size: 1.1rem;
  padding: 14px;
}

.btn-change {
  background: #e53935;
  color: #fff;
}
.btn-change:hover { background: #ef5350; }

.btn-nochange {
  background: #1565c0;
  color: #fff;
}
.btn-nochange:hover { background: #1976d2; }

.btn-chain {
  background: #f57c00;
  color: #fff;
}
.btn-chain:hover { background: #fb8c00; }

.btn-kuku {
  background: #7b1fa2;
  color: #fff;
  animation: pulse-kuku 2s infinite;
}
.btn-kuku:hover { background: #9c27b0; }

@keyframes pulse-kuku {
  0%, 100% { box-shadow: 0 0 0 0 rgba(123, 31, 162, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(123, 31, 162, 0); }
}

/* ゲームレイアウト */
#game-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

#info-bar {
  display: flex;
  gap: 24px;
  padding: 8px 20px;
  background: rgba(0,0,0,0.3);
  align-items: center;
  flex-wrap: wrap;
}

.info-item {
  font-size: 0.9rem;
  color: #c8e6c9;
}
.info-label {
  color: #81c784;
  margin-right: 4px;
  font-size: 0.8rem;
}

#game-area {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* テーブルエリア */
#table-area {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
}

#players-circle {
  position: relative;
  width: min(80vw - 260px, 500px);
  height: min(80vw - 260px, 500px);
  min-width: 300px;
  min-height: 300px;
}

/* プレイヤーシート */
.player-seat {
  position: absolute;
  transform: translate(-50%, -50%);
  text-align: center;
  transition: all 0.3s;
}

.player-seat.current-turn {
  filter: drop-shadow(0 0 12px #ffd600);
}

.player-seat.disqualified {
  opacity: 0.5;
}

.player-seat.eliminated {
  opacity: 0.3;
}

.player-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #2e7d32;
  border: 3px solid #4caf50;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  margin: 0 auto 4px;
  transition: all 0.3s;
}

.player-seat.current-turn .player-avatar {
  border-color: #ffd600;
  background: #4a3f00;
  box-shadow: 0 0 16px #ffd600;
}

.player-seat.is-me .player-avatar {
  border-color: #42a5f5;
  background: #0d3b6e;
}

.player-seat.is-dealer .player-avatar::after {
  content: '👑';
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
}

.player-name {
  font-size: 0.75rem;
  font-weight: bold;
  max-width: 70px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-chips {
  font-size: 0.7rem;
  color: #ffd600;
}

.player-card-mini {
  width: 36px;
  height: 50px;
  border-radius: 4px;
  background: #2c5f2e;
  border: 2px solid #81c784;
  margin: 4px auto 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: bold;
  transition: all 0.3s;
  position: relative;
}

.player-card-mini.revealed {
  background: #fff;
  color: #222;
  border-color: #333;
}

.player-card-mini .card-back-owl {
  font-size: 1.2rem;
}

.player-card-mini .card-symbol-mini {
  font-size: 0.65rem;
  line-height: 1;
}

.player-card-mini .card-name-mini {
  font-size: 0.55rem;
  line-height: 1;
}

.player-status-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  font-size: 0.65rem;
  background: #d32f2f;
  border-radius: 4px;
  padding: 1px 3px;
}

/* 交換アニメーション */
#exchange-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  overflow: visible;
}

.exchange-arrow {
  stroke: #ffd600;
  stroke-width: 3;
  fill: none;
  stroke-dasharray: 8 4;
  animation: dash-move 0.6s linear infinite;
}

.exchange-arrow-head {
  fill: #ffd600;
}

@keyframes dash-move {
  to { stroke-dashoffset: -24; }
}

.flying-card {
  position: absolute;
  width: 36px;
  height: 50px;
  background: #fff;
  border: 2px solid #333;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: bold;
  color: #222;
  pointer-events: none;
  animation: fly-card 0.6s ease-in-out forwards;
  z-index: 100;
}

@keyframes fly-card {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  50% { transform: translate(var(--dx-half), var(--dy-half)) scale(1.3); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1); opacity: 0; }
}

/* クク宣言オーバーレイ */
#kuku-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(123, 31, 162, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fade-in 0.3s ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.kuku-banner {
  background: #7b1fa2;
  border: 4px solid #e040fb;
  border-radius: 16px;
  padding: 24px 48px;
  font-size: 2rem;
  font-weight: bold;
  box-shadow: 0 0 40px rgba(224, 64, 251, 0.6);
  animation: bounce-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes bounce-in {
  0% { transform: scale(0.5); }
  100% { transform: scale(1); }
}

/* サイドパネル */
#side-panel {
  width: 240px;
  background: rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 12px;
  overflow-y: auto;
}

#my-card-area h3,
#log-area h3 {
  font-size: 0.85rem;
  color: #81c784;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* 手札カード */
#my-card {
  width: 90px;
  height: 126px;
  border-radius: 10px;
  margin: 0 auto;
  cursor: default;
  perspective: 600px;
  transition: transform 0.3s;
}

.card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s;
}

.card-front, .card-back-face {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 10px;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.card-front {
  background: #fff;
  color: #222;
  border: 3px solid #333;
}

.card-back-face {
  background: #2c5f2e;
  border: 3px solid #81c784;
  font-size: 2.5rem;
  transform: rotateY(180deg);
}

.card.card-revealed .card-inner {
  transform: rotateY(0deg);
}

.card.card-back .card-inner {
  transform: rotateY(180deg);
}

.card-symbol {
  font-size: 1.4rem;
  font-weight: bold;
  color: #c62828;
}

.card-name {
  font-size: 1.1rem;
  font-weight: bold;
  margin-top: 4px;
}

.card-strength {
  font-size: 0.75rem;
  color: #666;
  margin-top: 4px;
}

/* 特殊カード色 */
.card-kuku .card-front { background: linear-gradient(135deg, #fff9c4, #fff); }
.card-kuku .card-symbol { color: #7b1fa2; }
.card-ningen .card-front { background: linear-gradient(135deg, #e3f2fd, #fff); }
.card-uma .card-front, .card-ie .card-front { background: linear-gradient(135deg, #e8f5e9, #fff); }
.card-neko .card-front { background: linear-gradient(135deg, #fce4ec, #fff); }
.card-douke .card-front { background: linear-gradient(135deg, #212121, #424242); color: #fff; }
.card-douke .card-symbol { color: #ff5722; }
.card-douke .card-name { color: #fff; }

/* アクションエリア */
#action-area {
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  padding: 10px;
  background: rgba(0,0,0,0.2);
}

#action-label {
  font-size: 0.85rem;
  color: #ffd600;
  margin-bottom: 8px;
  text-align: center;
  min-height: 20px;
}

/* ログ */
#log-area {
  flex: 1;
  overflow-y: auto;
}

#log-list {
  font-size: 0.78rem;
  line-height: 1.6;
  color: #c8e6c9;
}

.log-entry {
  padding: 2px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.log-entry.log-important {
  color: #ffd600;
  font-weight: bold;
}

.log-entry.log-kuku {
  color: #e040fb;
  font-weight: bold;
}

.log-entry.log-disq {
  color: #ef5350;
}

/* テーブル中央 */
#table-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
}

.table-pot {
  background: rgba(0,0,0,0.5);
  border: 2px solid #ffd600;
  border-radius: 50%;
  width: 80px;
  height: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
}

.table-pot-count {
  font-size: 1.3rem;
  font-weight: bold;
  color: #ffd600;
}

/* 結果オーバーレイ */
#result-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.7);
  z-index: 500;
  align-items: center;
  justify-content: center;
}

#result-overlay.show {
  display: flex;
}

.result-card {
  background: #1b5e20;
  border: 3px solid #4caf50;
  border-radius: 16px;
  padding: 32px 48px;
  text-align: center;
  max-width: 400px;
}

.result-card h2 {
  font-size: 1.8rem;
  margin-bottom: 16px;
}

.result-players {
  margin: 16px 0;
  text-align: left;
}

.result-player-row {
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  justify-content: space-between;
}

.result-player-row.loser {
  color: #ef5350;
}

.result-player-row.winner {
  color: #ffd600;
  font-weight: bold;
}

/* スマホ対応 */
@media (max-width: 600px) {
  #game-area {
    flex-direction: column;
  }
  #side-panel {
    width: 100%;
    max-height: 280px;
  }
  #players-circle {
    width: min(90vw, 300px);
    height: min(90vw, 300px);
  }
}

/* 山札表示 */
#deck-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.deck-pile {
  width: 50px;
  height: 70px;
  background: #2c5f2e;
  border: 2px solid #81c784;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 2px 2px 0 #1a3d1c, 4px 4px 0 #0f2310;
}

.deck-count {
  font-size: 0.75rem;
  color: #a5d6a7;
}

/* ========== アニメーション要素 ========== */

/* 全アニメーション要素の共通スタイル */
.anim-floater {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 400;
  user-select: none;
  line-height: 1;
}

/* カード交換: 飛び交うカード */
.anim-card-fly {
  width: 34px;
  height: 48px;
  background: #2c5f2e;
  border: 2px solid #81c784;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  box-shadow: 0 4px 14px rgba(0,0,0,0.5);
}

/* クク宣言フクロウ */
.anim-owl {
  font-size: 3rem;
  filter: drop-shadow(0 0 12px #e040fb);
}

/* 人間: 剣 */
.anim-sword {
  font-size: 2.4rem;
  filter: drop-shadow(0 0 6px #ef5350);
}

/* 人間: カットマーク */
.anim-cut {
  font-size: 2rem;
  filter: drop-shadow(0 0 6px #ef5350);
}

/* 道化 */
.anim-jester {
  font-size: 2.8rem;
  filter: drop-shadow(0 0 10px #ce93d8);
}

/* 猫 */
.anim-cat {
  font-size: 2rem;
  filter: drop-shadow(0 0 6px #ff9800);
  transition: transform 0.1s;
}
