/* 桥牌 — Bridge */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700&family=EB+Garamond:ital,wght@0,400;0,600;1,400&family=MedievalSharp&family=Uncial+Antiqua&display=swap');

:root {
    --parchment: #f4e4c1;
    --parchment-light: #faf0d7;
    --parchment-dark: #d4b896;
    --ink: #3a2a1a;
    --ink-light: rgba(58, 42, 26, 0.6);
    --ink-faint: rgba(58, 42, 26, 0.2);
    --sepia: #704214;
    --gold: #b8860b;
    --gold-bright: #daa520;
    --hl-color: #daa520;
    --sanguine: #8c3a3a;
    /* Da Vinci red chalk for Hearts/Diamonds */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: #1a0e04;
    font-family: 'EB Garamond', serif;
}

/* ===== GORGEOUS ENTRANCE ANIMATION ===== */
.entrance-overlay {
    position: fixed;
    inset: 0;
    background: #1a0e04;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    animation: entranceFadeOut 2s 7s forwards;
}

@keyframes entranceFadeOut {
    to {
        opacity: 0;
        pointer-events: none;
    }
}

.entrance-svg {
    width: 50vw;
    max-width: 500px;
    margin-bottom: 20px;
    filter: drop-shadow(0 0 15px rgba(218, 165, 32, 0.3));
}

.anim-draw {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    animation: drawComplex 5s ease-in-out forwards;
}

.anim-draw-fast {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: drawComplex 3s 1s ease-in-out forwards;
}

.anim-draw-slow {
    stroke-dasharray: 4000;
    stroke-dashoffset: 4000;
    animation: drawComplex 6s 0.5s ease-in-out forwards;
}

@keyframes drawComplex {
    to {
        stroke-dashoffset: 0;
    }
}

.rotate-clock {
    transform-origin: center;
    animation: rotateC 25s linear infinite;
}

.rotate-counter {
    transform-origin: center;
    animation: rotateCC 30s linear infinite;
}

@keyframes rotateC {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes rotateCC {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(-360deg);
    }
}

.entrance-title {
    font-family: 'Cinzel', serif;
    font-size: 2.8rem;
    color: var(--gold-bright);
    letter-spacing: 12px;
    opacity: 0;
    animation: fadeUpGold 2s 3.5s forwards;
    text-shadow: 0 0 20px rgba(218, 165, 32, 0.4);
}

.entrance-sub {
    font-family: 'EB Garamond', serif;
    font-style: italic;
    font-size: 1.2rem;
    color: var(--parchment-dark);
    letter-spacing: 6px;
    opacity: 0;
    animation: fadeUpGold 1.5s 4.5s forwards;
}

@keyframes fadeUpGold {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== MAIN CONTAINER ===== */
.main-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    opacity: 0;
    animation: mainFadeIn 1.5s 8s forwards;
}

@keyframes mainFadeIn {
    to {
        opacity: 1;
    }
}

.back-link {
    position: absolute;
    top: 10px;
    left: 15px;
    z-index: 100;
    font-family: 'Cinzel', serif;
    font-size: 0.8rem;
    color: var(--ink);
    text-decoration: none;
    border: 1px solid var(--ink-faint);
    padding: 5px 12px;
    border-radius: 2px;
    background: rgba(244, 228, 193, 0.8);
    transition: all 0.3s;
}

.back-link:hover {
    background: var(--parchment);
    border-color: var(--ink);
}

/* Deal / Reset Controls */
.game-controls {
    position: absolute;
    top: 12px;
    right: 20px;
    z-index: 100;
    display: flex;
    gap: 10px;
}

.game-btn {
    font-family: 'Cinzel', serif;
    font-size: 0.8rem;
    color: var(--gold);
    border: 1px solid var(--gold);
    background: rgba(58, 42, 26, 0.9);
    padding: 6px 14px;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.3s;
    letter-spacing: 1px;
}

.game-btn:hover {
    background: var(--gold);
    color: #1a0e04;
    box-shadow: 0 0 10px rgba(218, 165, 32, 0.5);
}

/* ===== PARCHMENT ===== */
.parchment {
    position: relative;
    width: 97vw;
    height: 94vh;
    margin: 1.5vh auto;
    background:
        radial-gradient(ellipse at 15% 25%, rgba(180, 150, 100, 0.2) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 75%, rgba(160, 130, 80, 0.15) 0%, transparent 40%),
        radial-gradient(ellipse at center, var(--parchment-light) 30%, var(--parchment) 65%, var(--parchment-dark) 100%);
    border-radius: 3px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.6), inset 0 0 80px rgba(0, 0, 0, 0.08);
    display: flex;
    overflow: hidden;
}

