/* VSS Match Arena - Dedicated Stylesheet */

:root {
  --bg-dark: #0b0f19;
  --bg-panel: #111827;
  --bg-card: rgba(30, 41, 59, 0.7);
  --border-color: rgba(255, 255, 255, 0.08);
  --accent-cyan: #38bdf8;
  --accent-gold: #f59e0b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Secondary Sub-Header for Match Arena */
.match-sub-header {
  background: rgba(15, 23, 42, 0.75);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  width: 100%;
}

.match-sub-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  box-sizing: border-box;
}

.match-brand-tag {
  display: flex;
  align-items: center;
  gap: 8px;
}

.match-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Secondary Navigation Tabs Strip (Identical to Go / Minesweeper / Chess) */
.match-tabs-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
  background: transparent !important;
  padding: 0 16px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  box-sizing: border-box;
}

.match-tabs-strip::-webkit-scrollbar {
  display: none;
}

.match-tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: transparent !important;
  border: none !important;
  border-bottom: 3px solid transparent !important;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  flex: 0 0 auto;
  margin-bottom: -2px;
}

.match-tab-btn:hover {
  color: var(--text-main);
}

.match-tab-btn.active {
  color: #ffffff !important;
  border-bottom-color: var(--accent-cyan) !important;
  background: transparent !important;
  box-shadow: none !important;
}

/* Arena Main Area */
.arena-container {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 20px auto 40px;
  padding: 0 16px;
}

/* Game HUD Dashboard */
.game-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
  backdrop-filter: blur(10px);
}

.hud-stat-group {
  display: flex;
  align-items: center;
  gap: 20px;
}

.hud-stat {
  display: flex;
  flex-direction: column;
}

.hud-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

.hud-val {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.hud-val.gold {
  color: var(--accent-gold);
}

.hud-val.cyan {
  color: var(--accent-cyan);
}

/* Control Buttons */
.icon-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: var(--accent-cyan);
  border-color: var(--accent-cyan);
  color: #ffffff;
}

/* =========================================
   MODE 1: GEM SWAP (8x8)
   ========================================= */
.swap-board-wrap {
  display: flex;
  justify-content: center;
  margin: 0 auto;
  position: relative;
  max-width: 480px;
  width: 100%;
}

.swap-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: rgba(15, 23, 42, 0.7);
  padding: 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  position: relative;
  touch-action: none; /* 关键：禁止移动端滚动，完全接管手指滑动 */
  user-select: none;
  -webkit-user-select: none;
}

.fx-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 40;
}

.gem-cell {
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
  position: relative;
  touch-action: none;
  user-select: none;
}

.gem-cell:hover {
  filter: brightness(1.15);
  z-index: 2;
}

.gem-cell.gem-selected {
  border-color: #ffffff !important;
  transform: scale(1.12);
  box-shadow: 0 0 18px rgba(255, 255, 255, 0.8), inset 0 0 10px rgba(255, 255, 255, 0.3);
  z-index: 5;
  animation: pulseSelect 0.8s infinite alternate;
}

@keyframes pulseSelect {
  0% { transform: scale(1.08); }
  100% { transform: scale(1.16); }
}

/* 爆炸消隐动画 */
@keyframes gemBurst {
  0% { transform: scale(1); filter: brightness(1); }
  35% { transform: scale(1.4) rotate(8deg); filter: brightness(2.8); box-shadow: 0 0 30px #ffffff; }
  100% { transform: scale(0) rotate(20deg); opacity: 0; filter: brightness(4); }
}

.gem-bursting {
  animation: gemBurst 0.22s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards !important;
  z-index: 25 !important;
  pointer-events: none !important;
}

/* 屏幕震动反馈 */
@keyframes gridShake {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-3px, 2px); }
  50% { transform: translate(3px, -2px); }
  75% { transform: translate(-2px, 1px); }
}

@keyframes gridShakeHard {
  0%, 100% { transform: translate(0, 0) scale(1); }
  20% { transform: translate(-7px, 5px) scale(1.02); }
  40% { transform: translate(7px, -6px) scale(0.99); }
  60% { transform: translate(-4px, 4px) scale(1.01); }
  80% { transform: translate(4px, -2px) scale(1); }
}

.grid-shake {
  animation: gridShake 0.24s ease-out;
}

.grid-shake-hard {
  animation: gridShakeHard 0.35s ease-out;
}

.gem-icon {
  font-size: 1.7rem;
  line-height: 1;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.4));
  pointer-events: none;
}

.gem-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: 0.75rem;
  font-weight: 800;
  text-shadow: 0 1px 3px #000;
  pointer-events: none;
}

.combo-floater {
  position: absolute;
  font-size: 1.35rem;
  font-weight: 900;
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: floatUp 0.9s forwards ease-out;
  text-shadow: 0 2px 10px rgba(0,0,0,0.9), 0 0 12px rgba(255,255,255,0.4);
  z-index: 50;
  white-space: nowrap;
}

@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, 0) scale(0.5); }
  25% { opacity: 1; transform: translate(-50%, -18px) scale(1.3); }
  100% { opacity: 0; transform: translate(-50%, -55px) scale(1); }
}

/* =========================================
   MODE 2: 3D TILE STACK (羊了个羊)
   ========================================= */
.tile-arena-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
}

.tile-board-area {
  position: relative;
  width: 100%;
  height: 450px;
  min-height: 450px;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  overflow: hidden;
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.6);
}

.stack-tile {
  position: absolute;
  border-radius: 10px;
  background: #1e293b;
  border: 2px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.45);
  user-select: none;
  -webkit-user-select: none;
}

