/*
 * 成语接龙 Idiom Chain — /games/idiom-chain (growth plan D80)
 *
 * The visual job of this page is one thing: make the LINK CHARACTER obvious. The rule is
 * "the last character of one idiom is the first character of the next", and a player who
 * cannot see at a glance which character is carrying the chain is playing a different,
 * much worse game. So the link character glows, pulses, and is the only accent colour in
 * the chain; everything else is deliberately quiet.
 *
 * Dark mode is handled through [data-bs-theme="dark"], matching the rest of the site.
 */

.ic-hero {
    background: linear-gradient(135deg, #b45309 0%, #92400e 45%, #7c2d12 100%);
    position: relative;
    overflow: hidden;
}

.ic-hero::after {
    content: "龙";
    position: absolute;
    right: -0.15em;
    bottom: -0.42em;
    font-size: 11rem;
    line-height: 1;
    opacity: 0.08;
    font-weight: 700;
    pointer-events: none;
}

/* ── HUD ─────────────────────────────────────────────────────────────────── */

.ic-hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    flex-wrap: wrap;
}

[data-bs-theme="dark"] .ic-hud {
    border-bottom-color: rgba(255, 255, 255, 0.12);
}

.ic-hud-item {
    display: flex;
    flex-direction: column;
    min-width: 3.25rem;
}

.ic-hud-item > span {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.1;
}

.ic-hud-item > small {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.6;
}

