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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100dvh;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #f0f2f5;
    color: #1a1a2e;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    padding-bottom: 40px;
}

/* ===== TOAST ===== */
#toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: #1a1a2e;
    color: #fff;
    padding: 10px 24px;
    border-radius: 100px;
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    animation: toast-in 0.3s ease-out, toast-out 0.3s ease-in 1.8s forwards;
    white-space: nowrap;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(-12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toast-out {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(-12px);
    }
}

/* ===== HEADER ===== */
.header {
    padding: 28px 0 4px;
    text-align: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 900;
    letter-spacing: 0.18em;
    color: #1a1a2e;
}

/* ===== TARGET ===== */
.target-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 0 20px;
}

.target-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: #9ca3af;
}

.target-word {
    font-size: 2rem;
    font-weight: 900;
    letter-spacing: 0.22em;
    color: #4f46e5;
}

/* ===== GAME AREA ===== */
.game-area {
    display: flex;
    justify-content: center;
    padding: 0 16px;
}

.wheels-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ===== LETTER COLUMNS ===== */
.letter-column {
    width: 72px;
    height: 192px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 2px solid #e5e7eb;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
    position: relative;
    touch-action: none;
}

.letter-column:active {
    cursor: grabbing;
}

.letter-column.last-used {
    border-color: #f87171;
    box-shadow: 0 2px 16px rgba(248, 113, 113, 0.18);
}

.letter-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    will-change: transform;
}

.letter {
    width: 72px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.6rem;
    font-weight: 800;
    color: #d1d5db;
    transition: color 0.15s ease;
    pointer-events: none;
}

.letter.active {
    color: #1a1a2e;
    font-size: 2.8rem;
}

.letter-above,
.letter-below {
    opacity: 0.35;
    font-size: 1.6rem;
}

/* ===== BUTTONS ===== */
.buttons-col {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-left: 6px;
}

.btn-check,
.btn-reset {
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn-check {
    background: #22c55e;
}

.btn-reset {
    background: #ef4444;
}

.btn-check:hover,
.btn-reset:hover {
    transform: scale(1.06);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}

.btn-check:active,
.btn-reset:active {
    transform: scale(0.92);
}

/* ===== STEPS ===== */
.steps-display {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 24px 0 16px;
}

.steps-label {
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #9ca3af;
}

.steps-count {
    font-size: 1.8rem;
    font-weight: 900;
    color: #1a1a2e;
}

.btn-restart-inline {
    background: none;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #9ca3af;
    transition: all 0.15s ease;
    margin-left: 4px;
}

.btn-restart-inline:hover {
    border-color: #4f46e5;
    color: #4f46e5;
    background: #eef2ff;
}

.btn-restart-inline:active {
    transform: scale(0.9);
}

/* ===== WORD CHAIN ===== */
.chain-section {
    width: 100%;
    max-width: 400px;
    padding: 0 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.chain-section::-webkit-scrollbar {
    display: none;
}

.chain-track {
    display: flex;
    gap: 8px;
    padding: 8px 0;
    min-height: 48px;
    align-items: center;
}

.chain-word {
    flex-shrink: 0;
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    background: #fff;
    border: 2px solid #e5e7eb;
    color: #1a1a2e;
    transition: all 0.3s ease;
}

.chain-word:first-child {
    border-color: #4f46e5;
    color: #4f46e5;
    background: #eef2ff;
}

.chain-word.start-word {
    border-color: #9ca3af;
    color: #6b7280;
    background: #f9fafb;
}

.chain-word.target-word {
    border-color: #22c55e;
    color: #16a34a;
    background: #f0fdf4;
}

/* chain arrow */
.chain-arrow {
    flex-shrink: 0;
    font-size: 0.75rem;
    color: #d1d5db;
    font-weight: 600;
}

/* ===== WIN OVERLAY ===== */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 900;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}

.overlay.active {
    opacity: 1;
    pointer-events: all;
}

.win-card {
    background: #fff;
    border-radius: 24px;
    padding: 36px 32px;
    max-width: 360px;
    width: 90%;
    text-align: center;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.18);
    transform: translateY(20px) scale(0.96);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.overlay.active .win-card {
    transform: translateY(0) scale(1);
}

.win-emoji {
    font-size: 3rem;
    margin-bottom: 8px;
}

.win-title {
    font-size: 1.6rem;
    font-weight: 900;
    color: #1a1a2e;
    margin-bottom: 20px;
}

.win-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    margin-bottom: 20px;
}

.stat-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.stat-number {
    font-size: 2.2rem;
    font-weight: 900;
    color: #4f46e5;
}

.stat-label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #9ca3af;
}

.stat-divider {
    width: 1px;
    height: 40px;
    background: #e5e7eb;
}

.win-chain-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #9ca3af;
    margin-bottom: 6px;
}

.win-chain {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin-bottom: 16px;
    padding: 12px;
    background: #f9fafb;
    border-radius: 12px;
}

.win-chain.optimal {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    margin-bottom: 24px;
}

.win-chain .chain-word {
    font-size: 0.75rem;
    padding: 5px 10px;
}

.win-chain .chain-arrow {
    font-size: 0.65rem;
    align-self: center;
}

.win-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.btn-restart {
    padding: 12px 28px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    color: #1a1a2e;
    cursor: pointer;
    transition: transform 0.12s ease, border-color 0.15s ease;
}

.btn-restart:hover {
    border-color: #4f46e5;
    transform: scale(1.04);
}

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

.btn-play-again {
    padding: 12px 28px;
    border: none;
    border-radius: 12px;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn-play-again {
    background: #4f46e5;
    color: #fff;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
}

.btn-play-again:hover {
    transform: scale(1.04);
}

.btn-play-again:active {
    transform: scale(0.96);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 420px) {
    .letter-column {
        width: 62px;
        height: 168px;
    }

    .letter {
        width: 62px;
        height: 56px;
        font-size: 2.2rem;
    }

    .letter.active {
        font-size: 2.4rem;
    }

    .letter-above,
    .letter-below {
        font-size: 1.3rem;
    }

    .wheels-row {
        gap: 8px;
    }

    .btn-check,
    .btn-reset {
        width: 48px;
        height: 48px;
    }

    .target-word {
        font-size: 1.6rem;
    }
}