/* ==========================================================================
   GLISSADE (グリサード) - CSS Stylesheet
   Design System: Cyber-Fantasy Premium Dark Theme
   ========================================================================== */

:root {
  /* Color Palette */
  --bg-primary: #0a0e1a;
  --bg-secondary: #121829;
  --panel-bg: rgba(22, 30, 54, 0.55);
  --panel-border: rgba(255, 255, 255, 0.08);
  
  --p1-color: #00c7fc; /* P1 (先攻/下/青) */
  --p1-glow: rgba(0, 199, 252, 0.4);
  --p1-light: #73e5ff;
  
  --p2-color: #ff3b30; /* P2 (後攻/上/赤) */
  --p2-glow: rgba(255, 59, 48, 0.4);
  --p2-light: #ff7b73;

  --p3-color: #00ff66; /* P3 (左/緑) */
  --p3-glow: rgba(0, 255, 102, 0.4);
  --p3-light: #73ffa2;

  --p4-color: #ffd700; /* P4 (右/黄) */
  --p4-glow: rgba(255, 215, 0, 0.4);
  --p4-light: #ffea73;
  
  --nexus-color: #ffd700;
  --nexus-glow: rgba(255, 215, 0, 0.4);
  
  --text-main: #f5f6fa;
  --text-muted: #8f9cae;
  
  /* Layout Dimensions */
  /* Using percentage-based fluid layout instead of static dimensions */
}

/* Washi Craft (和風・漆器) */
body[data-theme="washi"] {
  --bg-primary: #120e0e; /* 落ち着いた暗漆黒 */
  --bg-secondary: #1a1414;
  --panel-bg: rgba(35, 20, 20, 0.75);
  --panel-border: rgba(217, 56, 58, 0.2);
  
  --p1-color: #ffd700; /* P1先攻＝高貴なゴールド（金箔） */
  --p1-glow: rgba(255, 215, 0, 0.5);
  --p1-light: #fff099;
  
  --p2-color: #d9383a; /* P2後攻＝本朱（朱漆） */
  --p2-glow: rgba(217, 56, 58, 0.6);
  --p2-light: #ff7a7c;

  --p3-color: #2e8b57; /* P3＝松葉・シーグリーン */
  --p3-glow: rgba(46, 139, 87, 0.5);
  --p3-light: #7cb897;

  --p4-color: #e2a014; /* P4＝琥珀・黄金 */
  --p4-glow: rgba(226, 160, 20, 0.5);
  --p4-light: #ffce6d;
  
  --nexus-color: #8af0cc; /* 若竹・青磁（金・朱赤と対比される澄んだ淡緑） */
  --nexus-glow: rgba(138, 240, 204, 0.4);
  
  --text-main: #fcfaf2; /* 生成り・和紙色 */
  --text-muted: #968c83;
}

/* Forest Wood (クラシック木調) */
body[data-theme="wood"] {
  --bg-primary: #1a1713; /* 暗い焦げ茶・黒檀 */
  --bg-secondary: #26211b;
  --panel-bg: rgba(45, 38, 30, 0.7);
  --panel-border: rgba(141, 110, 99, 0.25);
  
  --p1-color: #2e7d32; /* P1先攻＝深緑（針葉樹） */
  --p1-glow: rgba(46, 125, 50, 0.5);
  --p1-light: #81c784;
  
  --p2-color: #ffb300; /* P2後攻＝琥珀・オーク */
  --p2-glow: rgba(255, 179, 0, 0.5);
  --p2-light: #ffe082;

  --p3-color: #d84315; /* P3＝欅朱・煉瓦オレンジ */
  --p3-glow: rgba(216, 67, 21, 0.5);
  --p3-light: #ff8a65;

  --p4-color: #8d6e63; /* P4＝欅チャコールブラウン */
  --p4-glow: rgba(141, 110, 99, 0.5);
  --p4-light: #d7ccc8;
  
  --nexus-color: #ffb7c5; /* 桜木・淡サクラ（深緑・琥珀と対比される優しいピンク） */
  --nexus-glow: rgba(255, 183, 197, 0.4);
  
  --text-main: #efebe9;
  --text-muted: #a1887f;
}

