@layer utilities {
    .content-auto { content-visibility: auto; }
    .block-shadow { box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); }
    .game-grid { touch-action: none; }
    .line-path { pointer-events: none; }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: #000;
    font-family: '微軟正黑體', sans-serif;
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.word-block {
    transition: transform 0.15s ease, opacity 0.15s ease, top 0.3s ease, left 0.3s ease;
    will-change: transform, opacity, top, left;
    cursor: pointer;
    user-select: none;
}

.word-block.selected {
    transform: scale(1.15);
    z-index: 10;
    box-shadow: 0 0 10px 2px rgba(255,255,255,0.8);
}

.word-block.matching {
    animation: matchPulse 0.4s ease forwards;
}

@keyframes matchPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.25); }
    100% { transform: scale(1); opacity: 0; }
}

.sentence-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.85);
    color: #fff;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 18px;
    z-index: 999;
    animation: sentencePop 1.2s ease forwards;
    white-space: nowrap;
}

@keyframes sentencePop {
    0% { opacity: 0; transform: translate(-50%, -60%); }
    30% { opacity: 1; transform: translate(-50%, -50%); }
    80% { opacity: 1; }
    100% { opacity: 0; }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-10px); }
    40%, 80% { transform: translateX(10px); }
}

.shake {
    animation: shake 0.4s ease-in-out;
}

.firework-particle {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 1000;
    animation: explode 0.8s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
}

@keyframes explode {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(var(--tx), var(--ty)) scale(0); opacity: 0; }
}

.star-particle {
    position: absolute;
    font-size: 24px;
    pointer-events: none;
    z-index: 1000;
    transition: all 0.8s cubic-bezier(0.25, 0.1, 0.25, 1);
    text-shadow: 0 0 5px rgba(255,255,0,0.8);
}

.game-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.78);
    z-index: 2000;
}

.game-modal.hidden {
    display: none;
}

.game-modal-card {
    width: calc(100% - 48px);
    max-width: 360px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(10, 10, 10, 0.95);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
    color: #fff;
    padding: 22px;
    text-align: center;
}

.error-text {
    color: #ff7675;
    line-height: 1.7;
}

.task-modal-card {
    max-width: 388px;
    padding: 20px;
    text-align: left;
}

.task-modal-kicker {
    color: #9ca3af;
    font-size: 13px;
    text-align: center;
    margin-bottom: 4px;
}

.task-modal-title {
    color: #fff;
    font-weight: 800;
    font-size: 24px;
    text-align: center;
    margin-bottom: 14px;
    letter-spacing: 1px;
}

.task-main-card {
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.14);
    padding: 14px;
    margin-bottom: 14px;
}

.task-main-label {
    color: #facc15;
    font-size: 15px;
    font-weight: 800;
    margin-bottom: 6px;
}

.task-main-desc {
    color: #fff;
    font-size: 15px;
    line-height: 1.55;
}

.task-main-source,
.task-source {
    color: #9ca3af;
    font-size: 11px;
    margin-top: 5px;
}

.task-special-title {
    color: #d1d5db;
    font-size: 13px;
    margin: 6px 0 8px;
}

.task-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.task-item {
    display: flex;
    align-items: stretch;
    gap: 10px;
    border-radius: 13px;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.06);
}

.task-item.task-blue {
    border-color: rgba(96, 165, 250, 0.56);
    box-shadow: inset 3px 0 0 #3b82f6;
}

.task-item.task-orange {
    border-color: rgba(251, 146, 60, 0.58);
    box-shadow: inset 3px 0 0 #f97316;
}

.task-index {
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-weight: 800;
    font-size: 12px;
    margin-left: 2px;
}

.task-content {
    min-width: 0;
}

.task-title {
    color: #fff;
    font-weight: 800;
    font-size: 14px;
    margin-bottom: 3px;
}

.task-desc {
    color: #e5e7eb;
    font-size: 13px;
    line-height: 1.45;
}

.task-start-button {
    width: 100%;
    margin-top: 16px;
    border: none;
    border-radius: 999px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #facc15, #f97316);
    color: #111827;
    font-weight: 900;
    font-size: 15px;
    box-shadow: 0 8px 18px rgba(249, 115, 22, 0.28);
}

.progress-panel {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.progress-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #d1d5db;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 9px;
}

.task-progress-bar {
    position: relative;
    height: 44px;
    margin-top: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}

.task-progress-fill {
    width: 0;
    height: 12px;
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    border-radius: 999px;
    background: linear-gradient(90deg, #22c55e, #facc15);
    transition: width 0.35s ease;
}

.task-progress-nodes {
    position: absolute;
    inset: 0;
}

.task-progress-node {
    position: absolute;
    top: 50%;
    min-width: 82px;
    max-width: 116px;
    min-height: 30px;
    border-radius: 12px;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.9);
    color: #fff;
    font-size: 10px;
    font-weight: 900;
    line-height: 1.2;
    cursor: pointer;
    z-index: 3;
    padding: 4px 6px;
    text-align: center;
    white-space: normal;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.65), 0 4px 10px rgba(0, 0, 0, 0.45);
    transition: transform 0.2s ease, filter 0.2s ease, opacity 0.2s ease;
}

.task-progress-node.node-blue {
    background: linear-gradient(135deg, #2563eb, #60a5fa);
}

.task-progress-node.node-orange {
    background: linear-gradient(135deg, #ea580c, #fb923c);
}

.task-progress-node.near,
.task-progress-node.reached {
    animation: nodePulse 0.9s ease-in-out infinite;
}

.task-progress-node.completed {
    animation: none;
}

.task-node-prompt,
.task-node-word-pair {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex-wrap: wrap;
}

.task-node-keyword {
    font-size: 12px;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.task-node-word-pair {
    font-size: 13px;
    gap: 4px;
}

.task-node-connector {
    font-size: 14px;
    color: #fef3c7;
}

.task-progress-node:hover {
    transform: translate(-50%, -50%) scale(1.12);
    filter: brightness(1.12);
}

@keyframes nodePulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.65), 0 0 0 0 rgba(250, 204, 21, 0.55);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.12);
        box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.65), 0 0 0 8px rgba(250, 204, 21, 0);
    }
}

.task-start-button:active {
    transform: scale(0.98);
}