/* ===== LEFT PANE: FEATURE BUTTONS ===== */
.parchment-left {
    width: 28%;
    height: 100%;
    padding: 25px 15px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(0, 0, 0, 0.05);
    position: relative;
    background: linear-gradient(to right, transparent, rgba(0, 0, 0, 0.02) 98%, rgba(0, 0, 0, 0.05));
}

.quill-text-area {
    flex: 1;
    overflow: hidden;
    position: relative;
    margin-bottom: 20px;
}

.quill-svg {
    width: 100%;
    height: auto;
    display: block;
}

.quill-title {
    font-family: 'Uncial Antiqua', cursive;
    font-size: 20px;
    fill: var(--ink);
    opacity: 0;
    clip-path: inset(0 100% -20% -10%);
}

.quill-line {
    font-family: 'EB Garamond', cursive;
    font-size: 13px;
    font-style: italic;
    fill: var(--ink);
    opacity: 0;
    clip-path: inset(0 100% -20% -10%);
}

.writing-active {
    opacity: 1 !important;
    animation: writeSmooth 1.2s linear forwards;
}

@keyframes writeSmooth {
    from {
        clip-path: inset(0 100% -20% -10%);
    }

    to {
        clip-path: inset(0 -10% -20% -10%);
    }
}

.guide-panel-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.guide-title {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    color: var(--ink);
    border-bottom: 1px solid var(--ink-faint);
    padding-bottom: 5px;
    margin-bottom: 5px;
    text-align: center;
    letter-spacing: 2px;
}

.feature-btn {
    background: rgba(180, 150, 100, 0.08);
    border: 1px solid var(--ink-faint);
    padding: 6px 10px;
    font-family: 'EB Garamond', serif;
    font-size: 0.8rem;
    color: var(--ink);
    cursor: pointer;
    width: 100%;
    transition: all 0.25s;
    text-align: left;
    position: relative;
    border-radius: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.feature-btn:hover,
.feature-btn.active {
    background: rgba(184, 134, 11, 0.15);
    border-color: var(--gold);
    color: var(--gold);
    transform: translateX(4px);
}

.btn-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--ink-faint);
    transition: background 0.3s;
}

.feature-btn:hover .btn-dot,
.feature-btn.active .btn-dot {
    background: var(--gold);
    box-shadow: 0 0 5px var(--gold);
}

.btn-status {
    display: block;
    font-size: 0.6rem;
    color: var(--ink-light);
    font-style: italic;
    margin-top: 2px;
}

/* ===== RIGHT PANE: BRIDGE TABLE ===== */
.parchment-right {
    width: 72%;
    height: 100%;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.table-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
}

/* Da Vinci Sketch Circle for Table */
.table-sketch-bg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 85%;
    height: 85%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.6;
}

.player-area {
    position: absolute;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    transition: filter 0.3s;
}

.player-n {
    top: 0;
    left: 50%;
    transform: translateX(-50%);
}

.player-s {
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
}

.player-w {
    left: 0;
    top: 50%;
    transform: translateY(-50%) rotate(90deg);
}

.player-e {
    right: 0;
    top: 50%;
    transform: translateY(-50%) rotate(-90deg);
}

.player-label {
    position: absolute;
    font-family: 'Cinzel', serif;
    font-size: 0.8rem;
    color: var(--sepia);
    background: rgba(244, 228, 193, 0.8);
    padding: 2px 6px;
    border: 1px solid var(--ink-faint);
    border-radius: 2px;
    text-align: center;
    pointer-events: none;
}

.player-n .player-label {
    bottom: -25px;
}

.player-s .player-label {
    top: -25px;
}

.player-w .player-label {
    bottom: -25px;
}

.player-e .player-label {
    top: -25px;
}

.hand {
    display: flex;
    gap: -20px;
    position: relative;
    width: max-content;
}

.card {
    width: 50px;
    height: 75px;
    background: #fffcf5;
    border: 1px solid var(--ink-light);
    border-radius: 3px;
    box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.2);
    margin-left: -25px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, top 0.2s;
    position: relative;
    overflow: hidden;
}

.card:first-child {
    margin-left: 0;
}