/* Base Reset & Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  position: relative;
}

/* Background Glow Effects */
.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  z-index: -1;
  opacity: 0.4;
  pointer-events: none;
}

.bg-glow-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--p1-color) 0%, transparent 70%);
  top: -10%;
  left: -10%;
}

.bg-glow-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--p2-color) 0%, transparent 70%);
  bottom: -10%;
  right: -10%;
}

/* Glassmorphism Panel Template */
.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* Application Container */
.app-container {
  width: 100%;
  max-width: 1200px;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0 auto;
  position: relative;
}

/* Header */
.game-header {
  text-align: center;
  margin-bottom: 25px;
  animation: fadeInDown 0.8s ease-out;
}

.logo-area {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.logo-icon {
  color: var(--nexus-color);
  width: 32px;
  height: 32px;
  filter: drop-shadow(0 0 8px var(--nexus-glow));
  animation: pulseGold 2s infinite alternate;
}

.game-header h1 {
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: 4px;
  background: linear-gradient(135deg, #ffffff 30%, var(--text-muted) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.game-header .subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 300;
  letter-spacing: 2px;
  margin-top: 5px;
}

/* Game Layout Grid */
.game-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 40px;
  width: 100%;
  max-width: 1100px;
  align-items: start;
}

/* Left Panel: Controls */
.control-panel {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.panel-section h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-section h2 i {
  width: 18px;
  height: 18px;
}

/* Mode Selection */
.mode-select {
  display: flex;
  gap: 10px;
  background: rgba(0, 0, 0, 0.2);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.btn-mode {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.3s ease;
}

.btn-mode i {
  width: 16px;
  height: 16px;
}

.btn-mode.active {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Difficulty Selector */
.difficulty-select {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  background: rgba(0, 0, 0, 0.1);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.85rem;
}

.difficulty-select .label {
  color: var(--text-muted);
}

.btn-diff {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.8rem;
}

.btn-diff.active {
  background: var(--nexus-color);
  color: #000;
  border-color: var(--nexus-color);
  font-weight: 600;
  box-shadow: 0 0 8px var(--nexus-glow);
}

/* Player Status Cards */
.player-status-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.player-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.03);
  transition: all 0.3s ease;
}

.player-card.active {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.12);
}

.player-card.player-1.active {
  box-shadow: inset 0 0 12px var(--p1-glow);
  border-color: var(--p1-color);
}

.player-card.player-2.active {
  box-shadow: inset 0 0 12px var(--p2-glow);
  border-color: var(--p2-color);
}

.player-card.player-3.active {
  box-shadow: inset 0 0 12px var(--p3-glow);
  border-color: var(--p3-color);
}

.player-card.player-4.active {
  box-shadow: inset 0 0 12px var(--p4-glow);
  border-color: var(--p4-color);
}

.player-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0; /* フレックスコンテナ内での押しつぶしを防止 */
}

.player-avatar::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow: 0 0 10px currentColor;
  opacity: 0.6;
}

.red-theme {
  background: var(--p2-color);
  color: var(--p2-color);
}

.blue-theme {
  background: var(--p1-color);
  color: var(--p1-color);
}

.green-theme {
  background: var(--p3-color);
  color: var(--p3-color);
}

.yellow-theme {
  background: var(--p4-color);
  color: var(--p4-color);
}

.player-avatar .special-icon {
  color: #fff;
  width: 18px;
  height: 18px;
}

.player-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.player-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.player-card.player-1 .player-name {
  color: var(--p1-light);
}

.player-card.player-2 .player-name {
  color: var(--p2-light);
}

.player-card.player-3 .player-name {
  color: var(--p3-light);
}

.player-card.player-4 .player-name {
  color: var(--p4-light);
}

