/* ─────────────────────────────────────────────
   LunchLuck — 午休決勝局
   鮮豔漸層 / 毛玻璃 / RWD
   ───────────────────────────────────────────── */

:root {
  --pink:   #ff5fa2;
  --purple: #7b5cff;
  --orange: #ff9f43;
  --cyan:   #2ed9ff;
  --lime:   #b6ff3d;
  --ink:    #1b1340;
  --glass:  rgba(255, 255, 255, 0.14);
  --glass-strong: rgba(255, 255, 255, 0.22);
  --stroke: rgba(255, 255, 255, 0.35);
  --shadow: 0 18px 50px rgba(40, 12, 80, 0.35);
  --radius: 22px;
  --font: "Noto Sans TC", -apple-system, BlinkMacSystemFont, "Segoe UI",
          "PingFang TC", "Microsoft JhengHei", sans-serif;
}

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

html, body { height: 100%; }

body {
  font-family: var(--font);
  color: #fff;
  min-height: 100vh;
  background: linear-gradient(135deg, #7b5cff, #ff5fa2 35%, #ff9f43 70%, #2ed9ff);
  background-size: 300% 300%;
  animation: bgShift 18s ease infinite;
  -webkit-font-smoothing: antialiased;
  padding: 22px 16px 70px;
}

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

.app { max-width: 1080px; margin: 0 auto; }

/* ── 頂部 ── */
.topbar {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 22px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-emoji { font-size: 34px; filter: drop-shadow(0 4px 8px rgba(0,0,0,.25)); }
.brand-name {
  font-size: 30px; font-weight: 900; letter-spacing: -0.5px;
  text-shadow: 0 4px 14px rgba(40, 12, 80, 0.35);
}
.tagline { font-size: 14px; opacity: .9; font-weight: 600; }
.sound-toggle {
  margin-left: auto; width: 44px; height: 44px; border-radius: 14px;
  border: 1px solid var(--stroke); background: var(--glass);
  backdrop-filter: blur(10px); font-size: 20px; cursor: pointer;
  transition: transform .15s, background .2s;
}
.sound-toggle:hover { transform: scale(1.08); background: var(--glass-strong); }
.sound-toggle.muted { opacity: .5; }

/* ── 版面 ── */
.layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 22px;
  align-items: start;
}

/* ── 共用名單面板 ── */
.list-panel {
  background: var(--glass);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(16px);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  position: sticky; top: 16px;
}
.list-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.list-head h2 { font-size: 17px; font-weight: 800; }
.count-pill {
  min-width: 30px; text-align: center; padding: 3px 11px; border-radius: 999px;
  background: var(--ink); font-size: 13px; font-weight: 800;
}

.add-row { display: flex; gap: 8px; margin-bottom: 14px; }
.add-row input {
  flex: 1; min-width: 0; padding: 12px 14px; border-radius: 13px;
  border: 1px solid var(--stroke); background: rgba(255,255,255,.92);
  color: var(--ink); font-size: 15px; font-weight: 600; outline: none;
}
.add-row input::placeholder { color: #9a93b5; font-weight: 500; }
.add-row button {
  width: 46px; border: none; border-radius: 13px; cursor: pointer;
  background: var(--ink); color: #fff; font-size: 24px; font-weight: 700;
  transition: transform .12s, filter .2s;
}
.add-row button:hover { transform: translateY(-2px); filter: brightness(1.2); }

/* chips */
.chips {
  display: flex; flex-wrap: wrap; gap: 8px;
  min-height: 54px; max-height: 230px; overflow-y: auto;
  margin-bottom: 14px; padding: 4px;
}
.chips-empty { font-size: 13px; opacity: .8; padding: 14px 6px; line-height: 1.6; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 8px 7px 13px; border-radius: 999px;
  background: rgba(255,255,255,.92); color: var(--ink);
  font-size: 14px; font-weight: 700;
  animation: pop .25s ease;
}
.chip button {
  width: 20px; height: 20px; border: none; border-radius: 50%; cursor: pointer;
  background: rgba(27,19,64,.12); color: var(--ink); font-size: 13px; line-height: 1;
  display: grid; place-items: center; transition: background .15s;
}
.chip button:hover { background: var(--pink); color: #fff; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* import buttons */
.import-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.mini-btn {
  flex: 1 1 auto; padding: 10px 12px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--stroke); background: var(--glass-strong);
  color: #fff; font-size: 13px; font-weight: 700; white-space: nowrap;
  transition: transform .12s, background .2s;
}
.mini-btn:hover { transform: translateY(-2px); background: rgba(255,255,255,.32); }
.mini-btn.danger:hover { background: var(--pink); }
.mini-btn.primary { background: var(--ink); border-color: var(--ink); }
.mini-btn.primary:hover { filter: brightness(1.25); background: var(--ink); }

/* dropzone */
.dropzone {
  display: flex; align-items: center; gap: 12px;
  padding: 16px; border-radius: 16px;
  border: 2px dashed var(--stroke); background: rgba(255,255,255,.06);
  font-size: 13px; line-height: 1.5; transition: all .2s;
}
.dz-icon { font-size: 26px; }
.dropzone.drag {
  border-color: var(--lime); background: rgba(182,255,61,.18);
  transform: scale(1.02);
}

/* ── 遊戲分頁 ── */
.tabs {
  display: flex; gap: 8px; margin-bottom: 18px;
  background: var(--glass); border: 1px solid var(--stroke);
  border-radius: 16px; padding: 6px; backdrop-filter: blur(12px);
}
.tab {
  flex: 1; padding: 12px 8px; border: none; border-radius: 12px; cursor: pointer;
  background: transparent; color: #fff; font-size: 14px; font-weight: 800;
  transition: all .2s; white-space: nowrap;
}
.tab:hover { background: rgba(255,255,255,.12); }
.tab.active {
  background: #fff; color: var(--ink);
  box-shadow: 0 6px 18px rgba(0,0,0,.18);
}

/* ── 遊戲舞台 ── */
.stage {
  background: var(--glass);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(16px);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px 22px;
  min-height: 520px;
  display: flex; align-items: center; justify-content: center;
}
.game {
  width: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 22px;
}
.game.hidden { display: none; }
.game-hint { font-size: 14px; opacity: .9; font-weight: 600; text-align: center; }

/* ── 轉盤 ── */
.wheel-wrap { position: relative; width: 440px; max-width: 82vw; aspect-ratio: 1; }
#wheel-canvas {
  width: 100%; height: 100%; border-radius: 50%;
  box-shadow: 0 0 0 10px rgba(255,255,255,.9), 0 22px 50px rgba(40,12,80,.45);
  background: rgba(255,255,255,.15);
}
.wheel-pointer {
  position: absolute; top: -6px; left: 50%; transform: translateX(-50%);
  width: 0; height: 0; z-index: 4;
  border-left: 17px solid transparent; border-right: 17px solid transparent;
  border-top: 30px solid #fff;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,.35));
}
.spin-center {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 92px; height: 92px; border-radius: 50%; cursor: pointer;
  border: 6px solid #fff; background: var(--ink); color: #fff;
  font-size: 22px; font-weight: 900; z-index: 3;
  box-shadow: 0 8px 22px rgba(0,0,0,.4);
  transition: transform .15s, filter .2s;
}
.spin-center:hover:not(:disabled) { transform: translate(-50%,-50%) scale(1.08); filter: brightness(1.2); }
.spin-center:disabled { cursor: not-allowed; opacity: .7; }

/* ── 拉霸 ── */
.slot-machine {
  position: relative; padding: 22px;
  border-radius: 26px; background: linear-gradient(160deg, var(--purple), var(--pink));
  box-shadow: var(--shadow), inset 0 0 0 4px rgba(255,255,255,.25);
}
.slot-glow {
  position: absolute; inset: 0; border-radius: 26px; pointer-events: none;
  box-shadow: 0 0 40px rgba(255,255,255,.35) inset; opacity: .5;
}
.slot-window {
  position: relative; width: 300px; max-width: 70vw; height: 110px; overflow: hidden;
  border-radius: 16px; background: #fff;
  box-shadow: inset 0 8px 16px rgba(0,0,0,.2), inset 0 -8px 16px rgba(0,0,0,.2);
}
.slot-reel { will-change: transform; }
.slot-cell {
  height: 110px; display: grid; place-items: center;
  font-size: clamp(22px, 6vw, 34px); font-weight: 900; color: var(--ink);
  padding: 0 12px; text-align: center;
}
.slot-line {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,.85) 0%, transparent 28%, transparent 72%, rgba(255,255,255,.85) 100%);
}

