/* Card Mentalism - FunApp */
/* 原作者: Matt Cannon (https://codepen.io/matt-cannon/pen/gbOJbpZ) */

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

body {
  font-family: "Unica One", sans-serif;
  background-color: #000d1a;
  color: #fff;
  text-align: center;
  padding: 2em;
  padding-top: 60px;
  margin: 0;
  overflow-x: hidden;
  min-height: 100vh;
}

/* 煙霧背景 */
#smoke-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -3;
  pointer-events: none;
  opacity: 0.25;
  animation: videoFadeInOut 10s ease-in-out infinite;
}

@keyframes videoFadeInOut {
  0%, 100% { opacity: 0.25; }
  40% { opacity: 0.05; }
  60% { opacity: 0.05; }
}

/* 設定按鈕 */
.settings-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  padding: 0;
  margin: 0;
}

.settings-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: rotate(90deg);
}

/* 設定選單 */
.settings-menu {
  position: fixed;
  top: 70px;
  right: 16px;
  z-index: 9998;
  background: rgba(0, 13, 26, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 16px;
  min-width: 200px;
}

.settings-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
}

.settings-item label {
  color: #fff;
  font-size: 14px;
}

.settings-item select {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: #fff;
  padding: 6px 10px;
  font-size: 16px;
  cursor: pointer;
}

.settings-item.version {
  justify-content: center;
  opacity: 0.5;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: 8px;
  padding-top: 12px;
}

/* 版本號 */
#version-info {
  position: fixed;
  bottom: 8px;
  right: 8px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.4);
  z-index: 9999;
  pointer-events: none;
}

/* 標題 */
h2 {
  font-size: 2rem;
  font-weight: 600;
  margin-bottom: 1rem;
  text-shadow: 0 0 15px #00f2ff, 0 0 25px #005eff;
  letter-spacing: 2px;
}

/* 卡牌容器 */
.card-container {
  position: relative;
  width: 100%;
  max-width: 1000px;
  margin: 2rem auto 3rem auto;
  height: 180px;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  pointer-events: none;
}

.card-container img {
  position: absolute;
  bottom: 0;
  width: 90px;
  transform-origin: bottom center;
  border-radius: 8px;
  transform: scale(1.15) rotate(0deg);
  box-shadow: 0 0 25px rgba(0, 200, 255, 0.4);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  pointer-events: auto;
  left: 50%;
  z-index: 1;
}

.card-container img:hover {
  transform: scale(1.25) rotate(0deg) translateY(-10px);
  box-shadow: 0 0 40px rgba(0, 255, 255, 0.7);
  z-index: 100;
}

#card-pick {
  margin-top: 5px;
}

#card-group {
  margin-top: -15px;
}

/* 揭曉區域 */
.final-reveal {
  justify-content: center;
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  position: relative;
  height: 300px;
  width: 100%;
  overflow: hidden;
}

.final-reveal img {
  position: absolute;
  width: 150px;
  animation: smoothReveal 0.8s ease-out forwards,
    floatGlow 1.5s ease-in-out infinite alternate,
    floatUp 5s ease-in-out infinite;
  opacity: 0;
  transform: scale(0.6) translateY(60px);
  left: calc(50% - 75px);
  transform-origin: center center;
  margin: 0;
  box-shadow: 0 0 25px rgba(0, 195, 255, 0.4);
  border-radius: 8px;
}

.final-reveal img.main-card {
  animation: smoothReveal 0.8s ease-out forwards,
    floatGlow 1.5s ease-in-out infinite alternate;
  z-index: 10;
}

@keyframes smoothReveal {
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes floatGlow {
  0% {
    transform: scale(1) translateY(0);
    box-shadow: 0 0 15px rgba(0, 195, 255, 0.4);
  }
  100% {
    transform: scale(1.05) translateY(-10px);
    box-shadow: 0 0 35px rgba(0, 255, 255, 0.6);
  }
}

@keyframes floatUp {
  0% {
    transform: translateY(100px) rotate(0deg);
    opacity: 0;
  }
  20% {
    opacity: 0.5;
  }
  80% {
    opacity: 0.5;
  }
  100% {
    transform: translateY(-300px) rotate(10deg);
    opacity: 0;
  }
}

/* 按鈕 */
button {
  font-family: "Unica One", sans-serif;
  background: rgba(17, 17, 17, 0.8);
  color: white;
  border: 2px solid white;
  font-weight: 600;
  font-size: 1rem;
  padding: 12px 24px;
  margin-top: 1rem;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.25s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 1px;
}

button:hover {
  background: #fff;
  color: #111;
  box-shadow: 0 0 20px #00c3ff;
}

button:active {
  transform: scale(0.95);
}

#group-controls {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

#group-controls button {
  min-width: 120px;
}

/* 載入動畫 */
#loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.loader {
  width: 50px;
  height: 50px;
  border: 3px solid rgba(0, 195, 255, 0.3);
  border-top-color: #00c3ff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* 錯誤訊息 */
.error-message {
  color: #ff6b6b;
  font-size: 1.2rem;
  padding: 20px;
}

.hidden {
  display: none !important;
}

/* 手機版 */
@media (max-width: 768px) {
  body {
    padding: 1em;
    padding-top: 60px;
  }

  h2 {
    font-size: 1.4rem;
  }

  .card-container {
    height: 140px;
    margin: 1.5rem auto 2rem auto;
  }

  .card-container img {
    width: 65px;
  }

  .final-reveal {
    height: 250px;
  }

  .final-reveal img {
    width: 120px;
    left: calc(50% - 60px);
  }

  button {
    font-size: 0.9rem;
    padding: 10px 20px;
  }

  #group-controls button {
    min-width: 100px;
  }
}

@media (max-width: 480px) {
  h2 {
    font-size: 1.2rem;
  }

  .card-container {
    height: 120px;
  }

  .card-container img {
    width: 55px;
  }

  .final-reveal img {
    width: 100px;
    left: calc(50% - 50px);
  }
}