.player-status {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.player-card.active .player-status {
  color: #fff;
  font-weight: 600;
  animation: pulseText 1.5s infinite alternate;
}

/* Panel Actions */
.panel-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-action {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.btn-action i {
  width: 18px;
  height: 18px;
}

.btn-action.primary {
  background: linear-gradient(135deg, var(--nexus-color) 0%, #ffae00 100%);
  color: #000;
  box-shadow: 0 4px 15px rgba(255, 215, 0, 0.25);
}

.btn-action.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 215, 0, 0.4);
}

.btn-action.secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.btn-action.secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
}

/* Center Column: Game Board */
.board-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

/* Turn Banner for Mobile / Subheader */
.turn-banner {
  width: 100%;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  text-align: center;
  font-size: 0.95rem;
  letter-spacing: 1px;
  font-weight: 600;
  display: none; /* Desktop hides this since player-card has indicator */
  transition: all 0.3s ease;
}

.turn-banner[data-turn="p1"] {
  border: 2px solid var(--p1-color);
  box-shadow: 0 0 15px var(--p1-glow);
  background: rgba(255, 255, 255, 0.03);
}

.turn-banner[data-turn="p2"] {
  border: 2px solid var(--p2-color);
  box-shadow: 0 0 15px var(--p2-glow);
  background: rgba(255, 255, 255, 0.03);
}

.turn-banner[data-turn="p3"] {
  border: 2px solid var(--p3-color);
  box-shadow: 0 0 15px var(--p3-glow);
  background: rgba(255, 255, 255, 0.03);
}

.turn-banner[data-turn="p4"] {
  border: 2px solid var(--p4-color);
  box-shadow: 0 0 15px var(--p4-glow);
  background: rgba(255, 255, 255, 0.03);
}

.board-wrapper {
  padding: 15px;
  position: relative;
  width: min(100%, 92vw, 80vh, 650px); /* PC大画面対応: 親カラムの100%を超えず、画面高さを超えず、最大650pxまで自動伸縮 */
  aspect-ratio: 1 / 1;
  display: flex;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
}

.board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
  width: 100%;
  height: auto; /* WebKitでの潰れを防ぐため高さを自動にし、アスペクト比を固定 */
  aspect-ratio: 1 / 1;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
  position: relative;
}

/* Board Background Cells */
.cell {
  border: 1px solid rgba(255, 255, 255, 0.12);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Nexus: Center Cell (2,2) */
.cell-nexus {
  background: radial-gradient(circle, rgba(255, 215, 0, 0.15) 0%, transparent 80%);
  border: 1px solid rgba(255, 215, 0, 0.3) !important;
  box-shadow: inset 0 0 15px rgba(255, 215, 0, 0.1);
  overflow: visible;
}

.cell-nexus::before {
  content: '';
  position: absolute;
  width: 80%;
  height: 80%;
  border: 2px dashed rgba(255, 215, 0, 0.5);
  border-radius: 50%;
  animation: rotateNexus 12s linear infinite;
}

.cell-nexus::after {
  content: '';
  position: absolute;
  width: 40%;
  height: 40%;
  background: var(--nexus-color);
  border-radius: 50%;
  opacity: 0.3;
  filter: blur(4px);
  animation: pulseGold 2s infinite alternate;
}

/* Piece Layer */
.pieces-layer {
  position: absolute;
  top: 15px;
  left: 15px;
  right: 15px;
  bottom: 15px;
  pointer-events: none; /* Allows click events to pass through to grid if needed, though we trigger events on pieces */
}

/* Game Piece */
.piece {
  position: absolute;
  width: calc(100% / var(--grid-size, 5));
  height: auto; /* WebKit/Safariでの楕円化を防ぐ */
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto; /* Re-enable clicks */
  cursor: pointer;
  
  /* Position calculations via JS setting --row and --col variables */
  top: calc(var(--row) * 100% / var(--grid-size, 5));
  left: calc(var(--col) * 100% / var(--grid-size, 5));
  
  /* Slide Transition! */
  transition: top 0.42s cubic-bezier(0.25, 1, 0.4, 1), 
              left 0.42s cubic-bezier(0.25, 1, 0.4, 1),
              transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
              
  z-index: 10;
}

/* Piece Inner Core */
.piece-inner {
  width: 72%;
  height: 72%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.25);
  position: relative;
  transition: all 0.25s ease;
}

