/* ============================================
   七巧板游戏样式表
   Tangram Game - Stylesheet
   ============================================ */

/* === Reset & Base === */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0f0f23;
    --bg-secondary: #1a1a3e;
    --bg-panel: rgba(255, 255, 255, 0.04);
    --bg-panel-hover: rgba(255, 255, 255, 0.08);
    --text-primary: #e8e8ff;
    --text-secondary: #9898cc;
    --text-muted: #6868aa;
    --accent-1: #667eea;
    --accent-2: #764ba2;
    --accent-3: #f093fb;
    --gradient-main: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-warm: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-cool: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-accent: rgba(102, 126, 234, 0.4);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(102, 126, 234, 0.3);
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

.subtitle {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 400;
}

/* === Action Buttons === */
.action-btn {
    border: none;
    border-radius: var(--radius-md);
    padding: 10px 20px;
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    gap: 6px;
}

.action-btn:hover {
    transform: translateY(-2px);
}

.action-btn:active {
    transform: translateY(0) scale(0.97);
}

.reset-btn {
    background: var(--bg-panel);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

.shuffle-btn {
    display: none;
    background: rgba(102, 126, 234, 0.14);
    color: #dfe5ff;
    border: 1px solid rgba(130, 150, 255, 0.32);
}

.shuffle-btn:hover {
    background: rgba(102, 126, 234, 0.24);
    color: #ffffff;
    border-color: rgba(160, 177, 255, 0.52);
    box-shadow: 0 0 18px rgba(102, 126, 234, 0.2);
}

.reset-btn:hover {
    background: var(--bg-panel-hover);
    color: var(--text-primary);
    border-color: var(--border-accent);
}

.help-btn {
    background: var(--bg-panel);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

.help-btn:hover {
    background: rgba(102, 126, 234, 0.15);
    color: var(--accent-1);
    border-color: var(--border-accent);
}

.help-btn.active {
    background: var(--gradient-main);
    color: #fff;
    border-color: transparent;
    box-shadow: var(--shadow-glow);
}

.target-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.select-btn {
    background: var(--bg-panel);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

.select-btn:hover {
    background: rgba(118, 75, 162, 0.14);
    color: var(--text-primary);
    border-color: rgba(118, 75, 162, 0.4);
}

.pattern-select-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
}

.pattern-select-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.primary-btn {
    background: var(--gradient-main);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.primary-btn:hover {
    box-shadow: var(--shadow-glow), var(--shadow-md);
}

.secondary-btn {
    background: var(--bg-panel);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

.secondary-btn:hover {
    background: var(--bg-panel-hover);
    color: var(--text-primary);
}

/* === Game Container === */
.game-container {
    display: flex;
    flex: 1;
    height: 100vh;
    padding: 16px;
    gap: 16px;
    position: relative;
}

/* === Panels === */
.panel {
    flex: 1;
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.source-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel-header h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.source-header-copy {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.source-brand {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.source-brand h1 {
    font-size: 24px;
    font-weight: 800;
    background: var(--gradient-main);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
    line-height: 1;
}

.panel-hint {
    font-size: 12px;
    color: var(--text-muted);
}

.source-panel {
    border-color: rgba(102, 126, 234, 0.2);
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
}

.source-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--gradient-main);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.target-panel {
    border-color: rgba(240, 147, 251, 0.2);
    background: linear-gradient(135deg, rgba(240, 147, 251, 0.05) 0%, rgba(245, 87, 108, 0.05) 100%);
}

.target-panel.selector-open {
    z-index: 40;
}

.target-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--gradient-warm);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.target-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pattern-category {
    font-size: 12px;
    color: var(--text-muted);
}

.target-canvas-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px 10px;
    min-height: 320px;
}

#targetSvg {
    width: 100%;
    height: 100%;
}

.quick-pattern-section {
    padding: 2px 12px 12px;
    border-top: 1px solid var(--border-subtle);
}

.quick-pattern-title {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 6px;
    padding: 0 4px;
}

.quick-pattern-strip {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 2px 2px 2px;
    scrollbar-width: thin;
}

.quick-pattern-thumb {
    min-width: 70px;
    border-radius: 12px;
    border: 1px solid var(--border-subtle);
    background: rgba(255, 255, 255, 0.03);
    padding: 6px 5px;
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.quick-pattern-thumb:hover {
    transform: translateY(-2px);
    border-color: rgba(102, 126, 234, 0.42);
    background: rgba(102, 126, 234, 0.08);
}

.quick-pattern-thumb.active {
    border-color: rgba(102, 126, 234, 0.7);
    background: rgba(102, 126, 234, 0.16);
    box-shadow: 0 0 0 1px rgba(102, 126, 234, 0.2);
}

.quick-pattern-thumb svg {
    width: 100%;
    height: 34px;
    display: block;
}

.quick-pattern-thumb-name {
    display: block;
    margin-top: 4px;
    font-size: 10px;
    color: var(--text-secondary);
    text-align: center;
    white-space: nowrap;
}

/* === SVG Styling === */
.silhouette {
    fill: rgba(102, 126, 234, 0.15);
    stroke: rgba(102, 126, 234, 0.5);
    stroke-width: 2;
}

.silhouette-fill {
    fill: #3b478f;
    stroke: #3b478f;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.silhouette-boundary {
    fill: none;
    stroke: rgba(182, 194, 255, 0.82);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.help-outline {
    fill: none;
    stroke: rgba(214, 223, 255, 0.92);
    stroke-width: 2.1;
    stroke-dasharray: 6, 5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.help-hidden {
    display: none;
}

.hidden {
    display: none !important;
}

.color-palette-host {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 32;
}

.color-palette-dial {
    position: fixed;
    left: 0;
    top: 0;
    width: 110px;
    height: 356px;
    pointer-events: auto;
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.94);
    transition:
        opacity 0.28s ease,
        transform 0.36s cubic-bezier(0.22, 1, 0.36, 1);
}

.color-palette-dial.visible {
    opacity: 1;
}

.color-palette-rail {
    position: absolute;
    inset: 18px auto 18px 50%;
    width: 1px;
    transform: translateX(-50%);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02) 0%, rgba(132, 148, 255, 0.18) 18%, rgba(132, 148, 255, 0.28) 50%, rgba(132, 148, 255, 0.18) 82%, rgba(255, 255, 255, 0.02) 100%);
}

.color-palette-viewport {
    position: absolute;
    inset: 24px 0;
    overflow: hidden;
    mask-image: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.38) 12%, #000 28%, #000 72%, rgba(0, 0, 0, 0.38) 88%, transparent 100%);
    -webkit-mask-image: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.38) 12%, #000 28%, #000 72%, rgba(0, 0, 0, 0.38) 88%, transparent 100%);
}

.color-palette-focus-ring {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    border: 2px solid rgba(255, 255, 255, 0.72);
    box-shadow:
        0 0 0 8px rgba(255, 255, 255, 0.05),
        0 10px 24px rgba(0, 0, 0, 0.18),
        0 0 30px rgba(132, 148, 255, 0.12);
    pointer-events: none;
}

.color-palette-track {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
}

.color-palette-dial.dragging .color-palette-track {
    transition: none;
}

.color-swatch-slot {
    width: 100%;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
}

.color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--swatch-color, #ffffff);
    border: 2px solid rgba(255, 255, 255, 0.16);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.16);
    opacity: 0.34;
    transform: scale(0.72);
    transition:
        transform 0.26s cubic-bezier(0.22, 1, 0.36, 1),
        opacity 0.22s ease,
        border-color 0.22s ease,
        box-shadow 0.26s ease;
}

