/* Love Live! Party!! - Premium UI */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;700;900&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg-deep: #0d0d1a;
  --bg-main: #141425;
  --bg-card: rgba(255,255,255,0.05);
  --bg-card-hover: rgba(255,255,255,0.1);
  --bg-glass: rgba(20,20,37,0.85);
  --border-subtle: rgba(255,255,255,0.08);
  --border-glow: rgba(255,167,81,0.4);
  --accent-gold: #ffa751;
  --accent-pink: #ff6b9d;
  --accent-red: #f43f5e;
  --accent-blue: #60a5fa;
  --accent-purple: #c084fc;
  --accent-green: #34d399;
  --accent-yellow: #fbbf24;
  --text-main: #f0f0f5;
  --text-dim: #8888aa;
  --text-muted: #555566;
  --shadow-card: 0 4px 20px rgba(0,0,0,0.4);
  --shadow-glow: 0 0 20px rgba(255,167,81,0.15);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 24px;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Noto Sans JP', 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
  background: var(--bg-deep);
  color: var(--text-main);
  touch-action: manipulation;
}

/* ============================================ */
/* タイトル画面                                  */
/* ============================================ */
#title-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: radial-gradient(ellipse at 50% 30%, #1e1040 0%, #0d0d1a 70%);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  position: relative;
  overflow: hidden;
}

#title-screen::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: conic-gradient(from 0deg, transparent, rgba(255,107,157,0.03), transparent, rgba(255,167,81,0.03), transparent);
  animation: titleBgSpin 20s linear infinite;
}

@keyframes titleBgSpin {
  to { transform: rotate(360deg); }
}

.title-logo {
  font-size: 2.6em;
  font-weight: 900;
  background: linear-gradient(135deg, #ff6b9d, #ffa751, #ffd700, #ff6b9d);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
  margin-bottom: 10px;
  animation: titleShimmer 3s ease-in-out infinite;
  position: relative;
  z-index: 1;
  letter-spacing: 2px;
}

@keyframes titleShimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.title-sub {
  font-size: 0.85em;
  color: var(--text-dim);
  margin-bottom: 40px;
  position: relative;
  z-index: 1;
  letter-spacing: 1px;
}

/* ============================================ */
/* キャラ選択画面                                 */
/* ============================================ */
#char-select-screen {
  display: none;
  flex-direction: column;
  height: 100%;
  background: radial-gradient(ellipse at 50% 20%, #1e1040 0%, var(--bg-deep) 70%);
  padding: env(safe-area-inset-top) 12px env(safe-area-inset-bottom);
}

.char-select-title {
  text-align: center;
  font-size: 1.3em;
  font-weight: 700;
  padding: 16px 0 8px;
  color: var(--accent-gold);
  letter-spacing: 1px;
}

.char-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  overflow-y: auto;
  padding: 8px 4px;
  flex: 1;
}

.char-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 10px 6px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
  backdrop-filter: blur(8px);
}

.char-card:active,
.char-card.selected {
  border-color: var(--accent-gold);
  background: rgba(255,167,81,0.12);
  transform: scale(0.97);
  box-shadow: 0 0 16px rgba(255,167,81,0.2);
}

.char-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  margin: 0 auto 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6em;
  font-weight: bold;
  color: #fff;
  overflow: hidden;
  position: relative;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

.char-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.char-card .char-name {
  font-size: 0.8em;
  font-weight: 700;
}

.char-card .char-attr {
  font-size: 0.65em;
  color: var(--text-dim);
  margin-top: 2px;
}

/* ============================================ */
/* ゲーム画面                                    */
/* ============================================ */
#game-screen {
  display: none;
  flex-direction: column;
  height: 100%;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  background: var(--bg-deep);
}

/* ヘッダー */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  background: linear-gradient(180deg, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0.2) 100%);
  font-size: 0.75em;
  min-height: 36px;
  border-bottom: 1px solid var(--border-subtle);
}

.turn-info {
  color: var(--accent-gold);
  font-weight: 700;
  letter-spacing: 1px;
}

.rank-info { color: var(--text-dim); }

/* ============================================ */
/* プレイヤーカード                               */
/* ============================================ */
.player-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 8px 8px 6px;
  flex-shrink: 0;
}

.p-card {
  background: linear-gradient(145deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0.02) 100%);
  border-radius: var(--radius-md);
  padding: 8px 4px 6px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
  position: relative;
  overflow: hidden;
}