.piece-inner::before {
  content: '';
  position: absolute;
  top: -4px; left: -4px; right: -4px; bottom: -4px;
  border-radius: 50%;
  border: 1px solid transparent;
  opacity: 0;
  transition: all 0.3s;
}

/* Player 1 Pieces (P1 Theme) */
.piece-p1 .piece-inner {
  background: linear-gradient(135deg, var(--p1-color) 0%, var(--p1-glow) 100%);
  box-shadow: 0 0 10px var(--p1-glow);
}

/* Player 2 Pieces (P2 Theme) */
.piece-p2 .piece-inner {
  background: linear-gradient(135deg, var(--p2-color) 0%, var(--p2-glow) 100%);
  box-shadow: 0 0 10px var(--p2-glow);
}

.piece-p3 .piece-inner {
  background: linear-gradient(135deg, var(--p3-color) 0%, var(--p3-glow) 100%);
  box-shadow: 0 0 10px var(--p3-glow);
}

.piece-p4 .piece-inner {
  background: linear-gradient(135deg, var(--p4-color) 0%, var(--p4-glow) 100%);
  box-shadow: 0 0 10px var(--p4-glow);
}

/* Crown Piece Design */
.piece-special .piece-inner {
  width: 78%;
  height: 78%;
  border-width: 3px;
  border-color: #ffffff;
}

.piece-special.piece-p1 .piece-inner {
  background: linear-gradient(135deg, var(--p1-light) 0%, var(--p1-color) 40%, var(--nexus-color) 100%);
  box-shadow: 0 0 20px var(--p1-glow);
}

.piece-special.piece-p2 .piece-inner {
  background: linear-gradient(135deg, var(--p2-light) 0%, var(--p2-color) 40%, var(--nexus-color) 100%);
  box-shadow: 0 0 20px var(--p2-glow);
}

.piece-special.piece-p3 .piece-inner {
  background: linear-gradient(135deg, var(--p3-light) 0%, var(--p3-color) 40%, var(--nexus-color) 100%);
  box-shadow: 0 0 20px var(--p3-glow);
}

.piece-special.piece-p4 .piece-inner {
  background: linear-gradient(135deg, var(--p4-light) 0%, var(--p4-color) 40%, var(--nexus-color) 100%);
  box-shadow: 0 0 20px var(--p4-glow);
}

/* Special Crown Icon Styles */
.piece-special i {
  color: #ffffff;
  width: 20px;
  height: 20px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
  animation: pulseGold 2s infinite alternate;
}

/* Interactive States */
.piece:hover .piece-inner {
  transform: scale(1.08);
}

.piece-p1:hover .piece-inner {
  box-shadow: 0 0 16px var(--p1-color);
}

.piece-p2:hover .piece-inner {
  box-shadow: 0 0 16px var(--p2-color);
}

.piece-p3:hover .piece-inner {
  box-shadow: 0 0 16px var(--p3-color);
}

.piece-p4:hover .piece-inner {
  box-shadow: 0 0 16px var(--p4-color);
}

/* Selected State */
.piece.selected {
  z-index: 15;
}

.piece.selected .piece-inner {
  transform: scale(1.15);
  border-color: #fff;
  box-shadow: 0 0 25px currentColor;
}

.piece.selected .piece-inner::before {
  opacity: 1;
  border-color: #fff;
  transform: scale(1.12);
  animation: rotateNexus 4s linear infinite;
}

/* Destination Target Overlay (Hints) */
.move-hint {
  position: absolute;
  width: calc(100% / var(--grid-size, 5));
  height: auto; /* WebKitでの楕円化を防ぐ */
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 12;
  cursor: pointer;
  pointer-events: auto;
  
  top: calc(var(--row) * 100% / var(--grid-size, 5));
  left: calc(var(--col) * 100% / var(--grid-size, 5));
  animation: fadeIn 0.25s ease-out;
}

.move-hint-inner {
  width: 60%;
  height: 60%;
  border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.6);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
}

