﻿:root {
  --purple: #6c5ce7;
  --purple-dark: #5143c4;
  --ink: #332f4c;
  --muted: #8d87a8;
  --cream: #fffaf2;
  --panel: rgba(255, 255, 255, .84);
  --line: #eee8f7;
  --pink: #ff7ca8;
  --yellow: #ffd166;
  --green: #43d9a3;
}

* { box-sizing: border-box; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: linear-gradient(145deg, #f7f3ff 0%, #fff8ee 54%, #eefcff 100%);
  font-family: "Noto Sans TC", sans-serif;
  overflow-x: hidden;
}
button { border: 0; font: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--pink); outline-offset: 3px; }
.bg-shape { position: fixed; z-index: -1; border-radius: 50%; filter: blur(3px); opacity: .45; }
.shape-one { width: 360px; height: 360px; top: -150px; left: -100px; background: #cebfff; }
.shape-two { width: 430px; height: 430px; right: -180px; bottom: -190px; background: #b8f4e9; }

.game-shell { width: min(1180px, calc(100% - 32px)); margin: auto; padding: 28px 0 20px; }
.hero { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 20px; }
.hero-actions { display: flex; align-items: center; gap: 10px; }
.back-link { padding: 9px 13px; border: 1px solid white; border-radius: 11px; color: var(--purple); background: rgba(255,255,255,.72); font-size: 11px; font-weight: 800; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-coin {
  width: 58px; height: 58px; display: grid; place-items: center; border: 5px solid white; border-radius: 20px;
  color: white; background: linear-gradient(145deg, #ffbe55, #ff8d5c); box-shadow: 0 10px 24px rgba(255, 141, 92, .25);
  font: 800 32px/1 "Baloo 2", sans-serif; transform: rotate(-8deg);
}
.brand-coin.admin-enabled { cursor: pointer; box-shadow: 0 0 0 3px rgba(108, 92, 231, .14), 0 10px 24px rgba(255, 141, 92, .25); transition: transform .16s, box-shadow .16s; }
.brand-coin.admin-enabled:hover { transform: rotate(-8deg) scale(1.06); }
.brand-coin.paused { background: linear-gradient(145deg, #332f4c, #6c5ce7); box-shadow: 0 0 0 4px rgba(108, 92, 231, .2), 0 0 24px rgba(108, 92, 231, .65); }
body.admin-paused .timer-card { outline: 2px solid var(--purple); outline-offset: -2px; }
body.admin-paused .timer-track i { background: linear-gradient(90deg, #332f4c, var(--purple)) !important; }
.brand p { margin: 0 0 -4px; color: var(--purple); font: 800 10px/1 "Baloo 2", sans-serif; letter-spacing: .18em; }
.brand h1 { margin: 0; font-size: clamp(25px, 4vw, 36px); font-weight: 900; letter-spacing: -.04em; }
.difficulty { display: flex; gap: 5px; padding: 5px; border: 1px solid white; border-radius: 14px; background: rgba(255,255,255,.55); }
.difficulty button { padding: 8px 15px; border-radius: 10px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 700; }
.difficulty button.active { color: white; background: var(--purple); box-shadow: 0 5px 12px rgba(108,92,231,.24); }

.status-panel { display: grid; grid-template-columns: 210px 1fr 210px; gap: 12px; margin-bottom: 12px; }
.stat-card, .timer-card { min-height: 72px; border: 1px solid white; border-radius: 18px; background: var(--panel); box-shadow: 0 12px 35px rgba(75, 62, 120, .07); }
.stat-card { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.stat-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 13px; font-size: 19px; }
.score-card .stat-icon { color: #d18c00; background: #fff0c2; }
.combo-card .stat-icon { color: #e44b82; background: #ffe0ec; }
.stat-card div { display: grid; gap: 2px; }
.stat-card small, .timer-top span { color: var(--muted); font-size: 11px; font-weight: 700; }
.stat-card strong { font: 800 21px/1 "Baloo 2", sans-serif; }
.combo-card strong { color: var(--pink); font-size: 15px; }
.timer-card { padding: 13px 18px; }
.timer-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 11px; }
.timer-top strong { color: var(--purple); font: 800 22px/1 "Baloo 2", sans-serif; }
.timer-track { height: 9px; overflow: hidden; border-radius: 99px; background: #eeeaf7; }
.timer-track i { display: block; width: 100%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--purple), #a57bff); transition: width .5s linear, background .25s; }

.game-card { border: 1px solid white; border-radius: 24px; background: rgba(255,255,255,.7); box-shadow: 0 22px 55px rgba(75, 62, 120, .11); overflow: hidden; backdrop-filter: blur(16px); }
.game-toolbar { min-height: 70px; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.game-toolbar > div:first-child { display: grid; gap: 3px; }
.game-toolbar strong { font-size: 14px; }
.game-toolbar span { color: var(--muted); font-size: 11px; }
.toolbar-actions { display: flex; gap: 7px; }
.soft-button, .primary-button { padding: 9px 13px; border-radius: 11px; font-size: 11px; font-weight: 800; transition: transform .15s, box-shadow .15s, opacity .15s; }
.soft-button { color: var(--ink); background: #f4f0fb; }
.soft-button span { margin-right: 3px; }
.soft-button b { min-width: 17px; display: inline-block; margin-left: 3px; padding: 1px 4px; border-radius: 6px; color: var(--purple); background: white; }
.primary-button { color: white; background: linear-gradient(135deg, #7968ed, #5c4bd3); box-shadow: 0 7px 16px rgba(108,92,231,.22); }
button:hover:not(:disabled) { transform: translateY(-2px); }
button:disabled { cursor: not-allowed; opacity: .45; }

.board-wrap { position: relative; min-height: 570px; display: grid; place-items: center; padding: 28px; }
.board { position: relative; z-index: 2; display: grid; gap: 9px; width: min(100%, 830px); }
.tile {
  position: relative; aspect-ratio: 1; min-width: 0; padding: 0; border: 2px solid white; border-radius: 17px;
  background: linear-gradient(145deg, #fff, #faf8ff); box-shadow: 0 6px 13px rgba(67, 54, 115, .09);
  transition: transform .18s cubic-bezier(.2,.8,.2,1), box-shadow .18s, opacity .28s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.tile:hover:not(.removed) { transform: translateY(-4px) rotate(1deg); box-shadow: 0 11px 21px rgba(80, 64, 140, .14); }
.tile:active:not(.removed) { transform: scale(.92); }
.tile.selected { transform: translateY(-5px) scale(1.05); border-color: var(--purple); box-shadow: 0 0 0 4px rgba(108,92,231,.13), 0 12px 22px rgba(80,64,140,.18); }
.tile.queued { border-color: var(--green); box-shadow: 0 0 0 3px rgba(67,217,163,.2); }
.tile.hint { animation: hintPulse .65s ease-in-out infinite alternate; }
.tile.wrong { animation: shake .3s ease; border-color: var(--pink); }
.tile.removed { pointer-events: none; opacity: 0; transform: scale(.4) rotate(15deg); }
.tile.blocker {
  cursor: not-allowed;
  overflow: hidden;
  border-color: rgba(61, 55, 84, .18);
  background:
    repeating-linear-gradient(135deg, rgba(51,47,76,.1) 0 7px, rgba(255,255,255,.38) 7px 14px),
    linear-gradient(145deg, #c9c5d3, #8d87a8);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.45), 0 6px 13px rgba(67, 54, 115, .08);
}
.tile.blocker:hover { transform: none; }
.blocker-mark {
  width: 58%;
  height: 58%;
  display: grid;
  place-items: center;
  margin: auto;
  border-radius: 14px;
  color: #fffaf2;
  background: linear-gradient(145deg, #464057, #242235);
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.18);
  font-size: clamp(15px, 2.5vw, 24px);
}
.coin {
  width: 66%; height: 66%; display: grid; place-items: center; margin: auto; border-radius: 50%; color: white;
  font: 800 clamp(17px, 2.7vw, 28px)/1 "Baloo 2", sans-serif; text-shadow: 0 2px 0 rgba(0,0,0,.12);
  box-shadow: inset 0 -5px 0 rgba(0,0,0,.12), 0 5px 0 rgba(0,0,0,.05);
}
.tile small { position: absolute; right: 5px; bottom: 3px; color: #bab4cd; font: 800 8px/1 "Baloo 2", sans-serif; }
.path-layer { position: absolute; z-index: 3; pointer-events: none !important; inset: 0; width: 100%; height: 100%; overflow: visible; }
.match-line { pointer-events: none !important; fill: none; stroke: var(--purple); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 2px 3px rgba(108,92,231,.35)); stroke-dasharray: 12 7; animation: dash .45s linear infinite; }
.start-countdown {
  position: absolute; z-index: 6; display: none; place-items: center; width: 110px; height: 110px; border: 7px solid white; border-radius: 35px;
  color: white; background: var(--purple); box-shadow: 0 18px 50px rgba(108,92,231,.35); font: 800 58px/1 "Baloo 2", sans-serif;
  pointer-events: none !important;
}
.start-countdown[hidden] { display: none !important; }
.start-countdown.show { display: grid; animation: countPop .8s ease both; }

footer { display: flex; justify-content: center; gap: 32px; padding: 15px; color: var(--muted); font-size: 10px; font-weight: 700; }
footer span::before { content: "●"; margin-right: 6px; color: var(--green); }
.modal { position: fixed; z-index: 20; inset: 0; display: none; place-items: center; padding: 20px; background: rgba(52,45,83,.33); backdrop-filter: blur(8px); }
.modal.show { display: grid; }
.modal-card { width: min(360px, 100%); padding: 32px; border: 5px solid white; border-radius: 30px; text-align: center; background: #fffaf4; box-shadow: 0 28px 80px rgba(52,45,83,.25); animation: modalPop .35s ease both; }
.result-icon { width: 84px; height: 84px; display: grid; place-items: center; margin: auto; border-radius: 28px; background: #fff0c2; font-size: 42px; transform: rotate(-5deg); }
.modal-card p { margin: 18px 0 3px; color: var(--purple); font-size: 11px; font-weight: 900; letter-spacing: .13em; }
.modal-card h2 { margin: 0 0 18px; font-size: 25px; }
.final-score { display: grid; gap: 2px; margin-bottom: 18px; padding: 13px; border-radius: 14px; background: #f4f0fb; }
.final-score small { color: var(--muted); font-size: 10px; }
.final-score strong { color: var(--purple); font: 800 30px/1 "Baloo 2", sans-serif; }
.member-score-status { min-height: 18px; margin: -8px 0 16px !important; color: var(--muted) !important; font-size: 10px !important; letter-spacing: 0 !important; }
.modal-card button { width: 100%; padding: 12px; }
.toast { position: fixed; z-index: 30; left: 50%; bottom: -80px; transform: translateX(-50%); padding: 10px 16px; border-radius: 12px; color: white; background: var(--ink); font-size: 11px; font-weight: 700; transition: bottom .25s; }
.toast.show { bottom: 22px; }

@keyframes hintPulse { to { transform: translateY(-6px) scale(1.06); box-shadow: 0 0 0 6px rgba(255,209,102,.35); border-color: var(--yellow); } }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes dash { to { stroke-dashoffset: -19; } }
@keyframes countPop { 0% { opacity: 0; transform: scale(.5) rotate(-10deg); } 25%, 75% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(1.25); } }
@keyframes modalPop { from { opacity: 0; transform: translateY(15px) scale(.92); } }

@media (max-width: 760px) {
  .game-shell { width: min(100% - 14px, 620px); padding-top: 12px; }
  .hero { align-items: stretch; flex-direction: column; margin-bottom: 10px; }
  .hero-actions { justify-content: space-between; }
  .brand-coin { width: 45px; height: 45px; border-radius: 15px; font-size: 25px; }
  .brand p { display: none; }
  .brand h1 { font-size: 22px; }
  .difficulty button { padding: 7px 9px; font-size: 10px; }
  .status-panel { grid-template-columns: 1fr 1fr; gap: 7px; }
  .timer-card { grid-column: 1 / -1; grid-row: 2; min-height: 60px; }
  .stat-card { min-height: 58px; padding: 8px 10px; }
  .stat-icon { width: 34px; height: 34px; }
  .game-toolbar { display: grid; padding: 10px; }
  .toolbar-actions { justify-content: space-between; }
  .soft-button, .primary-button { padding: 8px 9px; }
  .board-wrap { min-height: 390px; padding: 13px 7px 16px; overflow: hidden; }
  .board { gap: 4px; }
  .tile { border-width: 1px; border-radius: 9px; }
  .coin { width: 72%; height: 72%; }
  .tile small { display: none; }
  footer { gap: 10px; text-align: center; }
}

@media (hover: none) {
  .tile:hover:not(.removed) { transform: none; box-shadow: 0 6px 13px rgba(67, 54, 115, .09); }
}

@media (max-width: 430px) {
  .hero-actions { align-items: stretch; flex-direction: column; }
  .back-link { text-align: center; }
  .difficulty { display: grid; grid-template-columns: repeat(4, 1fr); }
  .toolbar-actions { display: grid; grid-template-columns: repeat(2, 1fr); }
  .toolbar-actions .primary-button { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