.ic-heart {
    color: #dc2626;
    font-size: 1.1rem;
    margin-right: 0.1rem;
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.ic-heart.ic-heart-lost {
    opacity: 0.2;
    transform: scale(0.75);
}

.ic-combo-badge {
    display: inline-block;
    padding: 0 0.4rem;
    border-radius: 0.4rem;
    background: rgba(180, 83, 9, 0.12);
    color: #b45309;
    transition: transform 0.2s ease, background 0.2s ease;
}

.ic-combo-badge.ic-combo-hot {
    background: linear-gradient(135deg, #f59e0b, #dc2626);
    color: #fff;
    transform: scale(1.12);
    box-shadow: 0 0 14px rgba(245, 158, 11, 0.55);
}

/* ── Stage ───────────────────────────────────────────────────────────────── */

.ic-stage {
    position: relative;
    min-height: 26rem;
}

.ic-progress {
    height: 4px;
    border-radius: 2px;
    background: rgba(0, 0, 0, 0.07);
    overflow: hidden;
    margin-bottom: 0.75rem;
}

[data-bs-theme="dark"] .ic-progress {
    background: rgba(255, 255, 255, 0.1);
}

.ic-progress-fill {
    height: 100%;
    width: 0;
    border-radius: 2px;
    background: linear-gradient(90deg, #f59e0b, #b45309);
    transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.ic-timer {
    height: 8px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.07);
    overflow: hidden;
    margin: 0.5rem 0 0.85rem;
}

[data-bs-theme="dark"] .ic-timer {
    background: rgba(255, 255, 255, 0.1);
}

.ic-timer-fill {
    height: 100%;
    width: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, #16a34a, #65a30d);
    transition: width 0.1s linear, background 0.3s ease;
}

.ic-timer-fill.ic-timer-warn {
    background: linear-gradient(90deg, #f59e0b, #ea580c);
}

.ic-timer-fill.ic-timer-danger {
    background: linear-gradient(90deg, #dc2626, #991b1b);
    animation: ic-pulse 0.6s ease-in-out infinite;
}

@keyframes ic-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.45; }
}

/* ── The chain ───────────────────────────────────────────────────────────── */

.ic-chain {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    overflow-x: auto;
    padding: 0.35rem 0.15rem 0.6rem;
    scrollbar-width: thin;
    min-height: 4.2rem;
}

.ic-tile {
    display: flex;
    flex: 0 0 auto;
    padding: 0.35rem 0.45rem;
    border-radius: 0.6rem;
    background: rgba(180, 83, 9, 0.08);
    border: 1px solid rgba(180, 83, 9, 0.2);
    animation: ic-tile-in 0.42s cubic-bezier(0.22, 1, 0.36, 1);
}

[data-bs-theme="dark"] .ic-tile {
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.3);
}

@keyframes ic-tile-in {
    from { opacity: 0; transform: translateX(-14px) scale(0.86); }
    to   { opacity: 1; transform: none; }
}

.ic-tile-char {
    font-size: 1.55rem;
    line-height: 1.15;
    font-weight: 600;
    padding: 0 0.06em;
}

/* The character carrying the chain forward — the one thing the page must make obvious. */
.ic-tile-char.ic-linked {
    color: #b45309;
    text-shadow: 0 0 12px rgba(245, 158, 11, 0.75);
    animation: ic-glow 1.6s ease-in-out infinite;
}

[data-bs-theme="dark"] .ic-tile-char.ic-linked {
    color: #fbbf24;
}

@keyframes ic-glow {
    0%, 100% { text-shadow: 0 0 8px rgba(245, 158, 11, 0.5); }
    50%      { text-shadow: 0 0 20px rgba(245, 158, 11, 1); }
}

.ic-chain-link {
    flex: 0 0 auto;
    color: #b45309;
    opacity: 0.55;
    font-size: 0.85rem;
}

/* ── Prompt ──────────────────────────────────────────────────────────────── */

.ic-prompt {
    text-align: center;
    margin-bottom: 0.85rem;
    min-height: 3.6rem;
}

.ic-prompt-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.6;
}

.ic-prompt-char {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    margin: 0.15rem auto 0;
    border-radius: 0.75rem;
    font-size: 1.9rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #f59e0b, #b45309);
    box-shadow: 0 6px 18px rgba(180, 83, 9, 0.4);
    animation: ic-prompt-in 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes ic-prompt-in {
    from { transform: scale(0.6) rotate(-8deg); opacity: 0; }
    to   { transform: none; opacity: 1; }
}

/* ── Options ─────────────────────────────────────────────────────────────── */

.ic-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
}

@media (min-width: 992px) {
    .ic-options {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.ic-option {
    position: relative;
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.6rem 0.7rem;
    border-radius: 0.7rem;
    border: 2px solid rgba(0, 0, 0, 0.1);
    background: var(--bs-body-bg, #fff);
    cursor: pointer;
    transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

[data-bs-theme="dark"] .ic-option {
    border-color: rgba(255, 255, 255, 0.14);
}

.ic-option:hover:not(:disabled) {
    transform: translateY(-2px);
    border-color: #f59e0b;
    box-shadow: 0 6px 16px rgba(180, 83, 9, 0.18);
}

.ic-option:disabled {
    cursor: default;
}

.ic-option-hanzi {
    font-size: 1.35rem;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: 0.02em;
}

.ic-option-pinyin {
    font-size: 0.78rem;
    opacity: 0.72;
}

.ic-option-meaning {
    font-size: 0.75rem;
    opacity: 0.6;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ic-option-key {
    position: absolute;
    top: 0.3rem;
    right: 0.4rem;
    font-size: 0.65rem;
    opacity: 0.35;
    font-weight: 700;
}

.ic-option.ic-correct {
    border-color: #16a34a;
    background: rgba(22, 163, 74, 0.1);
    animation: ic-pop 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.ic-option.ic-wrong {
    border-color: #dc2626;
    background: rgba(220, 38, 38, 0.1);
    animation: ic-shake 0.4s ease;
}

.ic-option.ic-faded {
    opacity: 0.3;
}

@keyframes ic-pop {
    0%   { transform: scale(1); }
    45%  { transform: scale(1.06); }
    100% { transform: scale(1); }
}

@keyframes ic-shake {
    0%, 100% { transform: translateX(0); }
    20%      { transform: translateX(-7px); }
    40%      { transform: translateX(6px); }
    60%      { transform: translateX(-4px); }
    80%      { transform: translateX(3px); }
}

.ic-stage.ic-hit {
    animation: ic-shake 0.35s ease;
}

.ic-status {
    text-align: center;
    min-height: 1.6rem;
    margin-top: 0.7rem;
    font-size: 0.88rem;
    font-weight: 600;
}

.ic-status.ic-status-good { color: #16a34a; }
.ic-status.ic-status-bad  { color: #dc2626; }

/* Score pops that float up from a correct answer. */
.ic-float {
    position: absolute;
    pointer-events: none;
    font-weight: 800;
    font-size: 1.1rem;
    color: #16a34a;
    animation: ic-float-up 0.95s ease-out forwards;
    z-index: 6;
}

@keyframes ic-float-up {
    from { opacity: 1; transform: translateY(0) scale(0.9); }
    to   { opacity: 0; transform: translateY(-52px) scale(1.25); }
}

.ic-burst {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

/* ── Overlays ────────────────────────────────────────────────────────────── */

.ic-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    text-align: center;
    padding: 1rem;
    border-radius: 0.75rem;
    background: var(--bs-body-bg, #fff);
    overflow-y: auto;
}

.ic-big-icon {
    font-size: 2.6rem;
    color: #b45309;
}

.ic-btn-primary {
    background: linear-gradient(135deg, #f59e0b, #b45309);
    border: none;
    color: #fff;
    font-weight: 600;
}

.ic-btn-primary:hover,
.ic-btn-primary:focus {
    background: linear-gradient(135deg, #d97706, #92400e);
    color: #fff;
}

.ic-level-picker {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem;
}

.ic-level-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.4rem 0.75rem;
    border-radius: 0.6rem;
    border: 2px solid rgba(0, 0, 0, 0.12);
    background: transparent;
    color: inherit;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

[data-bs-theme="dark"] .ic-level-btn {
    border-color: rgba(255, 255, 255, 0.16);
}

.ic-level-btn.active {
    border-color: #b45309;
    background: rgba(180, 83, 9, 0.12);
}

.ic-level-zh {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.1;
}

.ic-level-en {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.65;
}

.ic-final-score {
    font-size: 2.6rem;
    font-weight: 800;
    line-height: 1;
    background: linear-gradient(135deg, #f59e0b, #b45309);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.ic-final-stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.85rem;
    font-size: 0.82rem;
    opacity: 0.8;
}

.ic-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.3rem;
}

.ic-chip {
    padding: 0.15rem 0.5rem;
    border-radius: 1rem;
    background: rgba(220, 38, 38, 0.12);
    font-size: 0.82rem;
}

/* ── Chain-complete reveal ───────────────────────────────────────────────── */

.ic-reveal {
    justify-content: flex-start;
    padding-top: 1.25rem;
}

.ic-reveal-head {
    font-size: 1.1rem;
    font-weight: 700;
}

.ic-reveal-chain {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    width: 100%;
    max-width: 30rem;
    text-align: left;
}

.ic-reveal-row {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.3rem 0.5rem;
    border-radius: 0.5rem;
    background: rgba(180, 83, 9, 0.07);
    animation: ic-row-in 0.35s ease backwards;
}

@keyframes ic-row-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}

.ic-reveal-hanzi {
    font-size: 1.15rem;
    font-weight: 600;
    white-space: nowrap;
}

.ic-reveal-pinyin {
    font-size: 0.75rem;
    opacity: 0.7;
    white-space: nowrap;
}

.ic-reveal-meaning {
    font-size: 0.75rem;
    opacity: 0.75;
    flex: 1 1 auto;
}

.ic-reveal-score {
    font-size: 1.1rem;
    font-weight: 700;
    color: #16a34a;
}

.ic-audio-btn {
    border: none;
    background: transparent;
    color: #b45309;
    padding: 0 0.2rem;
    cursor: pointer;
}

/* ── The worked example in the prose section ─────────────────────────────── */

.ic-example {
    display: flex;
    align-items: stretch;
    gap: 0.35rem;
    overflow-x: auto;
    padding-bottom: 0.4rem;
}

.ic-example-item {
    flex: 0 0 auto;
    padding: 0.5rem 0.6rem;
    border-radius: 0.6rem;
    border: 1px solid rgba(180, 83, 9, 0.25);
    background: rgba(180, 83, 9, 0.06);
    text-align: center;
    max-width: 11rem;
}

.ic-example-hanzi {
    font-size: 1.25rem;
    font-weight: 600;
}

.ic-example-link {
    color: #b45309;
    font-weight: 800;
}

[data-bs-theme="dark"] .ic-example-link {
    color: #fbbf24;
}

.ic-example-pinyin {
    font-size: 0.7rem;
    opacity: 0.7;
}

.ic-example-meaning {
    font-size: 0.7rem;
    opacity: 0.75;
}

.ic-example-arrow {
    display: flex;
    align-items: center;
    color: #b45309;
    opacity: 0.5;
}

.ic-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (prefers-reduced-motion: reduce) {
    .ic-tile,
    .ic-prompt-char,
    .ic-option,
    .ic-reveal-row,
    .ic-float,
    .ic-tile-char.ic-linked,
    .ic-timer-fill.ic-timer-danger,
    .ic-stage.ic-hit,
    .ic-option.ic-correct,
    .ic-option.ic-wrong {
        animation: none !important;
        transition: none !important;
    }
}