.move-hint:hover .move-hint-inner {
  background: rgba(255, 255, 255, 0.2);
  border-color: #ffffff;
  color: #ffffff;
  transform: scale(1.1);
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

/* Custom styles for P1/P2 dynamic indicator color of hints */
.move-hint.p1-hint .move-hint-inner {
  border-color: var(--p1-light);
  background: rgba(255, 255, 255, 0.05);
  color: var(--p1-light);
}
.move-hint.p1-hint:hover .move-hint-inner {
  border-color: var(--p1-color);
  background: var(--p1-glow);
  box-shadow: 0 0 15px var(--p1-glow);
}

.move-hint.p2-hint .move-hint-inner {
  border-color: var(--p2-light);
  background: rgba(255, 255, 255, 0.05);
  color: var(--p2-light);
}
.move-hint.p2-hint:hover .move-hint-inner {
  border-color: var(--p2-color);
  background: var(--p2-glow);
  box-shadow: 0 0 15px var(--p2-glow);
}

.move-hint.p3-hint .move-hint-inner {
  border-color: var(--p3-light);
  background: rgba(255, 255, 255, 0.05);
  color: var(--p3-light);
}
.move-hint.p3-hint:hover .move-hint-inner {
  border-color: var(--p3-color);
  background: var(--p3-glow);
  box-shadow: 0 0 15px var(--p3-glow);
}

.move-hint.p4-hint .move-hint-inner {
  border-color: var(--p4-light);
  background: rgba(255, 255, 255, 0.05);
  color: var(--p4-light);
}
.move-hint.p4-hint:hover .move-hint-inner {
  border-color: var(--p4-color);
  background: var(--p4-glow);
  box-shadow: 0 0 15px var(--p4-glow);
}

.move-hint i {
  width: 20px;
  height: 20px;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  display: none !important;
}

.modal-content {
  width: 90%;
  max-width: 500px;
  padding: 30px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 1.4rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--nexus-color);
}

.modal-header h2 i {
  width: 24px;
  height: 24px;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s;
}

.btn-close:hover {
  color: #fff;
}

.modal-body ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-body li {
  font-size: 0.95rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.85);
  position: relative;
  padding-left: 20px;
}

.modal-body li::before {
  content: '✦';
  position: absolute;
  left: 0;
  color: var(--nexus-color);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

/* Result Modal Special Styling */
.result-content {
  text-align: center;
  align-items: center;
  padding: 40px;
}

.trophy-glow {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 215, 0, 0.2) 0%, transparent 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
  border: 1px solid rgba(255, 215, 0, 0.15);
}

.trophy-icon {
  width: 48px;
  height: 48px;
  color: var(--nexus-color);
  filter: drop-shadow(0 0 15px var(--nexus-glow));
  animation: bounceTrophy 1.5s infinite ease-in-out alternate;
}

.result-content h2 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 1px;
}

.result-content p {
  color: var(--text-muted);
  font-size: 1rem;
  margin-bottom: 10px;
}

.btn-large {
  padding: 14px 28px;
  font-size: 1.1rem;
}

/* ==========================================================================
   Animations
   ========================================================================== */

@keyframes rotateNexus {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes pulseGold {
  from { filter: drop-shadow(0 0 2px rgba(255, 215, 0, 0.3)); }
  to { filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.7)); }
}

