/* web/style.css - 樣式表 */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #333;
  min-height: 100vh;
  overflow-x: hidden;
}

/* 畫面切換 */
.screen {
  display: block;
  min-height: 100vh;
}

.screen.hidden {
  display: none;
}

/* 容器 */
.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px 20px 80px;
  position: relative;
  min-height: 100vh;
}

/* 標題 */
.title {
  text-align: center;
  color: #fff;
  font-size: 2.2em;
  margin: 40px 0 10px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
  font-weight: 700;
  line-height: 1.3;
}

.subtitle {
  font-size: 0.6em;
  font-weight: 500;
  opacity: 0.95;
  display: inline-block;
  margin-top: 5px;
}

/* 卡片 */
.card {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#name-card {
  background: rgba(255, 255, 255, 0.95);
  padding: 20px 24px;
  margin-bottom: 16px;
}

#join-card {
  border: 3px solid #667eea;
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
}

#create-card {
  background: rgba(255, 255, 255, 0.95);
}

.create-room-header {
  text-align: center;
  margin-bottom: 16px;
}

.host-label {
  display: inline-block;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 0.9em;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

/* 分隔線 */
.divider {
  text-align: center;
  color: #fff;
  margin: 20px 0;
  font-size: 1.2em;
  font-weight: 600;
}

/* 輸入框 */
input[type="text"] {
  width: 100%;
  padding: 14px;
  margin-bottom: 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 16px;
  transition: border-color 0.3s;
}

input[type="text"]:focus {
  outline: none;
  border-color: #667eea;
}

#name-card input[type="text"] {
  margin-bottom: 0;
}

#join-card input[type="text"] {
  margin-bottom: 12px;
}

/* 主題選擇器 */
.theme-selector {
  margin: 16px 0;
}

.theme-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #666;
  margin-bottom: 8px;
}

.theme-select {
  width: 100%;
  padding: 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 15px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.3s;
}

.theme-select:focus {
  outline: none;
  border-color: #667eea;
}

/* 按鈕 */
.btn {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
}

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

.btn-large {
  padding: 18px;
  font-size: 18px;
  font-weight: 700;
}

.btn-primary {
  background: #667eea;
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: #5568d3;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.5);
}

.btn-secondary {
  background: #999;
  color: #fff;
  font-size: 14px;
  padding: 12px;
}