.tile-clickable {
  border-color: #38bdf8;
  background: linear-gradient(145deg, #243852, #1e293b);
  filter: brightness(1);
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.35);
}

.tile-clickable:hover {
  transform: translateY(-4px) scale(1.04);
  box-shadow: 0 10px 24px rgba(56, 189, 248, 0.55);
  border-color: #7dd3fc;
  z-index: 999 !important;
}

.tile-blocked {
  filter: brightness(0.35) grayscale(0.5);
  cursor: not-allowed;
  border-color: rgba(255, 255, 255, 0.06);
  background: #0f172a;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

.tile-icon {
  font-size: 1.7rem;
  line-height: 1;
  pointer-events: none;
}

/* Buffer bar */
.tile-buffer-wrap {
  width: 100%;
  background: #0f172a;
  border: 2px solid rgba(56, 189, 248, 0.3);
  border-radius: var(--radius-md);
  padding: 10px;
  display: flex;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

.tile-buffer-slots {
  display: flex;
  gap: 8px;
  width: 100%;
  justify-content: space-between;
}

.buffer-slot {
  flex: 1;
  max-width: 54px;
  height: 62px;
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.02);
}

.buffer-slot.has-tile {
  border-style: solid;
  border-color: #38bdf8;
  background: #1e293b;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

/* =========================================
   MODE 3: LINE LINK (7x7)
   ========================================= */
.line-arena-wrap {
  display: flex;
  justify-content: center;
  position: relative;
  max-width: 460px;
  margin: 0 auto;
}

.line-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: rgba(15, 23, 42, 0.6);
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  position: relative;
  touch-action: none;
}

.line-svg-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

.line-cell {
  border-radius: 50%;
  border: 2px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 41, 59, 0.6);
  cursor: pointer;
  position: relative;
  transition: transform 0.15s ease;
}

.orb-icon {
  font-size: 1.6rem;
}

.path-order {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #38bdf8;
  color: #000;
  font-size: 0.68rem;
  font-weight: 800;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* =========================================
   MODE 4: BLOCK PUZZLE (10x10)
   ========================================= */
.block-arena-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 480px;
  margin: 0 auto;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.block-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: rgba(15, 23, 42, 0.7);
  padding: 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin-bottom: 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  touch-action: none;
}

.block-cell {
  background: rgba(30, 41, 59, 0.4);
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.block-cell.block-occupied {
  cursor: default;
}

.block-preview-valid {
  background-color: rgba(16, 185, 129, 0.6) !important;
  box-shadow: inset 0 0 8px rgba(16, 185, 129, 0.9), 0 0 10px rgba(16, 185, 129, 0.5) !important;
  border-color: #10b981 !important;
}

.block-preview-invalid {
  background-color: rgba(239, 68, 68, 0.5) !important;
  box-shadow: inset 0 0 8px rgba(239, 68, 68, 0.8) !important;
  border-color: #ef4444 !important;
}

.block-pieces-area {
  display: flex;
  justify-content: space-between;
  width: 100%;
  gap: 12px;
}

.piece-slot {
  flex: 1;
  height: 96px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: all 0.2s ease;
}

.piece-slot.piece-dragging {
  cursor: grabbing;
  opacity: 0.3;
  transform: scale(0.95);
}

.block-drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 999999;
  display: grid;
  gap: 3px;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.7));
  transition: none;
}

.block-drag-ghost .ghost-cell {
  border-radius: 4px;
  box-shadow: inset 0 0 6px rgba(255, 255, 255, 0.6), 0 0 10px rgba(0, 0, 0, 0.4);
}

.piece-slot:hover {
  border-color: var(--accent-cyan);
}

.piece-slot.piece-selected {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.15);
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.3);
}

.mini-piece-grid {
  display: grid;
  gap: 2px;
}

.mini-cell {
  width: 22px;
  height: 22px;
  border-radius: 3px;
  border: 1px solid transparent;
}

/* =========================================
   MODE 5: LEADERBOARD
   ========================================= */
.rank-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rank-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(8px);
}

.rank-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.rank-num {
  font-size: 1.25rem;
  font-weight: 900;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
}

.rank-1 { background: linear-gradient(135deg, #fbbf24, #d97706); color: #000; }
.rank-2 { background: linear-gradient(135deg, #94a3b8, #64748b); color: #000; }
.rank-3 { background: linear-gradient(135deg, #d97706, #b45309); color: #fff; }

.rank-name {
  font-weight: 700;
  font-size: 1rem;
}

.rank-badge {
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  margin-left: 6px;
}

.rank-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.rank-score {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--accent-gold);
}

/* Modal Windows */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-content {
  background: #111827;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 28px;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  text-align: center;
  position: relative;
}

.modal-close-btn {
  position: absolute;
  top: 12px;
  right: 14px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

.modal-close-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.mode-btn-active {
  background: var(--accent-cyan) !important;
  color: #000000 !important;
  font-weight: 700 !important;
  border-color: var(--accent-cyan) !important;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.35);
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 12px;
}

.modal-body {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.6;
}

.modal-score {
  font-size: 2.4rem;
  font-weight: 900;
  color: var(--accent-gold);
  margin: 12px 0;
}

/* Responsive */
@media (max-width: 540px) {
  .gem-icon { font-size: 1.3rem; }
  .tile-board-area { height: 420px; min-height: 420px; }
  .tile-icon { font-size: 1.4rem; }
  .orb-icon { font-size: 1.3rem; }
  .mini-cell { width: 16px; height: 16px; }
  .piece-slot { height: 74px; }
}