@keyframes pulseText {
  from { opacity: 0.6; }
  to { opacity: 1; }
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

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

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes bounceTrophy {
  from { transform: translateY(0) scale(1); }
  to { transform: translateY(-8px) scale(1.05); }
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 900px) {
  body {
    padding-top: 15px;
    padding-bottom: 30px;
  }

  .app-container {
    padding: 15px 10px;
    width: 100%;
    margin: 0 auto;
    overflow-x: hidden;
  }

  .game-header {
    margin-bottom: 15px;
    width: 100%;
    text-align: center;
  }

  .game-header h1 {
    font-size: 2.2rem;
  }

  .game-layout {
    grid-template-columns: 1fr;
    gap: 15px;
    max-width: 480px;
    width: 100%;
    margin: 0 auto;
  }

  .control-panel {
    order: 2; /* Move controls to the bottom on mobile */
    padding: 16px;
    gap: 16px;
  }

  .board-container {
    order: 1;
    gap: 12px;
  }

  .board-wrapper {
    width: min(100%, 92vw, 440px); /* スマホ時の表示崩れ防止: 親要素の100%を超えず、最大440pxに抑える */
  }

  .turn-banner {
    display: block; /* Show turn banner in mobile view above board */
  }

  .player-status-section {
    flex-direction: column;
    gap: 8px;
  }

  .player-card {
    padding: 10px 14px;
    gap: 10px;
  }

  .player-avatar {
    width: 28px;
    height: 28px;
  }

  .player-name {
    font-size: 0.8rem;
  }

  .difficulty-select {
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  .btn-diff {
    padding: 3px 8px;
    font-size: 0.75rem;
  }

  .mode-select {
    padding: 3px;
  }

  .btn-mode {
    padding: 8px 10px;
    font-size: 0.8rem;
  }
}

@media (max-width: 360px) {
  /* For very narrow phones like iPhone SE */
  .player-status-section {
    flex-direction: column;
    gap: 6px;
  }

  .game-header h1 {
    font-size: 1.8rem;
    letter-spacing: 2px;
  }

  .game-header .subtitle {
    font-size: 0.8rem;
    letter-spacing: 1px;
  }

  .btn-action {
    padding: 10px;
    font-size: 0.85rem;
  }
}

/* ==========================================================================
   Puzzle Mode UI Styles
   ========================================================================== */

/* Puzzle Stages Grid */
.puzzle-stages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 16px;
  padding: 10px;
}

.stage-card {
  aspect-ratio: 1.1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.25, 1, 0.4, 1);
  position: relative;
  overflow: hidden;
  gap: 6px;
}

.stage-card:hover:not(.locked) {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--nexus-color);
  transform: translateY(-4px);
  box-shadow: 0 6px 20px rgba(255, 215, 0, 0.15);
}

.stage-card.locked {
  opacity: 0.35;
  cursor: not-allowed;
  background: rgba(0, 0, 0, 0.2);
}

.stage-card.cleared {
  border-color: rgba(129, 199, 132, 0.35);
  background: rgba(46, 125, 50, 0.06);
}

.stage-number {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.stage-card.cleared .stage-number {
  color: #81c784;
}

.stage-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  text-align: center;
  padding: 0 8px;
}

.stage-moves {
  font-size: 0.7rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 8px;
  border-radius: 10px;
}

.stage-card.cleared .stage-moves {
  color: #c8e6c9;
  background: rgba(76, 175, 80, 0.15);
}

.stage-status-icon {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stage-status-icon i {
  width: 14px;
  height: 14px;
}

.stage-status-icon.cleared-icon {
  color: #81c784;
}

.stage-status-icon.locked-icon {
  color: var(--text-muted);
}

/* Puzzle Result styles */
.puzzle-result-icon-area.success {
  background: rgba(46, 125, 50, 0.15) !important;
  border: 1px solid rgba(76, 175, 80, 0.3);
  box-shadow: 0 0 20px rgba(76, 175, 80, 0.3);
  color: #81c784;
}

.puzzle-result-icon-area.fail {
  background: rgba(255, 59, 48, 0.15) !important;
  border: 1px solid rgba(255, 59, 48, 0.3);
  box-shadow: 0 0 20px rgba(255, 59, 48, 0.3);
  color: #ff3b30;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   Welcome Screen (Title Menu) Styles
   ========================================================================== */
.welcome-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  overflow-y: auto;
  overflow-x: hidden;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.welcome-screen.hidden {
  opacity: 0;
  transform: scale(1.05);
  pointer-events: none;
  display: none !important;
}

.welcome-glow {
  position: absolute;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--p1-color) 0%, transparent 60%);
  filter: blur(80px);
  opacity: 0.15;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: welcomeGlowPulse 8s infinite alternate;
}

@keyframes welcomeGlowPulse {
  0% { opacity: 0.12; transform: translate(-50%, -50%) scale(0.9); }
  100% { opacity: 0.22; transform: translate(-50%, -50%) scale(1.1); }
}

