:root {
  --primary: #0284c7;
  --primary-glow: rgba(56, 189, 248, 0.4);
  --accent: #f59e0b;
  --accent-red: #ef4444;
  --accent-green: #10b981;
  --bg-dark: #090d16;
  --bg-card: #111827;
  --bg-card-hover: #1e293b;
  --border: #1f293d;
  --text-main: #f3f4f6;
  --text-muted: #94a3b8;
}

html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  position: relative;
  -webkit-text-size-adjust: 100%;
}

* {
  box-sizing: border-box;
}

/* 確保任何文字、網址、單詞自動折行，避免字串過長超出手機螢幕 */
p, span, h1, h2, h3, h4, h5, h6, a, div, td, th, label, input, button, select {
  word-break: break-word;
  overflow-wrap: anywhere;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, 'Microsoft JhengHei', sans-serif;
  min-height: 100vh;
}

/* 陀螺金屬科技漸層字體 */
.cyber-title {
  background: linear-gradient(135deg, #ffffff 0%, #38bdf8 50%, #818cf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 20px var(--primary-glow);
}

.gold-glow {
  text-shadow: 0 0 25px rgba(245, 158, 11, 0.6);
}

.card-glow {
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

/* 1-64 號籤位格子 */
.draw-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 8px;
}

@media (max-width: 640px) {
  .draw-grid {
    grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
    gap: 5px;
  }
}

.grid-cell {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  transition: all 0.25s ease;
  user-select: none;
}

.grid-cell.available {
  background-color: rgba(30, 41, 59, 0.5);
  border: 1px solid #334155;
  color: #64748b;
}

.grid-cell.available:hover {
  background-color: #1e293b;
  border-color: #38bdf8;
  color: #94a3b8;
}

.grid-cell.drawn {
  background: linear-gradient(135deg, #0369a1 0%, #0284c7 100%);
  border: 1px solid #38bdf8;
  color: #ffffff;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.4);
}

.grid-cell .cell-num {
  font-size: 16px;
  line-height: 1;
}

.grid-cell .cell-name {
  font-size: 10px;
  margin-top: 2px;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .grid-cell .cell-num {
    font-size: 13px;
  }
  .grid-cell .cell-name {
    font-size: 8px;
    max-width: 95%;
  }
}

/* 抽籤拉霸動態效果 */
@keyframes numberRoll {
  0% { transform: scale(0.7); opacity: 0; filter: blur(4px); }
  60% { transform: scale(1.15); opacity: 1; filter: blur(0); }
  100% { transform: scale(1); opacity: 1; }
}

.roll-animation {
  animation: numberRoll 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* 掃描器相機視窗裝飾 */
.scanner-viewport {
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  background-color: #000000;
  border: 2px solid #38bdf8;
  box-shadow: 0 0 25px rgba(56, 189, 248, 0.3);
}

.scan-laser {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, #38bdf8, #ffffff, #38bdf8, transparent);
  box-shadow: 0 0 15px #38bdf8;
  animation: laserScan 2s ease-in-out infinite;
  z-index: 10;
  pointer-events: none;
}

@keyframes laserScan {
  0% { top: 5%; opacity: 0.8; }
  50% { top: 92%; opacity: 1; }
  100% { top: 5%; opacity: 0.8; }
}

/* 號碼牌巨大徽章 */
.number-badge-giant {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0284c7 0%, #2563eb 50%, #4f46e5 100%);
  border: 3px solid #38bdf8;
  border-radius: 20px;
  color: #ffffff;
  box-shadow: 0 0 35px rgba(56, 189, 248, 0.6);
}

/* 手機相機掃描元件（html5-qrcode）防爆版 */
#reader {
  width: 100% !important;
  max-width: 100% !important;
  overflow: hidden !important;
  border-radius: 16px;
}

#reader video, #reader canvas, #reader img {
  width: 100% !important;
  max-width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}

/* 隱藏滾動條但保留滑動行為 */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}
