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

body {
  font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  min-height: 100vh;
  overflow: hidden;
}

#app {
  width: 100vw;
  height: 100vh;
}

.screen {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hidden {
  display: none !important;
}

/* 配置界面 */
.setup-box {
  background: #16213e;
  border-radius: 16px;
  padding: 40px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  text-align: center;
  min-width: 480px;
  border: 1px solid #0f3460;
}

.setup-box h1 {
  font-size: 42px;
  color: #e94560;
  margin-bottom: 8px;
  letter-spacing: 8px;
}

.subtitle {
  color: #8892b0;
  margin-bottom: 32px;
  font-size: 14px;
}

.setup-form {
  text-align: left;
}

.form-group {
  margin-bottom: 24px;
}

.form-group label {
  display: block;
  font-size: 14px;
  color: #a8b2d1;
  margin-bottom: 10px;
}

.player-count-selector {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.count-btn {
  flex: 1;
  min-width: 50px;
  padding: 10px;
  border: 2px solid #0f3460;
  background: transparent;
  color: #a8b2d1;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  transition: all 0.2s;
}

.count-btn:hover {
  border-color: #e94560;
  color: #e94560;
}

.count-btn.active {
  background: #e94560;
  border-color: #e94560;
  color: white;
}

#player-names-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.name-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.name-input-row .color-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
}

.name-input-row input {
  flex: 1;
  padding: 8px 12px;
  background: #0f1626;
  border: 1px solid #0f3460;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 14px;
  outline: none;
}

.name-input-row input:focus {
  border-color: #e94560;
}

.primary-btn {
  width: 100%;
  padding: 14px;
  background: #e94560;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
}

.primary-btn:hover {
  background: #ff5773;
  transform: translateY(-1px);
}

.link-btn {
  background: none;
  border: none;
  color: #8892b0;
  cursor: pointer;
  font-size: 14px;
  text-decoration: underline;
}

.link-btn:hover {
  color: #e94560;
}

.ai-select {
  width: 100%;
  padding: 10px 14px;
  background: #0f1626;
  border: 1px solid #0f3460;
  border-radius: 8px;
  color: #e0e0e0;
  font-size: 14px;
  cursor: pointer;
  outline: none;
}

.ai-select:focus {
  border-color: #e94560;
}

.rules-box {
  background: #16213e;
  border-radius: 16px;
  padding: 30px 40px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  border: 1px solid #0f3460;
}

.rules-box h2 {
  color: #e94560;
  margin-bottom: 20px;
  text-align: center;
  font-size: 28px;
}

.rules-content h4 {
  color: #ffc107;
  margin: 16px 0 8px;
  font-size: 16px;
}

.rules-content p {
  color: #a8b2d1;
  font-size: 14px;
  line-height: 1.7;
  margin-bottom: 4px;
}

.rules-content b {
  color: #e0e0e0;
}

.rules-box .primary-btn {
  margin-top: 20px;
}

/* 回合切换遮罩 */
#turn-mask {
  background: rgba(0,0,0,0.95);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
}

/* 规则弹窗 */
#rules-modal {
  background: rgba(0,0,0,0.85);
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 200;
  backdrop-filter: blur(4px);
}

.turn-mask-content {
  text-align: center;
}

.turn-mask-content p {
  font-size: 28px;
  color: #a8b2d1;
  margin-bottom: 30px;
}

.turn-mask-content button {
  padding: 16px 48px;
  background: #e94560;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
}

.turn-mask-content button:hover {
  background: #ff5773;
}

/* 游戏界面 */
#game-screen {
  flex-direction: column;
  padding: 10px;
  gap: 8px;
}

.game-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: #16213e;
  border-radius: 10px;
  border: 1px solid #0f3460;
}

.turn-info {
  display: flex;
  gap: 20px;
  align-items: center;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid #0f3460;
  background: #0f1626;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: #1a2744;
  transform: scale(1.05);
}

#current-player-label {
  font-size: 20px;
  font-weight: bold;
  color: #e94560;
}

#turn-phase {
  padding: 4px 12px;
  background: #0f3460;
  border-radius: 20px;
  font-size: 13px;
  color: #8892b0;
}