.welcome-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 90%;
  max-width: 900px;
  gap: 48px;
}

.welcome-logo-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.welcome-logo-icon {
  width: 48px;
  height: 48px;
  color: var(--nexus-color);
  filter: drop-shadow(0 0 10px var(--nexus-glow));
  animation: logoFloat 4s infinite ease-in-out;
}

.welcome-logo {
  font-family: 'Outfit', sans-serif;
  font-size: 4rem;
  font-weight: 800;
  letter-spacing: 8px;
  background: linear-gradient(135deg, var(--text-main) 30%, var(--nexus-color) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.1));
}

.welcome-subtitle {
  font-size: 1rem;
  color: var(--text-muted);
  letter-spacing: 6px;
  text-transform: uppercase;
}

.welcome-modes {
  display: flex;
  gap: 24px;
  width: 100%;
}

.welcome-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 40px 30px;
  border-radius: 20px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(16px);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 1, 0.4, 1);
  gap: 16px;
}

.welcome-card:hover {
  transform: translateY(-8px);
  border-color: var(--card-hover-border);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3), 0 0 20px var(--card-hover-glow);
}

.battle-card {
  --card-hover-border: rgba(0, 199, 252, 0.3);
  --card-hover-glow: rgba(0, 199, 252, 0.1);
}

.puzzle-card {
  --card-hover-border: rgba(255, 215, 0, 0.3);
  --card-hover-glow: rgba(255, 215, 0, 0.1);
}

body[data-theme="washi"] .welcome-card:hover {
  border-color: rgba(217, 56, 58, 0.35);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.35), 0 0 20px rgba(217, 56, 58, 0.15);
}

body[data-theme="wood"] .welcome-card:hover {
  border-color: rgba(46, 125, 50, 0.35);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.35), 0 0 20px rgba(46, 125, 50, 0.15);
}

.card-icon-wrapper {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-main);
  transition: all 0.3s ease;
}

.welcome-card:hover .card-icon-wrapper {
  color: #fff;
  transform: scale(1.1);
}

.battle-card:hover .card-icon-wrapper {
  background: rgba(0, 199, 252, 0.15);
  border-color: rgba(0, 199, 252, 0.3);
}

.puzzle-card:hover .card-icon-wrapper {
  background: rgba(255, 215, 0, 0.15);
  border-color: rgba(255, 215, 0, 0.3);
}

.welcome-card h3 {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-main);
}

.welcome-card p {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
  flex-grow: 1;
}

.btn-play-mode {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  padding: 10px 24px;
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: all 0.2s ease;
}

.welcome-card:hover .btn-play-mode {
  background: #fff;
  color: #000;
  box-shadow: 0 5px 15px rgba(255, 255, 255, 0.15);
}

/* Home Button styling */
.btn-home {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: 8px;
  transition: all 0.2s ease;
  margin-right: 8px;
}

.btn-home:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.btn-home i {
  width: 20px;
  height: 20px;
}

/* Responsive adjustment for welcome menu */
@media (max-width: 768px) {
  .welcome-screen {
    align-items: flex-start;
    padding: 40px 10px;
  }
  .welcome-modes {
    flex-direction: column;
    gap: 16px;
  }
  .welcome-logo {
    font-size: 3rem;
  }
  .welcome-card {
    padding: 30px 20px;
  }
}

/* Puzzle Info Area styles */
.puzzle-info-container {
  margin-top: 16px;
  border-top: 1px solid var(--panel-border);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
}

.puzzle-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.puzzle-title-text {
  font-weight: 800;
  color: var(--nexus-color);
  font-size: 1.15rem;
}

.puzzle-moves-badge {
  padding: 4px 12px;
  border-radius: 8px;
  background: var(--panel-bg);
  border: 1px solid var(--nexus-color);
  color: var(--nexus-color);
  font-weight: bold;
  font-size: 0.85rem;
  box-shadow: 0 0 10px var(--nexus-glow);
  pointer-events: none;
  white-space: nowrap;
}