.p-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.p-card.current {
  border-color: var(--accent-gold);
  background: linear-gradient(145deg, rgba(255,167,81,0.12) 0%, rgba(255,167,81,0.04) 100%);
  box-shadow: 0 0 16px rgba(255,167,81,0.15);
}

.p-card.finished {
  opacity: 0.45;
}

.p-card:active {
  transform: scale(0.96);
}

.p-card-player-label {
  font-size: 0.55em;
  color: var(--text-dim);
  margin-bottom: 3px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.p-card-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  margin: 0 auto 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: #fff;
  overflow: hidden;
  position: relative;
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
  border: 2px solid rgba(255,255,255,0.15);
}

.p-card-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.p-card-name {
  font-size: 0.65em;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.p-card-stats {
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 0.58em;
}

.p-card-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2px;
}

.p-card-stat-label {
  color: var(--text-dim);
}

.p-card-stat-value {
  font-weight: 700;
}

.p-card-fans { color: var(--accent-pink); }
.p-card-gold { color: var(--accent-yellow); }

/* ============================================ */
/* ボードマップ - 縦型パス                        */
/* ============================================ */
.board-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 8px;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

.board-path {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 0;
  padding: 10px 4px 20px;
  min-height: 100%;
  position: relative;
}

/* ヘアピン: 行 */
.board-row-hairpin {
  display: flex;
  gap: 2px;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.board-row-hairpin.reverse {
  flex-direction: row-reverse;
}

/* ヘアピン: 行内タイル間の横コネクター */
.board-connector-h {
  width: 8px;
  height: 3px;
  background: linear-gradient(90deg, rgba(255,255,255,0.08), rgba(255,255,255,0.25), rgba(255,255,255,0.08));
  border-radius: 2px;
  flex-shrink: 0;
}

/* ヘアピン: 行間の縦コネクター */
.board-connector-v {
  width: 100%;
  display: flex;
  justify-content: flex-end;
  padding: 0 8px;
}

.board-connector-v.align-left {
  justify-content: flex-start;
}

.board-connector-v-line {
  width: 3px;
  height: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.25), rgba(255,255,255,0.08));
  border-radius: 2px;
}

/* 旧スタイル（互換性のため残す） */
.board-row {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 100%;
}

.board-connector {
  width: 3px;
  height: 20px;
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.2), rgba(255,255,255,0.08));
  border-radius: 2px;
  flex-shrink: 0;
}