.btn-secondary:hover:not(:disabled) {
  background: #777;
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.btn-start {
  background: #51cf66;
  color: #fff;
  font-size: 1.3em;
  padding: 18px;
  margin-top: 20px;
}

.btn-start:hover:not(:disabled) {
  background: #40c057;
  transform: scale(1.02);
}

.btn-danger {
  background: #ff6b6b;
  color: #fff;
  margin-top: 20px;
}

.btn-danger:hover {
  background: #fa5252;
}

.btn-small {
  width: auto;
  padding: 8px 16px;
  font-size: 14px;
}

.btn-leave {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
}

/* Host 視圖（等待畫面） */
.room-info {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.room-info h2 {
  color: #666;
  font-size: 1em;
  margin-bottom: 10px;
}

.room-code {
  font-size: 3em;
  font-weight: 800;
  color: #667eea;
  letter-spacing: 8px;
  margin: 10px 0 20px;
}

.share-url {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.share-url input {
  flex: 1;
  margin: 0;
  font-size: 14px;
}

.qrcode-container {
  margin-top: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
}

#qrcode {
  display: inline-block;
  padding: 10px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#qrcode img {
  display: block;
  margin: 0 auto;
}

/* 玩家列表 */
.players-section {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.players-section h3 {
  margin-bottom: 16px;
  color: #333;
}

.players-list {
  max-height: 300px;
  overflow-y: auto;
}

.player-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 6px;
  background: #f8f9fa;
  border-radius: 6px;
  cursor: move;
  transition: all 0.2s;
  user-select: none;
}

.player-item:hover {
  background: #e9ecef;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.player-item.dragging {
  opacity: 0.5;
  cursor: grabbing;
}

.player-item.drag-over {
  border-top: 3px solid #667eea;
}

.player-item .player-seat {
  font-weight: 600;
  color: #667eea;
  min-width: 28px;
  font-size: 0.95em;
}

.player-item .player-name {
  flex: 1;
  font-weight: 500;
  font-size: 1em;
}

.offline {
  color: #999;
  font-size: 0.9em;
}

/* 控制區 */
.control-section {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.round-status {
  text-align: center;
  margin-top: 16px;
  font-size: 1.2em;
  color: #666;
  min-height: 30px;
}

/* Player 視圖 */
.player-container {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.player-display {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #000;
  color: #fff;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

/* 主題樣式 */

/* 經典黑白 */
.player-display.theme-classic {
  background: #000;
  color: #fff;
}

.player-display.theme-classic.highlight {
  background: #fff;
  color: #000;
}

/* 彩色漸層波浪 */
.player-display.theme-gradient {
  background: #1a1a2e;
  color: #fff;
}

.player-display.theme-gradient.highlight {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 25%, #f093fb 50%, #4facfe 75%, #00f2fe 100%);
  background-size: 400% 400%;
  animation: gradientWave 2s ease infinite;
  color: #fff;
  box-shadow: inset 0 0 100px rgba(255, 255, 255, 0.3);
}

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

/* 彩虹輪轉 */
.player-display.theme-rainbow {
  background: #1a1a2e;
  color: #fff;
}

.player-display.theme-rainbow.highlight {
  /* 根據座號動態設定顏色，在 JS 中處理 */
  color: #fff;
  text-shadow: 0 0 20px currentColor;
  box-shadow: inset 0 0 100px currentColor;
}

/* 脈衝光暈 */
.player-display.theme-pulse {
  background: #0a0a0a;
  color: #0ff;
}

.player-display.theme-pulse.highlight {
  background: radial-gradient(circle, #0ff 0%, #0a0a0a 70%);
  animation: pulseGlow 0.6s ease-in-out infinite;
  box-shadow: 0 0 50px #0ff, inset 0 0 50px #0ff;
}

.player-display.theme-pulse.highlight::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 200%;
  height: 200%;
  border: 3px solid #0ff;
  border-radius: 50%;
  animation: pulseRing 1s ease-out infinite;
}

@keyframes pulseGlow {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.5); }
}

@keyframes pulseRing {
  0% {
    width: 0%;
    height: 0%;
    opacity: 1;
  }
  100% {
    width: 200%;
    height: 200%;
    opacity: 0;
  }
}

/* 黑金奢華 */
.player-display.theme-gold {
  background: #000;
  color: #d4af37;
}

.player-display.theme-gold.highlight {
  background: linear-gradient(135deg, #000 0%, #d4af37 50%, #ffd700 100%);
  background-size: 200% 200%;
  animation: goldShine 1.5s ease infinite;
  color: #000;
  text-shadow: 0 0 10px #ffd700, 0 0 20px #ffd700;
  box-shadow: inset 0 0 80px rgba(255, 215, 0, 0.5);
}

.player-display.theme-gold.highlight::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(45deg, transparent 30%, rgba(255, 215, 0, 0.3) 50%, transparent 70%);
  animation: goldSweep 2s ease infinite;
}

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

@keyframes goldSweep {
  0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
  100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

.player-display .player-seat {
  font-size: 6em;
  font-weight: 800;
  margin-bottom: 20px;
  opacity: 0.5;
}

.player-display .player-name {
  font-size: 2.5em;
  font-weight: 600;
  margin-bottom: 40px;
}

.player-display .player-status {
  font-size: 1.5em;
  color: #999;
  margin-top: 20px;
}

/* 中獎顯示 */
.winner-display {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 20%, #f093fb 40%, #ff6b6b 60%, #feca57 80%, #48dbfb 100%);
  background-size: 400% 400%;
  animation: winnerGradient 3s ease infinite;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 40px;
  z-index: 1000;
  box-shadow: inset 0 0 100px rgba(255, 255, 255, 0.3);
}

.winner-display.hidden {
  display: none;
}

.winner-text {
  font-size: min(15vw, 8em);
  font-weight: 900;
  color: #fff;
  text-shadow:
    0 0 20px rgba(255, 107, 107, 0.8),
    0 0 40px rgba(255, 107, 107, 0.6),
    4px 4px 8px rgba(0, 0, 0, 0.5);
  animation: pulse 1s ease-in-out infinite;
  padding: 0 20px;
  text-align: center;
  word-break: break-word;
}

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

.btn-next-round {
  background: #51cf66;
  color: #fff;
  font-size: 1.5em;
  padding: 20px 40px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;
  transition: all 0.3s;
  animation: fadeInUp 0.5s ease 1s both;
}

.btn-next-round:hover {
  background: #40c057;
  transform: scale(1.05);
}

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

/* 移除舊的閃爍動畫，改用漸層動畫 */

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

/* 底部版權 */
.footer {
  text-align: center;
  margin-top: 40px;
  padding: 20px 0;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.9em;
}

.footer p {
  margin-bottom: 8px;
}

.footer a {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  transition: color 0.3s;
}

.footer a:hover {
  color: #fff;
  text-decoration: underline;
}

/* 響應式 */
@media (max-width: 480px) {
  .title {
    font-size: 2em;
  }

  .room-code {
    font-size: 2.5em;
    letter-spacing: 4px;
  }

  .player-display .player-seat {
    font-size: 4em;
  }

  .player-display .player-name {
    font-size: 2em;
  }

  .player-display .player-status {
    font-size: 1.2em;
  }

  .winner-text {
    font-size: 5em;
  }
}

/* 語言切換器 */
.language-switcher {
  position: absolute;
  top: 20px;
  right: 20px;
  display: flex;
  gap: 8px;
  z-index: 10;
}

.lang-btn {
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  color: #fff;
  font-size: 0.9em;
  cursor: pointer;
  transition: all 0.2s;
  backdrop-filter: blur(10px);
}

.lang-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.lang-btn.active {
  background: rgba(255, 255, 255, 0.4);
  border-color: rgba(255, 255, 255, 0.5);
  font-weight: 600;
}

/* 介紹區塊 */
.intro-section {
  margin: 30px 0 20px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  backdrop-filter: blur(10px);
  color: #fff;
}

.intro-title {
  font-size: 1.3em;
  font-weight: 600;
  margin-bottom: 12px;
  text-align: center;
  color: #fff;
}

.intro-description {
  font-size: 0.95em;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.95);
  text-align: left;
}