/* ── 抽籤 / 翻牌 ── */
.card-grid {
  display: grid; gap: 14px; width: 100%;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  justify-items: center;
}
.flip-card {
  width: 100%; max-width: 120px; aspect-ratio: 3 / 4; perspective: 800px;
}
.flip-inner {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d; transition: transform .6s cubic-bezier(.5,1.6,.4,1);
}
.flip-card.flipped .flip-inner { transform: rotateY(180deg); }
.flip-face {
  position: absolute; inset: 0; backface-visibility: hidden;
  border-radius: 14px; display: grid; place-items: center;
  font-weight: 900; box-shadow: 0 8px 18px rgba(0,0,0,.25);
}
.flip-back {
  background: linear-gradient(160deg, var(--ink), #3a2a7a);
  color: #fff; font-size: 30px;
  border: 2px solid rgba(255,255,255,.3);
}
.flip-front {
  background: #fff; color: var(--ink); transform: rotateY(180deg);
  font-size: clamp(13px, 3.4vw, 17px); text-align: center; padding: 6px;
  border: 3px solid var(--lime);
}
.flip-card.scan .flip-back {
  box-shadow: 0 0 0 4px var(--lime), 0 8px 22px rgba(0,0,0,.35);
  transform: scale(1.06);
}
.flip-card { transition: transform .12s; }

/* ── 教練配對 ── */
.coach-stage { display: grid; place-items: center; min-height: 360px; width: 100%; }
.coach-card {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 26px 30px; border-radius: 26px;
  background: var(--glass-strong); border: 1px solid var(--stroke);
  box-shadow: var(--shadow); backdrop-filter: blur(12px);
  transition: transform .12s;
}
.coach-card.bump { transform: scale(1.04); }
.coach-photo {
  width: 200px; height: 200px; max-width: 56vw; max-height: 56vw;
  border-radius: 24px; overflow: hidden;
  display: grid; place-items: center;
  background: linear-gradient(160deg, var(--ink), #3a2a7a);
  box-shadow: 0 12px 30px rgba(0,0,0,.3), 0 0 0 4px rgba(255,255,255,.5);
}
.coach-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.coach-placeholder { font-size: 76px; opacity: .85; }
.coach-name {
  font-size: 26px; font-weight: 900; color: #fff;
  text-shadow: 0 4px 14px rgba(40,12,80,.4); min-height: 30px;
}
.coach-en { font-size: 15px; font-weight: 700; color: #fff; opacity: .82; min-height: 18px; }
.coach-card.winner .coach-photo { box-shadow: 0 12px 30px rgba(0,0,0,.35), 0 0 0 5px var(--lime); }

/* ── 大按鈕 ── */
.big-btn {
  padding: 16px 42px; border: none; border-radius: 16px; cursor: pointer;
  background: var(--ink); color: #fff; font-size: 19px; font-weight: 900;
  box-shadow: 0 10px 26px rgba(0,0,0,.32);
  transition: transform .15s, filter .2s;
}
.big-btn:hover:not(:disabled) { transform: translateY(-3px); filter: brightness(1.25); }
.big-btn:disabled { opacity: .6; cursor: not-allowed; }

/* ── 結果橫幅 ── */
.result-banner {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; z-index: 50;
  padding: 14px 26px; border-radius: 999px;
  background: #fff; color: var(--ink);
  box-shadow: 0 16px 44px rgba(0,0,0,.35);
  animation: rbUp .4s cubic-bezier(.5,1.5,.4,1);
}
.result-banner.hidden { display: none; }
.rb-label { font-size: 12px; font-weight: 800; opacity: .55; }
.rb-text { font-size: 22px; font-weight: 900; }
@keyframes rbUp { from { transform: translate(-50%, 30px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* ── 批次彈窗 ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(20, 8, 50, .55); backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal {
  width: min(520px, 100%); background: #fff; color: var(--ink);
  border-radius: 22px; padding: 24px; box-shadow: var(--shadow);
  animation: rbUp .3s ease;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.modal-head h3 { font-size: 20px; font-weight: 900; }
.modal-close {
  width: 34px; height: 34px; border: none; border-radius: 10px; cursor: pointer;
  background: #f0eef8; color: var(--ink); font-size: 16px; font-weight: 700;
}
.modal-close:hover { background: var(--pink); color: #fff; }
.modal-hint { font-size: 13px; color: #6c6390; line-height: 1.6; margin-bottom: 14px; }
#batch-text {
  width: 100%; height: 180px; resize: vertical; padding: 14px; border-radius: 14px;
  border: 1px solid #ddd9ec; font-size: 15px; font-family: var(--font); color: var(--ink);
  outline: none; line-height: 1.6;
}
#batch-text:focus { border-color: var(--purple); }
.modal-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; gap: 10px; }
.batch-count { font-size: 13px; font-weight: 700; color: #6c6390; }
.modal-foot > div { display: flex; gap: 8px; }
.modal-foot .mini-btn { color: var(--ink); background: #f0eef8; border-color: #e2def0; flex: 0 0 auto; }
.modal-foot .mini-btn:hover { background: #e6e2f5; }
.modal-foot .mini-btn.primary { color: #fff; }

/* ── 彩帶畫布 ── */
#confetti-canvas {
  position: fixed; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 80;
}

/* ── RWD ── */
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .list-panel { position: static; }
  .stage { padding: 24px 14px; min-height: 460px; }
  .tab { font-size: 13px; padding: 11px 6px; }
}