.tile {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1em;
  position: relative;
  transition: all 0.3s;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.1);
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.tile.blue { background: linear-gradient(135deg, #1e40af, #2563eb); border-color: rgba(37,99,235,0.4); }
.tile.red { background: linear-gradient(135deg, #b91c1c, #dc2626); border-color: rgba(220,38,38,0.4); }
.tile.live { background: linear-gradient(135deg, #a21caf, #d946ef); border-color: rgba(217,70,239,0.5); box-shadow: 0 0 14px rgba(217,70,239,0.3); }
.tile.member { background: linear-gradient(135deg, #6d28d9, #8b5cf6); border-color: rgba(139,92,246,0.4); }
.tile.event { background: linear-gradient(135deg, #047857, #10b981); border-color: rgba(16,185,129,0.4); }
.tile.shop { background: linear-gradient(135deg, #b45309, #d97706); border-color: rgba(217,119,6,0.4); }
.tile.rest { background: linear-gradient(135deg, #0e7490, #06b6d4); border-color: rgba(6,182,212,0.4); }
.tile.trouble { background: linear-gradient(135deg, #991b1b, #b91c1c); border-color: rgba(185,28,28,0.4); }
.tile.warp { background: linear-gradient(135deg, #3730a3, #6366f1); border-color: rgba(99,102,241,0.4); }
.tile.bonus { background: linear-gradient(135deg, #a16207, #eab308); border-color: rgba(234,179,8,0.4); }
.tile.start { background: linear-gradient(135deg, #047857, #10b981); border: 2px solid #34d399; box-shadow: 0 0 14px rgba(52,211,153,0.3); }
.tile.goal { background: linear-gradient(135deg, #be123c, #f43f5e); border: 2px solid #fb7185; box-shadow: 0 0 14px rgba(244,63,94,0.3); }
.tile.branch { background: linear-gradient(135deg, #6d28d9, #8b5cf6); border-color: rgba(139,92,246,0.4); }

.tile .tile-num {
  position: absolute;
  top: 2px;
  left: 5px;
  font-size: 0.4em;
  color: rgba(255,255,255,0.45);
  font-weight: 500;
}

.tile .tile-label {
  position: absolute;
  bottom: 2px;
  font-size: 0.35em;
  color: rgba(255,255,255,0.5);
  font-weight: 500;
  white-space: nowrap;
}

/* プレイヤー駒（キャラ画像） */
.player-tokens {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 2px;
  z-index: 10;
}

.p-token {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #fff;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
  position: relative;
}

.p-token img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.p-token.current-token {
  width: 26px;
  height: 26px;
  border-color: var(--accent-gold);
  box-shadow: 0 0 10px rgba(255,167,81,0.5);
  z-index: 11;
}

/* タイルハイライト */
@keyframes tileGlow {
  0%, 100% { box-shadow: 0 0 10px rgba(255,255,255,0.2); transform: scale(1); }
  50% { box-shadow: 0 0 24px rgba(255,167,81,0.4); transform: scale(1.04); }
}

.tile-highlight {
  animation: tileGlow 1.2s ease-in-out infinite;
}

/* ============================================ */
/* メッセージログ                                 */
/* ============================================ */
.message-log {
  padding: 6px 14px;
  background: linear-gradient(180deg, rgba(0,0,0,0.3) 0%, rgba(0,0,0,0.15) 100%);
  font-size: 0.75em;
  color: var(--text-dim);
  min-height: 28px;
  max-height: 104px;
  overflow-y: auto;
  border-top: 1px solid var(--border-subtle);
}

.message-log .msg { padding: 1px 0; }
.msg-good { color: var(--accent-green); }
.msg-bad { color: #f87171; }
.msg-info { color: var(--accent-blue); }
.msg-event { color: var(--accent-yellow); }

/* ============================================ */
/* アクションボタン                               */
/* ============================================ */
.action-bar {
  display: flex;
  gap: 8px;
  padding: 8px 12px 12px;
  background: linear-gradient(180deg, rgba(0,0,0,0.2) 0%, rgba(0,0,0,0.5) 100%);
  border-top: 1px solid var(--border-subtle);
}

.action-btn {
  flex: 1;
  padding: 13px 8px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.85em;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  letter-spacing: 0.5px;
  box-shadow: 0 3px 12px rgba(0,0,0,0.3);
}

.action-btn:active {
  transform: scale(0.96) translateY(1px);
  opacity: 0.85;
}

.action-btn:disabled {
  opacity: 0.35;
  transform: none;
  box-shadow: none;
}

.btn-dice {
  background: linear-gradient(135deg, #e11d48, #f43f5e);
}

.btn-skill {
  background: linear-gradient(135deg, #2563eb, #6366f1);
}

.btn-item {
  background: linear-gradient(135deg, #d97706, #f59e0b);
}

/* ============================================ */
/* モーダル                                      */
/* ============================================ */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
  animation: modalFadeIn 0.25s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: linear-gradient(145deg, #1e293b 0%, #172033 100%);
  border-radius: var(--radius-xl);
  padding: 22px;
  max-width: 380px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-title {
  font-size: 1.15em;
  font-weight: 700;
  text-align: center;
  margin-bottom: 16px;
  color: var(--accent-gold);
  letter-spacing: 1px;
}

/* ============================================ */
/* プレイヤー詳細モーダル                          */
/* ============================================ */
.detail-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.detail-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  border: 3px solid rgba(255,255,255,0.15);
  position: relative;
}

.detail-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.detail-info { flex: 1; }

.detail-player-name {
  font-size: 0.7em;
  color: var(--text-dim);
  margin-bottom: 2px;
}

.detail-char-name {
  font-size: 1.1em;
  font-weight: 700;
  margin-bottom: 4px;
}

.detail-attr {
  font-size: 0.75em;
  color: var(--text-dim);
}

.detail-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 18px;
}

.detail-stat-box {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
  border: 1px solid var(--border-subtle);
}

.detail-stat-label {
  font-size: 0.65em;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.detail-stat-value {
  font-size: 1.15em;
  font-weight: 700;
}

.detail-section-title {
  font-size: 0.8em;
  font-weight: 700;
  color: var(--accent-gold);
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255,167,81,0.2);
  letter-spacing: 0.5px;
}

.detail-skill-item {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-bottom: 6px;
  border: 1px solid var(--border-subtle);
}

.detail-skill-owner {
  font-size: 0.6em;
  color: var(--text-dim);
  margin-bottom: 2px;
}

.detail-skill-name {
  font-size: 0.85em;
  font-weight: 700;
  margin-bottom: 2px;
}

.detail-skill-desc {
  font-size: 0.72em;
  color: var(--text-dim);
}

.detail-skill-cost {
  font-size: 0.68em;
  color: var(--accent-blue);
  margin-top: 2px;
}

.detail-buddy-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 6px;
  border: 1px solid var(--border-subtle);
}

.detail-buddy-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
}

.detail-buddy-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.detail-buddy-info { flex: 1; }

.detail-buddy-name {
  font-size: 0.8em;
  font-weight: 700;
  margin-bottom: 1px;
}

.detail-buddy-skill {
  font-size: 0.65em;
  color: var(--text-dim);
}

.detail-bonus-item {
  padding: 4px 0;
  font-size: 0.75em;
  color: var(--accent-green);
}

.detail-section {
  margin-bottom: 16px;
}

/* ============================================ */
/* ライブモーダル                                 */
/* ============================================ */
.diff-option {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s;
  border: 2px solid transparent;
}

.diff-option:active {
  border-color: var(--accent-gold);
  background: rgba(255,167,81,0.1);
}

.diff-name {
  font-size: 1em;
  font-weight: 700;
  margin-bottom: 4px;
}

.diff-info {
  font-size: 0.75em;
  color: var(--text-dim);
}

/* ライブ結果 */
.live-result { text-align: center; }

.dice-display {
  font-size: 2.5em;
  margin: 16px 0;
  letter-spacing: 8px;
}

.result-label {
  font-size: 1.4em;
  font-weight: 700;
  margin: 12px 0;
}

.result-label.big-success { color: var(--accent-yellow); }
.result-label.success { color: var(--accent-green); }
.result-label.mediocre { color: #fb923c; }
.result-label.fail { color: #f87171; }

.result-detail {
  font-size: 0.85em;
  color: var(--text-dim);
  margin: 4px 0;
}

/* ============================================ */
/* イベントモーダル                               */
/* ============================================ */
.event-desc {
  text-align: center;
  font-size: 0.9em;
  margin: 12px 0;
  line-height: 1.6;
}

.choice-btn {
  display: block;
  width: 100%;
  padding: 13px;
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: #fff;
  font-size: 0.85em;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  font-family: inherit;
}

.choice-btn:active {
  border-color: var(--accent-gold);
  background: rgba(255,167,81,0.12);
}

.choice-label { font-weight: 700; margin-bottom: 2px; }
.choice-desc { color: var(--text-dim); font-size: 0.85em; }

/* ============================================ */
/* ショップモーダル                               */
/* ============================================ */
.shop-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.shop-item:active { background: rgba(255,167,81,0.1); }
.shop-item.disabled { opacity: 0.35; pointer-events: none; }

.shop-item-info { flex: 1; }
.shop-item-name { font-weight: 700; font-size: 0.85em; }
.shop-item-desc { font-size: 0.7em; color: var(--text-dim); }
.shop-item-cost { font-weight: 700; color: var(--accent-yellow); font-size: 0.85em; }

/* ============================================ */
/* メンバー加入モーダル                            */
/* ============================================ */
.member-option {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.member-option:active {
  background: rgba(255,167,81,0.1);
}

.member-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}

.member-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.member-info { flex: 1; }
.member-name { font-weight: 700; font-size: 0.85em; }
.member-skill { font-size: 0.7em; color: var(--text-dim); }

/* ============================================ */
/* スキルモーダル                                 */
/* ============================================ */
.skill-option {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 13px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.skill-option:active { background: rgba(255,167,81,0.1); }
.skill-option.disabled { opacity: 0.35; pointer-events: none; }

.skill-name { font-weight: 700; font-size: 0.85em; }
.skill-desc { font-size: 0.75em; color: var(--text-dim); margin-top: 2px; }
.skill-cost { font-size: 0.75em; color: var(--accent-blue); margin-top: 2px; }
.skill-owner { font-size: 0.65em; color: var(--text-muted); }

/* ============================================ */
/* ボタン共通                                    */
/* ============================================ */
.modal-btn {
  display: block;
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.9em;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  margin-top: 12px;
  font-family: inherit;
  letter-spacing: 0.5px;
}

.modal-btn:active { opacity: 0.85; }

.modal-btn-primary {
  background: linear-gradient(135deg, #e11d48, #ec4899);
  box-shadow: 0 3px 12px rgba(236,72,153,0.3);
}

.modal-btn-secondary {
  background: rgba(255,255,255,0.08);
  margin-top: 8px;
}

/* サイコロ選択モーダル */
.dice-choose-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 12px 0;
}

.dice-choose-btn {
  padding: 16px 8px;
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: #fff;
  font-size: 1.5em;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.dice-choose-btn:active {
  border-color: var(--accent-gold);
  background: rgba(255,167,81,0.15);
}

/* ターゲット選択 */
.target-option {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.target-option:active { background: rgba(255,167,81,0.1); }

.sb-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7em;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}

.sb-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.sb-fans { color: var(--accent-pink); margin-left: 2px; }

/* ============================================ */
/* ゲーム終了画面                                 */
/* ============================================ */
#result-screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: radial-gradient(ellipse at 50% 30%, #1e1040 0%, var(--bg-deep) 70%);
  padding: 20px;
}

.result-title {
  font-size: 1.6em;
  font-weight: 900;
  color: var(--accent-yellow);
  margin-bottom: 24px;
  letter-spacing: 2px;
}

.result-list {
  width: 100%;
  max-width: 360px;
}

.result-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 8px;
  border: 1px solid var(--border-subtle);
}

.result-entry.winner {
  background: rgba(255,215,0,0.08);
  border: 2px solid rgba(255,215,0,0.25);
  box-shadow: 0 0 20px rgba(255,215,0,0.1);
}

.result-rank {
  font-size: 1.4em;
  font-weight: 900;
  width: 36px;
  text-align: center;
}

.result-rank.gold { color: var(--accent-yellow); }
.result-rank.silver { color: #9ca3af; }
.result-rank.bronze { color: #d97706; }

.result-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.result-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.result-info { flex: 1; }
.result-name { font-weight: 700; }
.result-fans { color: var(--accent-pink); font-size: 0.85em; }

.btn-restart {
  margin-top: 24px;
  padding: 14px 40px;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #e11d48, #ec4899);
  color: #fff;
  font-size: 1em;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 4px 16px rgba(236,72,153,0.3);
  letter-spacing: 0.5px;
}

/* アイテムリスト */
.inventory-list { max-height: 50vh; overflow-y: auto; }

.inv-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.inv-item:active { background: rgba(255,167,81,0.1); }

/* スタートボタン */
.btn-start {
  padding: 14px 50px;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #e11d48, #ec4899);
  color: #fff;
  font-size: 1.1em;
  font-weight: 700;
  cursor: pointer;
  margin-top: 20px;
  font-family: inherit;
  transition: all 0.15s;
  box-shadow: 0 4px 16px rgba(236,72,153,0.3);
  letter-spacing: 0.5px;
  position: relative;
  z-index: 1;
}

.btn-start:active { transform: scale(0.96); }
.btn-start:disabled { opacity: 0.35; box-shadow: none; }

/* 移動先選択モーダル */
.move-choose-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 12px 0;
}

/* ボーナス表示 */
.bonus-list { font-size: 0.75em; color: var(--text-dim); margin-top: 8px; }
.bonus-item { padding: 2px 0; color: var(--accent-green); }

/* アイテム個数バッジ */
.item-count {
  background: rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 2px 8px;
  font-size: 0.75em;
  margin-left: 4px;
}

/* ============================================ */
/* 3Dサイコロ演出                                 */
/* ============================================ */
.dice-roll-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(3px);
  z-index: 200;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.dice-roll-overlay.active {
  display: flex;
  animation: modalFadeIn 0.2s ease-out;
}

.dice-roll-area {
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: center;
}

.dice-roll-result {
  font-size: 1.8em;
  font-weight: 900;
  color: var(--accent-gold);
  text-align: center;
  text-shadow: 0 2px 8px rgba(255,167,81,0.5);
  min-height: 1.8em;
  letter-spacing: 2px;
}

.dice-scene {
  width: 60px;
  height: 60px;
  flex-shrink: 0;
  perspective: 400px;
  user-select: none;
}

.dice-cube {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transform: translateZ(-30px);
  transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.dice-face {
  position: absolute;
  width: 60px;
  height: 60px;
  border: 2px solid rgba(255,255,255,0.3);
  background-color: #f8fafc;
  box-sizing: border-box;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
  box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
  background-size: 70%;
  background-repeat: no-repeat;
  background-position: center;
}

.dice-face.face-1 { transform: rotateY(  0deg) translateZ(30px); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='12' fill='%230f172a'/%3E%3C/svg%3E"); }
.dice-face.face-2 { transform: rotateY( 90deg) translateZ(30px); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='25' cy='25' r='10' fill='%230f172a'/%3E%3Ccircle cx='75' cy='75' r='10' fill='%230f172a'/%3E%3C/svg%3E"); }
.dice-face.face-3 { transform: rotateY(-180deg) translateZ(30px); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='25' cy='25' r='10' fill='%230f172a'/%3E%3Ccircle cx='50' cy='50' r='10' fill='%230f172a'/%3E%3Ccircle cx='75' cy='75' r='10' fill='%230f172a'/%3E%3C/svg%3E"); }
.dice-face.face-4 { transform: rotateY(-90deg) translateZ(30px); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='25' cy='25' r='10' fill='%230f172a'/%3E%3Ccircle cx='75' cy='25' r='10' fill='%230f172a'/%3E%3Ccircle cx='25' cy='75' r='10' fill='%230f172a'/%3E%3Ccircle cx='75' cy='75' r='10' fill='%230f172a'/%3E%3C/svg%3E"); }
.dice-face.face-5 { transform: rotateX( 90deg) translateZ(30px); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='25' cy='25' r='10' fill='%230f172a'/%3E%3Ccircle cx='75' cy='25' r='10' fill='%230f172a'/%3E%3Ccircle cx='25' cy='75' r='10' fill='%230f172a'/%3E%3Ccircle cx='75' cy='75' r='10' fill='%230f172a'/%3E%3Ccircle cx='50' cy='50' r='10' fill='%230f172a'/%3E%3C/svg%3E"); }
.dice-face.face-6 { transform: rotateX(-90deg) translateZ(30px); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='25' cy='20' r='10' fill='%230f172a'/%3E%3Ccircle cx='75' cy='20' r='10' fill='%230f172a'/%3E%3Ccircle cx='25' cy='50' r='10' fill='%230f172a'/%3E%3Ccircle cx='75' cy='50' r='10' fill='%230f172a'/%3E%3Ccircle cx='25' cy='80' r='10' fill='%230f172a'/%3E%3Ccircle cx='75' cy='80' r='10' fill='%230f172a'/%3E%3C/svg%3E"); }

@keyframes tumble {
  0% { transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg); }
  100% { transform: rotateX(360deg) rotateY(720deg) rotateZ(360deg); }
}

.dice-cube.rolling {
  animation: tumble 0.6s linear infinite;
}

.dice-cube.show-1 { transform: translateZ(-30px) rotateY(   0deg); }
.dice-cube.show-2 { transform: translateZ(-30px) rotateY( -90deg); }
.dice-cube.show-3 { transform: translateZ(-30px) rotateY(-180deg); }
.dice-cube.show-4 { transform: translateZ(-30px) rotateY(  90deg); }
.dice-cube.show-5 { transform: translateZ(-30px) rotateX( -90deg); }
.dice-cube.show-6 { transform: translateZ(-30px) rotateX(  90deg); }

@keyframes diceOverlayFadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

.dice-roll-overlay.fade-out {
  animation: diceOverlayFadeOut 0.3s ease-out forwards;
}

/* ============================================ */
/* アニメーション                                 */
/* ============================================ */
@keyframes diceRoll {
  0% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(90deg) scale(1.2); }
  50% { transform: rotate(180deg) scale(1); }
  75% { transform: rotate(270deg) scale(1.2); }
  100% { transform: rotate(360deg) scale(1); }
}

.dice-rolling { animation: diceRoll 0.6s ease-in-out; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fadeIn 0.3s ease-out; }

/* ============================================ */
/* レスポンシブ                                   */
/* ============================================ */
@media (min-width: 500px) {
  .board-path { max-width: 460px; margin: 0 auto; }
  .tile { width: 58px; height: 58px; font-size: 1.2em; }
  .p-token { width: 26px; height: 26px; }
  .p-token.current-token { width: 30px; height: 30px; }
  .char-grid { grid-template-columns: repeat(4, 1fr); }
  .p-card-avatar { width: 48px; height: 48px; }
  .board-connector-h { width: 12px; }
  .board-connector-v-line { height: 20px; }
}

@media (min-width: 768px) {
  #game-screen { max-width: 500px; margin: 0 auto; }
  #title-screen { max-width: 500px; margin: 0 auto; }
  #char-select-screen { max-width: 500px; margin: 0 auto; }
  #result-screen { max-width: 500px; margin: 0 auto; }
}