.card:hover {
    transform: translateY(-10px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    z-index: 100 !important;
}

.card.unplayable {
    filter: grayscale(1) brightness(0.9);
    cursor: not-allowed;
}

.card.unplayable:hover {
    transform: none;
    box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.2);
}

.card-back {
    background: repeating-linear-gradient(45deg, transparent, transparent 3px, rgba(58, 42, 26, 0.1) 3px, rgba(58, 42, 26, 0.1) 6px),
        repeating-linear-gradient(-45deg, transparent, transparent 3px, rgba(58, 42, 26, 0.1) 3px, rgba(58, 42, 26, 0.1) 6px), var(--parchment-light);
    border: 1px solid var(--ink);
}

.card-svg {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
}

.card-val {
    font-family: 'Cinzel', serif;
    font-size: 14px;
    font-weight: bold;
}

.card-suit-sm {
    font-size: 10px;
}

.trick-area {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 150px;
    height: 150px;
    z-index: 5;
}

.played-card {
    position: absolute;
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Status Box */
.status-box {
    position: absolute;
    top: 15px;
    left: 15px;
    background: rgba(244, 228, 193, 0.8);
    border: 1px solid var(--ink);
    padding: 8px 12px;
    font-family: 'EB Garamond', serif;
    font-size: 0.9rem;
    color: var(--ink);
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.1);
    z-index: 20;
    transition: filter 0.3s;
}

.status-box h4 {
    font-family: 'Cinzel', serif;
    margin-bottom: 5px;
    border-bottom: 1px solid var(--ink-faint);
    padding-bottom: 3px;
    font-size: 0.85rem;
}

.highlighted {
    filter: drop-shadow(0 0 8px var(--gold)) brightness(1.1) !important;
}

/* ===== SLIDE-IN TUTORIAL PANEL ===== */
.feature-panel {
    position: fixed;
    top: 0;
    right: -50vw;
    width: 40vw;
    height: 100vh;
    background: radial-gradient(ellipse at 50% 50%, var(--parchment-light) 0%, var(--parchment) 100%);
    border-left: 2px solid var(--ink-faint);
    z-index: 1000;
    overflow-y: auto;
    transition: right 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.3);
}

.feature-panel.open {
    right: 0;
}

.close-panel-btn {
    float: right;
    margin: 15px;
    background: transparent;
    border: 1px solid var(--ink-faint);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s;
}

.close-panel-btn:hover {
    background: var(--ink);
    color: var(--parchment);
}

.feature-panel-inner {
    padding: 40px 30px;
    clear: both;
}

.fp-title {
    font-family: 'Cinzel', serif;
    font-size: 1.6rem;
    color: var(--ink);
    border-bottom: 1px solid var(--ink-faint);
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.fp-desc {
    font-family: 'EB Garamond', serif;
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--ink);
    margin-bottom: 20px;
}

.fp-demo {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid var(--ink-faint);
    padding: 15px;
    text-align: center;
    border-radius: 4px;
    margin-bottom: 20px;
}

.fp-demo svg {
    max-width: 100%;
    height: auto;
}

.fp-details h3 {
    font-family: 'Cinzel', serif;
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: var(--ink);
}

.fp-details p {
    font-family: 'EB Garamond', serif;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--sepia);
    margin-bottom: 15px;
}

/* ===== AI REASON BOX ===== */
.ai-reason-box {
    position: absolute;
    bottom: 15px;
    left: 15px;
    background: rgba(58, 42, 26, 0.92);
    border: 1px solid var(--gold);
    padding: 10px 14px;
    font-family: 'EB Garamond', serif;
    font-size: 0.85rem;
    color: var(--parchment);
    box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.3);
    z-index: 20;
    max-width: 320px;
    border-radius: 4px;
    transition: opacity 0.4s;
}

.ai-reason-title {
    font-family: 'Cinzel', serif;
    font-size: 0.8rem;
    color: var(--gold);
    margin-bottom: 5px;
    border-bottom: 1px solid rgba(218, 165, 32, 0.3);
    padding-bottom: 4px;
}

.ai-reason-text {
    line-height: 1.5;
}

.ai-reason-text .reason-highlight {
    color: var(--gold-bright);
    font-weight: bold;
}

/* Pulsing animation for AI demo active */
.ai-demo-active {
    animation: aiPulse 1s ease-in-out infinite;
}

@keyframes aiPulse {

    0%,
    100% {
        box-shadow: 0 0 5px var(--gold);
    }

    50% {
        box-shadow: 0 0 20px var(--gold);
    }
}