.color-swatch.near {
    opacity: 0.5;
    transform: scale(0.88);
}

.color-swatch.mid {
    opacity: 0.72;
    transform: scale(1.02);
}

.color-swatch.active {
    opacity: 1;
    transform: scale(1.22);
    border-color: rgba(255, 255, 255, 0.86);
    box-shadow:
        0 0 0 7px rgba(255, 255, 255, 0.06),
        0 14px 30px rgba(0, 0, 0, 0.26),
        0 0 22px rgba(255, 255, 255, 0.12);
}

.color-palette-dial.dragging .color-swatch.active {
    transform: scale(1.16);
}

.color-swatch-slot:active .color-swatch {
    transform: scale(1.08);
}

/* === Game Layer (Fullscreen SVG) === */
#gameLayer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

#piecesLayer {
    pointer-events: bounding-box;
}

.piece {
    pointer-events: all;
    opacity: 1;
    transition: opacity 0.2s ease;
}

.piece.shuffling {
    transition: none;
}

.piece.dimmed {
    opacity: 0.6;
}

.piece.help-obscuring {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.piece-body {
    cursor: grab;
    stroke: rgba(255, 255, 255, 0.6);
    stroke-width: 1.5;
    filter: drop-shadow(2px 4px 6px rgba(0, 0, 0, 0.4));
    transition: filter 0.2s ease, stroke-width 0.2s ease;
}

.piece:hover .piece-body {
    stroke-width: 3;
    filter: drop-shadow(2px 4px 8px rgba(0, 0, 0, 0.5));
}

.piece.dragging .piece-body {
    cursor: grabbing;
    stroke-width: 3;
    filter: drop-shadow(4px 8px 16px rgba(0, 0, 0, 0.6));
}

.piece.selected .piece-body {
    stroke: rgba(255, 255, 255, 0.96);
    stroke-width: 3;
    filter: drop-shadow(0 0 14px rgba(255, 255, 255, 0.18));
}

.piece.snap-ready .piece-body {
    stroke: rgba(255, 255, 255, 0.95);
    stroke-width: 3.5;
    filter: drop-shadow(0 0 18px rgba(102, 126, 234, 0.65));
}

.piece.snapped .piece-body {
    cursor: default;
    stroke: rgba(255, 255, 255, 0);
    stroke-width: 0;
    filter: none;
}

/* Snap animation */
@keyframes snapPulse {
    0% { filter: drop-shadow(0 0 0 rgba(102, 126, 234, 0)); }
    50% { filter: drop-shadow(0 0 12px rgba(102, 126, 234, 0.45)); }
    100% { filter: none; }
}

.piece.snapped .piece-body {
    animation: snapPulse 0.5s ease-out;
}

.piece-handles {
    display: none;
}

.piece-handles.visible {
    display: block;
}

.piece-handle {
    pointer-events: all;
    opacity: 0.5;
    transition: opacity 0.16s ease;
    will-change: opacity;
}

.piece-handle .handle-hit {
    fill: transparent;
    stroke: none;
}

.piece-handle .handle-ring {
    display: none;
}

.piece-handle .handle-icon {
    fill: none;
    stroke: rgba(255, 255, 255, 0.92);
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
    transform-box: fill-box;
    transform-origin: center;
    will-change: transform, stroke, opacity;
    transition: stroke 0.18s ease, transform 0.18s ease, opacity 0.18s ease;
}

.rotate-handle {
    cursor: alias;
}

.flip-handle {
    cursor: pointer;
}

.piece-handle:hover,
.piece-handle:active {
    opacity: 1;
}

.piece-handle:hover .handle-icon {
    stroke: rgba(255, 215, 118, 1);
    transform: scale(1.08);
}

.piece-handle:active .handle-icon,
.piece-handle.pressed .handle-icon,
.piece-handle.active-handle .handle-icon {
    stroke: rgba(255, 255, 255, 1);
    transform: scale(1.28);
}

.piece-handles.focus-mode .piece-handle {
    opacity: 0.2;
}

.piece-handles.focus-mode .piece-handle .handle-icon {
    transform: scale(0.82);
    stroke: rgba(255, 255, 255, 0.72);
}

.piece-handles.focus-mode .piece-handle.active-handle {
    opacity: 1;
}

.piece-handles.focus-mode .piece-handle.active-handle .handle-icon {
    transform: scale(1.22);
    stroke: rgba(255, 255, 255, 1);
}

/* === Modal === */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none !important;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(7, 7, 16, 0.2);
}