#actions-left {
  font-size: 14px;
  color: #a8b2d1;
}

.player-status {
  display: flex;
  gap: 12px;
}

.player-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  background: #0f1626;
}

.player-chip .color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.player-chip.dead {
  opacity: 0.3;
  text-decoration: line-through;
}

.game-main {
  display: flex;
  gap: 12px;
  flex: 1;
  min-height: 0;
  width: 100%;
}

.board-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #16213e;
  border-radius: 10px;
  border: 1px solid #0f3460;
  padding: 16px;
}

#board {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  max-width: 600px;
  max-height: 600px;
  aspect-ratio: 1;
}

.board-col-labels {
  display: grid;
  grid-template-columns: 30px repeat(10, 1fr);
  gap: 2px;
  margin-bottom: 2px;
  flex-shrink: 0;
}

.board-row {
  display: grid;
  grid-template-columns: 30px repeat(10, 1fr);
  gap: 2px;
  flex: 1;
  min-height: 0;
}

.board-grid {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 2px;
  min-height: 0;
}

.board-grid .board-row {
  display: grid;
  grid-template-columns: 30px repeat(10, 1fr);
  gap: 2px;
  flex: 1;
  min-height: 0;
}

.col-label, .row-label {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #5a6a8a;
  font-weight: bold;
  flex-shrink: 0;
}

.board-col-labels .col-label {
  height: 24px;
}

.board-row .row-label {
  width: 30px;
  min-width: 30px;
}