.puzzle-desc-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 4px 0 8px 0;
}

/* ==========================================================================
   AI形勢判断メーター (AI Evaluation Meter) Styles
   ========================================================================== */
.eval-meter-container {
  width: 100%;
  max-width: 1100px;
  margin: 10px auto 25px auto;
  padding: 16px;
  background: var(--panel-bg);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.3s ease;
}

.eval-meter-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-family: 'Outfit', sans-serif;
}

.eval-meter-bar-wrapper {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}

.eval-meter-bar {
  width: 100%;
  height: 100%;
  background: linear-gradient(to right, var(--p1-color) 0%, var(--p1-color) 50%, var(--p2-color) 50%, var(--p2-color) 100%);
  transition: background 0.8s cubic-bezier(0.25, 0.8, 0.25, 1);
  border-radius: 4px;
}

/* ==========================================================================
   対局リプレイコントロールバー (Replay Control Bar) Styles
   ========================================================================== */
.replay-control-bar {
  position: fixed;
  bottom: 25px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(18, 18, 24, 0.9);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(0, 199, 252, 0.3);
  box-shadow: 0 10px 40px rgba(0, 199, 252, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  border-radius: 30px;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  z-index: 150;
  animation: slideUpReplay 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  pointer-events: auto;
}

@keyframes slideUpReplay {
  from { transform: translate(-50%, 100px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

.replay-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: 'Outfit', sans-serif;
  min-width: 100px;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  padding-right: 16px;
}

.replay-status-text {
  font-size: 0.75rem;
  color: var(--nexus-color);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  animation: pulseText 1.5s infinite alternate;
}

.replay-step-counter {
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
}

.replay-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-replay {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.btn-replay svg {
  width: 18px;
  height: 18px;
}

.btn-replay:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--nexus-color);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

.btn-replay:active {
  transform: translateY(0);
}

.btn-replay.highlight {
  background: var(--nexus-color);
  color: #000;
  border: none;
}

.btn-replay.highlight:hover {
  background: #fff;
  color: #000;
  box-shadow: 0 0 15px var(--nexus-glow);
}

.btn-replay.danger {
  color: #ff3b30;
  border-color: rgba(255, 59, 48, 0.2);
}

.btn-replay.danger:hover {
  background: rgba(255, 59, 48, 0.15);
  color: #ff3b30;
  border-color: rgba(255, 59, 48, 0.4);
}

/* ==========================================================================
   デイリーパズル過去リスト (Daily Puzzle List) Styles
   ========================================================================== */
.daily-slot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid rgba(255, 255, 255, 0.04);
  transition: all 0.2s ease;
  cursor: pointer;
  width: 100%;
}

.daily-slot:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.daily-slot-left {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
}

.daily-date-badge {
  font-size: 0.95rem;
  color: #fff;
}

.daily-today-badge {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(76, 175, 80, 0.15);
  border: 1px solid rgba(76, 175, 80, 0.3);
  color: #81c784;
  font-weight: 700;
  text-transform: uppercase;
}

.daily-slot-right {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.daily-status-cleared {
  color: #81c784;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
}

.daily-status-cleared svg {
  width: 14px;
  height: 14px;
  fill: #81c784;
}

.daily-status-uncleared {
  color: var(--text-muted);
}

/* モバイル対応の調整 */
@media (max-width: 900px) {
  .eval-meter-container {
    margin: 5px auto 15px auto;
    padding: 12px;
  }
  .replay-control-bar {
    width: 92%;
    padding: 10px 16px;
    gap: 12px;
    bottom: 15px;
  }
  .replay-info {
    min-width: 80px;
    padding-right: 10px;
  }
  .replay-step-counter {
    font-size: 0.85rem;
  }
  .btn-replay {
    width: 32px;
    height: 32px;
  }
  .btn-replay svg {
    width: 15px;
    height: 15px;
  }
}

.disabled-during-replay {
  pointer-events: none !important;
  opacity: 0.3 !important;
  cursor: not-allowed !important;
  filter: grayscale(0.8) !important;
  transition: all 0.3s ease !important;
}