.modal-content {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    padding: 40px;
    border-radius: var(--radius-xl);
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: modalPopIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 420px;
    width: 90%;
}

.modal-close-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition:
        background 0.2s ease,
        color 0.2s ease,
        transform 0.2s ease,
        border-color 0.2s ease;
}

.modal-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.18);
    transform: scale(1.04);
}

.modal-close-btn:active {
    transform: scale(0.96);
}

@keyframes modalPopIn {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.modal-icon {
    font-size: 56px;
    margin-bottom: 12px;
    animation: bounceIn 0.6s ease-out;
}

@keyframes bounceIn {
    0% { transform: scale(0); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.modal-content h2 {
    font-size: 28px;
    font-weight: 800;
    background: var(--gradient-warm);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.modal-content p {
    color: var(--text-secondary);
    font-size: 16px;
    margin-bottom: 24px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.modal-actions .action-btn {
    padding: 12px 24px;
    font-size: 15px;
}

/* === Pattern Selector === */
.selector-panel {
    position: absolute;
    inset: 78px 12px 12px;
    z-index: 45;
    background: rgba(20, 18, 46, 0.96);
    backdrop-filter: blur(18px);
    border: 1px solid rgba(134, 149, 255, 0.16);
    border-radius: 22px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.38);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.selector-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.selector-panel-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.selector-panel-actions {
    display: flex;
    gap: 10px;
}

.selector-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-template-rows: repeat(5, minmax(0, 1fr));
    gap: 10px;
    flex: 1;
    min-height: 0;
}

.selector-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 10px 8px;
    cursor: pointer;
    transition: all 0.25s ease;
    text-align: center;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    gap: 6px;
    height: 100%;
    overflow: hidden;
}

.selector-card:hover:not(.placeholder) {
    background: var(--bg-panel-hover);
    border-color: var(--border-accent);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.selector-card.current {
    border-color: rgba(255, 255, 255, 0.16);
}

.selector-card.selected {
    border-color: rgba(133, 153, 255, 0.92);
    background: linear-gradient(180deg, rgba(108, 127, 242, 0.24) 0%, rgba(78, 97, 210, 0.2) 100%);
    box-shadow: 0 0 0 1px rgba(133, 153, 255, 0.36) inset, 0 0 28px rgba(102, 126, 234, 0.22);
    transform: translateY(-2px);
}

.selector-card.selected:hover {
    border-color: rgba(165, 181, 255, 1);
    background: linear-gradient(180deg, rgba(123, 142, 255, 0.32) 0%, rgba(88, 108, 225, 0.26) 100%);
    box-shadow: 0 0 0 1px rgba(165, 181, 255, 0.42) inset, 0 0 34px rgba(102, 126, 234, 0.28);
}

.selector-card.placeholder {
    cursor: default;
    opacity: 0.36;
    border-style: dashed;
}

.selector-card.placeholder:hover {
    transform: none;
    box-shadow: none;
}

.card-preview {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 0;
    margin-bottom: 0;
}

.card-preview svg {
    width: 76%;
    height: 76%;
    max-width: 100%;
    max-height: 100%;
    flex: 0 0 auto;
}

.card-info {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 26px;
    flex: 0 0 auto;
}

.card-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
}

.selector-card.current .card-name::after {
    content: ' · 当前';
    color: var(--text-muted);
    font-weight: 500;
}

.selector-panel .action-btn:disabled {
    opacity: 0.38;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* === Scrollbar === */
.selector-panel::-webkit-scrollbar {
    width: 6px;
}

.selector-panel::-webkit-scrollbar-track {
    background: transparent;
}

.selector-panel::-webkit-scrollbar-thumb {
    background: var(--border-subtle);
    border-radius: 3px;
}

.selector-panel::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* === Challenge Mode === */
.challenge-btn {
    background: linear-gradient(135deg, rgba(240, 147, 251, 0.18) 0%, rgba(245, 87, 108, 0.18) 100%);
    color: #f0b3ff;
    border: 1px solid rgba(240, 147, 251, 0.32);
}

.challenge-btn:hover {
    background: linear-gradient(135deg, rgba(240, 147, 251, 0.28) 0%, rgba(245, 87, 108, 0.28) 100%);
    color: #ffffff;
    border-color: rgba(240, 147, 251, 0.52);
    box-shadow: 0 0 18px rgba(240, 147, 251, 0.2);
}

.challenge-abandon-btn {
    background: rgba(245, 87, 108, 0.14);
    color: #f5576c;
    border: 1px solid rgba(245, 87, 108, 0.32);
}

.challenge-abandon-btn:hover {
    background: rgba(245, 87, 108, 0.24);
    color: #ff8a9e;
    border-color: rgba(245, 87, 108, 0.52);
    box-shadow: 0 0 18px rgba(245, 87, 108, 0.2);
}

body.challenge-active #helpBtn,
body.challenge-active #patternSelectBtn,
body.challenge-active #resetBtn,
body.challenge-active #shuffleBtn {
    display: none !important;
}

.target-panel .panel-header {
    position: relative;
}

.challenge-timer {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    pointer-events: none;
}

.timer-display {
    font-family: 'Outfit', monospace;
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 3px;
    padding: 6px 18px;
    border-radius: var(--radius-sm);
    background: rgba(102, 126, 234, 0.08);
    border: 1px solid rgba(102, 126, 234, 0.2);
    white-space: nowrap;
    display: inline-block;
}

.challenge-timer.urgent .timer-display {
    color: #f5a623;
    border-color: rgba(245, 166, 35, 0.4);
    background: rgba(245, 166, 35, 0.1);
    animation: timerGlow 1.2s ease-in-out infinite;
}

.challenge-timer.critical .timer-display {
    color: #f5576c;
    font-size: 28px;
    font-weight: 800;
    border-color: rgba(245, 87, 108, 0.5);
    background: rgba(245, 87, 108, 0.14);
    box-shadow: 0 0 24px rgba(245, 87, 108, 0.3);
    animation: timerCritical 0.5s ease-in-out infinite;
}

@keyframes timerGlow {
    0%, 100% {
        box-shadow: 0 0 8px rgba(245, 166, 35, 0.1);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 20px rgba(245, 166, 35, 0.3);
        transform: scale(1.04);
    }
}

@keyframes timerCritical {
    0%, 100% {
        box-shadow: 0 0 12px rgba(245, 87, 108, 0.2);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 30px rgba(245, 87, 108, 0.5);
        transform: scale(1.1);
    }
}

.challenge-intro-content {
    max-width: 440px;
}

.challenge-rules {
    text-align: left;
    margin: 16px 0 24px;
    padding: 16px 18px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.challenge-rules-list {
    list-style: none;
    padding: 0;
    margin: 0 0 14px;
}

.challenge-rules-list li {
    padding: 7px 0;
    color: var(--text-secondary);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    line-height: 1.5;
}

.challenge-rules-list li strong {
    color: var(--text-primary);
}

.rule-icon {
    flex-shrink: 0;
    font-size: 16px;
}

.challenge-star-table {
    border-top: 1px solid var(--border-subtle);
    padding-top: 12px;
}

.star-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 13px;
}

.star-label {
    letter-spacing: 1px;
}

.star-time {
    color: var(--text-muted);
    font-size: 12px;
}

.challenge-stars {
    font-size: 32px;
    margin: 8px 0 4px;
    letter-spacing: 6px;
    display: flex;
    justify-content: center;
    gap: 4px;
    min-height: 10px;
}

.star-filled {
    color: #FFD93D;
    text-shadow: 0 0 12px rgba(255, 217, 61, 0.4);
    display: inline-block;
    animation: starPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

.star-filled:nth-child(1) { animation-delay: 0.1s; }
.star-filled:nth-child(2) { animation-delay: 0.2s; }
.star-filled:nth-child(3) { animation-delay: 0.3s; }
.star-filled:nth-child(4) { animation-delay: 0.4s; }
.star-filled:nth-child(5) { animation-delay: 0.5s; }

.star-empty {
    color: var(--text-muted);
    opacity: 0.3;
}

@keyframes starPop {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.challenge-time-display {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* === Responsive === */
@media (max-width: 768px) {
    .game-container {
        flex-direction: column;
        padding: 8px;
        gap: 8px;
    }

    .subtitle {
        display: none;
    }

    .panel-header {
        padding: 10px 14px;
    }

    .target-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .source-brand h1 {
        font-size: 20px;
    }

    .selector-panel {
        inset: 70px 8px 8px;
        padding: 12px;
    }

    .selector-panel-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .selector-grid {
        gap: 8px;
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}