.cell {
  background: linear-gradient(135deg, #254a38 0%, #2d5a45 50%, #254a38 100%);
  border-radius: 6px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(255,255,255,0.05), inset 0 -1px 2px rgba(0,0,0,0.2);
}

.cell::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: 
    radial-gradient(ellipse 3px 5px at 15% 25%, #4a8a6e 0%, transparent 70%),
    radial-gradient(ellipse 2px 4px at 45% 40%, #3d7558 0%, transparent 70%),
    radial-gradient(ellipse 3px 6px at 75% 20%, #48856a 0%, transparent 70%),
    radial-gradient(ellipse 2px 5px at 25% 70%, #3f785c 0%, transparent 70%),
    radial-gradient(ellipse 4px 5px at 65% 75%, #468368 0%, transparent 70%),
    radial-gradient(ellipse 2px 4px at 88% 55%, #3c7256 0%, transparent 70%),
    radial-gradient(ellipse 3px 5px at 55% 15%, #4a8a6e 0%, transparent 70%);
  opacity: 0.7;
  transition: opacity 0.2s;
}

.cell::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.04) 0%, transparent 40%, transparent 60%, rgba(0,0,0,0.06) 100%);
  pointer-events: none;
}

.cell:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0,0,0,0.3), inset 0 1px 2px rgba(255,255,255,0.08);
}

.cell:hover::before {
  opacity: 0.85;
}

.cell.grass-moved {
  animation: grassShake 0.6s ease-in-out;
}

.cell.grass-moved::before {
  animation: grassSway 0.6s ease-in-out;
}

@keyframes grassShake {
  0%, 100% { box-shadow: inset 0 1px 2px rgba(255,255,255,0.05); }
  30% { box-shadow: 0 0 12px rgba(255, 220, 100, 0.4), inset 0 0 8px rgba(255, 220, 100, 0.2); }
  60% { box-shadow: 0 0 6px rgba(255, 220, 100, 0.2); }
}

@keyframes grassSway {
  0%, 100% { transform: translateX(0); opacity: 0.7; }
  25% { transform: translateX(-2px); opacity: 0.9; }
  75% { transform: translateX(2px); opacity: 0.9; }
}

.cell.highlight-move {
  background: linear-gradient(135deg, #2a6b52 0%, #388a6b 50%, #2a6b52 100%);
  box-shadow: inset 0 0 0 2px rgba(100, 220, 160, 0.5), 0 0 10px rgba(100, 220, 160, 0.2);
  animation: movePulse 1.5s ease-in-out infinite;
}

.cell.highlight-attack {
  background: linear-gradient(135deg, #7a3232 0%, #a04040 50%, #7a3232 100%);
  box-shadow: inset 0 0 0 2px rgba(255, 100, 100, 0.6), 0 0 10px rgba(255, 100, 100, 0.25);
  animation: attackPulse 1s ease-in-out infinite;
}

@keyframes movePulse {
  0%, 100% { box-shadow: inset 0 0 0 2px rgba(100, 220, 160, 0.4), 0 0 8px rgba(100, 220, 160, 0.15); }
  50% { box-shadow: inset 0 0 0 2px rgba(100, 220, 160, 0.7), 0 0 14px rgba(100, 220, 160, 0.3); }
}

@keyframes attackPulse {
  0%, 100% { box-shadow: inset 0 0 0 2px rgba(255, 100, 100, 0.5), 0 0 8px rgba(255, 100, 100, 0.2); }
  50% { box-shadow: inset 0 0 0 2px rgba(255, 100, 100, 0.8), 0 0 16px rgba(255, 100, 100, 0.4); }
}

.cell.player-cell::before {
  opacity: 0.3;
}

.player-marker {
  width: 65%;
  height: 65%;
  border-radius: 50%;
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 14px;
  color: white;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.6);
  box-shadow: 0 3px 8px rgba(0,0,0,0.4), inset 0 2px 4px rgba(255,255,255,0.3), inset 0 -2px 4px rgba(0,0,0,0.2);
  animation: playerBreathe 3s ease-in-out infinite;
}

@keyframes playerBreathe {
  0%, 100% { box-shadow: 0 3px 8px rgba(0,0,0,0.4), inset 0 2px 4px rgba(255,255,255,0.3), inset 0 -2px 4px rgba(0,0,0,0.2); }
  50% { box-shadow: 0 5px 12px rgba(0,0,0,0.5), inset 0 2px 4px rgba(255,255,255,0.4), inset 0 -2px 4px rgba(0,0,0,0.2); }
}

.player-marker .arrow {
  position: absolute;
  top: -10px;
  left: 50%;
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 12px solid rgba(255,255,255,0.95);
  transform-origin: center 20px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
}

.facing-n .arrow { transform: translateX(-50%) rotate(0deg); }
.facing-e .arrow { transform: translateX(-50%) rotate(90deg); }
.facing-s .arrow { transform: translateX(-50%) rotate(180deg); }
.facing-w .arrow { transform: translateX(-50%) rotate(270deg); }

.side-panel {
  width: 280px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel-section {
  background: #16213e;
  border-radius: 10px;
  border: 1px solid #0f3460;
  padding: 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-section h3 {
  font-size: 14px;
  color: #a8b2d1;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #0f3460;
}

.log {
  flex: 1;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.6;
}

.log-entry {
  padding: 4px 8px;
  margin-bottom: 4px;
  border-radius: 4px;
  background: #0f1626;
}

.log-entry.sound {
  border-left: 3px solid #ffc107;
}

.log-entry.vision {
  border-left: 3px solid #4caf50;
}

.log-entry.action {
  border-left: 3px solid #2196f3;
}

.log-entry.system {
  border-left: 3px solid #e94560;
}

.log::-webkit-scrollbar {
  width: 5px;
}

.log::-webkit-scrollbar-track {
  background: #0f1626;
}

.log::-webkit-scrollbar-thumb {
  background: #0f3460;
  border-radius: 3px;
}

.shortcuts-section {
  flex: none;
}

.shortcuts-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  font-size: 12px;
}

.shortcut-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #8892b0;
}

.shortcut-item kbd {
  display: inline-block;
  padding: 2px 6px;
  background: #0f1626;
  border: 1px solid #0f3460;
  border-radius: 4px;
  font-family: monospace;
  font-size: 11px;
  color: #a8b2d1;
  min-width: 20px;
  text-align: center;
}

.action-bar {
  width: 100%;
  background: #16213e;
  border-radius: 10px;
  border: 1px solid #0f3460;
  padding: 12px 20px;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  min-height: 70px;
}

.action-btn {
  padding: 12px 24px;
  border: 2px solid #0f3460;
  background: #0f1626;
  color: #a8b2d1;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  transition: all 0.2s;
  min-width: 100px;
}

.action-btn:hover:not(:disabled) {
  border-color: #e94560;
  color: #e94560;
  transform: translateY(-1px);
}

.action-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.action-btn.primary {
  background: #e94560;
  border-color: #e94560;
  color: white;
}

.action-btn.primary:hover:not(:disabled) {
  background: #ff5773;
  color: white;
}

.direction-pad {
  display: grid;
  grid-template-columns: repeat(3, 50px);
  grid-template-rows: repeat(3, 50px);
  gap: 4px;
}

.direction-pad button {
  border: 2px solid #0f3460;
  background: #0f1626;
  color: #a8b2d1;
  border-radius: 6px;
  cursor: pointer;
  font-size: 18px;
  transition: all 0.15s;
}

.direction-pad button:hover {
  border-color: #e94560;
  color: #e94560;
}

.direction-pad button.active {
  background: #e94560;
  border-color: #e94560;
  color: white;
}

.direction-pad .dir-up { grid-column: 2; grid-row: 1; }
.direction-pad .dir-left { grid-column: 1; grid-row: 2; }
.direction-pad .dir-right { grid-column: 3; grid-row: 2; }
.direction-pad .dir-down { grid-column: 2; grid-row: 3; }
.direction-pad .dir-center { grid-column: 2; grid-row: 2; background: #0f3460; cursor: default; color: #5a6a8a; }

.action-hint {
  font-size: 13px;
  color: #8892b0;
  text-align: center;
  flex: 1;
}

/* 游戏结束 */
.end-box {
  background: #16213e;
  border-radius: 16px;
  padding: 50px 60px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  text-align: center;
  border: 1px solid #0f3460;
}

.end-box h1 {
  font-size: 48px;
  color: #e94560;
  margin-bottom: 16px;
}

#winner-text {
  font-size: 24px;
  color: #a8b2d1;
  margin-bottom: 32px;
}

#winner-text .winner-name {
  color: #ffc107;
  font-weight: bold;
}

@media (max-width: 900px) {
  .game-main {
    flex-direction: column;
  }
  .side-panel {
    width: 100%;
    flex-direction: row;
    max-height: 150px;
  }
  .panel-section {
    flex: 1;
  }
  .shortcuts-section {
    display: none;
  }
}

@media (max-width: 600px) {
  .setup-box {
    min-width: auto;
    width: 90vw;
    padding: 24px;
  }
  
  .setup-box h1 {
    font-size: 28px;
    letter-spacing: 4px;
  }
  
  .game-header {
    flex-direction: column;
    gap: 8px;
    padding: 8px 12px;
  }
  
  .header-right {
    width: 100%;
    justify-content: space-between;
  }
  
  .turn-info {
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
  }
  
  .player-status {
    justify-content: center;
    flex-wrap: wrap;
  }
  
  .action-bar {
    flex-wrap: wrap;
    padding: 10px;
    gap: 8px;
  }
  
  .action-btn {
    min-width: 70px;
    padding: 10px 14px;
    font-size: 12px;
  }
  
  .action-btn small {
    font-size: 10px;
  }
  
  .direction-pad {
    grid-template-columns: repeat(3, 44px);
    grid-template-rows: repeat(3, 44px);
  }
  
  .board-container {
    padding: 8px;
  }
  
  #board {
    max-width: 100%;
    max-height: 100%;
  }
  
  .col-label, .row-label {
    font-size: 10px;
  }
  
  .end-box {
    padding: 32px 40px;
  }
  
  .end-box h1 {
    font-size: 32px;
  }
  
  .rules-box {
    max-width: 90vw;
    max-height: 85vh;
    padding: 20px 24px;
  }
}

@media (hover: none) and (pointer: coarse) {
  .action-btn:hover:not(:disabled) {
    transform: none;
  }
  
  .count-btn:hover {
    transform: none;
  }
  
  .cell:active {
    transform: scale(0.95);
  }
}
