:root {
    /* Theme: Forest Green / Premium Editorial */
    --bg-color: #FAF9F7;
    --card-bg: #FFFFFF;
    --text-primary: #1F2421;
    --text-secondary: #5C6B5E;

    /* Accents - Forest Green */
    --accent-primary: #2D5A3D;
    --accent-light: #E8F0EA;

    /* Functional */
    --success-bg: #D4EDDA;
    --success-text: #1E5631;
    --error-bg: #F8D7DA;
    --error-text: #842029;

    /* Typography */
    --font-display: 'DM Serif Display', serif;
    --font-body: 'DM Sans', sans-serif;

    /* Dimensions - Wide rectangle to reduce vertical gaps */
    --ring-width: min(94vw, 800px);
    --ring-height: calc(var(--ring-width) * 0.68);
    --slot-width: clamp(110px, calc(var(--ring-width) * 0.19), 150px);
    --slot-height: clamp(70px, calc(var(--ring-height) * 0.18), 95px);
    --pool-width: calc(var(--ring-width) * 0.50);
    --pool-height: calc(var(--ring-height) * 0.54);

    /* Shadows - The "Tactile" part */
    --shadow-rest: 0 2px 0 rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 0 rgba(0, 0, 0, 0.1);
    --shadow-active: 0 1px 0 rgba(0, 0, 0, 0.1);
    --shadow-floating: 0 8px 16px rgba(0, 0, 0, 0.1);
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    padding: 0 24px;
    position: relative;
    z-index: 1;
}

/* Header */
.game-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 16px 0;
    flex-shrink: 0;
}

.game-title {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 6vw, 3.5rem);
    font-weight: 400;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.game-tagline {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-top: 4px;
}

.icon-btn {
    width: 44px;
    height: 44px;
    background: var(--card-bg);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.1s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-rest);
}

.icon-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.icon-btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-active);
}

/* Lives */
.lives-container {
    display: flex;
    gap: 8px;
    padding: 8px 16px;
    background: var(--card-bg);
    border-radius: 20px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: var(--shadow-rest);
}

.life-pip {
    width: 14px;
    height: 14px;
    background: var(--accent-primary);
    border-radius: 50%;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.life-pip.lost {
    background: var(--accent-light);
    transform: scale(0.6);
}

/* Game Board */
.game-board {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    padding: 0;
    min-height: 0; /* Allow flex shrink */
}

.ring-container {
    position: relative;
    width: var(--ring-width);
    height: var(--ring-height);
}

/* Slots */
.slot {
    position: absolute;
    width: var(--slot-width);
    height: var(--slot-height);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: clamp(0.95rem, 2.8vw, 1.25rem);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    border-radius: 14px;
    transition: transform 0.1s, box-shadow 0.1s;
    z-index: 1;

    /* Solid Tactile Look */
    background: var(--accent-light);
    border: 2px solid transparent;
    color: var(--text-secondary);
}

.slot.empty {
    /* Inset look */
    box-shadow: inset 0 2px 4px rgba(45, 90, 61, 0.08);
}

.slot.filled {
    background: var(--card-bg);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
    box-shadow: var(--shadow-rest);
    cursor: grab;
}

.slot.filled:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
    z-index: 10;
}

.slot.filled:active {
    cursor: grabbing;
    transform: translateY(0) scale(0.98);
    /* Squash */
    box-shadow: var(--shadow-active);
}

.slot.drag-over {
    background: rgba(0, 0, 0, 0.05);
    transform: scale(1.05);
}

.slot.correct-side {
    background: var(--success-bg);
    color: var(--success-text);
    border-color: var(--success-text);
    box-shadow: var(--shadow-rest);
}

/* Pool */
.pool-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: var(--pool-width);
    height: var(--pool-height);
    z-index: 2;
}

.pool-inner {
    width: 100%;
    height: 100%;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px;
}

.pool-message {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 12px;
    opacity: 0.6;
}

.word-pool {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    width: 100%;
    padding: 0 8px;
}

.pool-word {
    padding: 14px 8px;
    background: var(--card-bg);
    border-radius: 10px;
    font-weight: 700;
    font-size: clamp(0.8rem, 2.4vw, 1rem);
    color: var(--text-primary);
    cursor: grab;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: var(--shadow-rest);
    transition: all 0.1s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 54px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.pool-word:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.pool-word:active {
    transform: translateY(0) scale(0.95);
    /* Squash */
    box-shadow: var(--shadow-active);
}

.pool-word.dragging {
    opacity: 0;
    /* Hide original, show ghost */
}

/* Submit Button */
.submit-btn {
    margin-top: 12px;
    padding: 12px 36px;
    background: var(--accent-primary);
    border: none;
    border-radius: 50px;
    color: white;
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    cursor: pointer;
    box-shadow: 0 3px 0 #1a3d28;
    transition: all 0.1s;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 0 #1a3d28;
}

.submit-btn:active {
    transform: translateY(1px);
    box-shadow: 0 2px 0 #1a3d28;
}

/* Feedback */
.feedback-message {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    font-family: var(--font-display);
    font-size: 1.3rem;
    color: var(--text-primary);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    white-space: nowrap;
}

.feedback-message:not(:empty) {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.feedback-message.success {
    color: var(--success-text);
}

.feedback-message.error {
    color: var(--error-text);
}

/* Footer */
.game-footer {
    text-align: center;
    padding: 12px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    opacity: 0.5;
    flex-shrink: 0;
}

.puzzle-number {
    font-weight: 600;
    margin-top: 4px;
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(44, 44, 44, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

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

.modal {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 48px;
    max-width: 440px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    transform: scale(0.9);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay:not(.hidden) .modal {
    transform: scale(1);
    opacity: 1;
}

.modal-title {
    font-family: var(--font-display);
    font-size: 2.5rem;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.modal-text {
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 1.1rem;
    line-height: 1.6;
}

.btn {
    padding: 14px 32px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: all 0.1s;
    font-family: var(--font-body);
    font-size: 1rem;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 4px 0 #1a3d28;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #1a3d28;
}

.btn-primary:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #1a3d28;
}

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    margin-left: 12px;
    border: 2px solid rgba(0, 0, 0, 0.1);
}

.btn-secondary:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Drag Ghost - The "Juice" */
.drag-ghost {
    position: fixed;
    pointer-events: none;
    z-index: 1000;
    padding: 14px 24px;
    background: var(--card-bg);
    color: var(--text-primary);
    border-radius: 12px;
    font-weight: 700;
    font-size: clamp(0.9rem, 2.2vw, 1.1rem);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(0, 0, 0, 0.08);
    transform: translate(-50%, -50%);
    will-change: transform, left, top;
}

/* Animations */
@keyframes pop {
    0% {
        transform: translate(-50%, -50%) scale(1);
    }

    50% {
        transform: translate(-50%, -50%) scale(1.1);
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
    }
}

.pop {
    animation: pop 0.2s cubic-bezier(0.34, 1.2, 0.64, 1);
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-6px) rotate(-2deg);
    }

    40% {
        transform: translateX(6px) rotate(2deg);
    }

    60% {
        transform: translateX(-3px);
    }

    80% {
        transform: translateX(3px);
    }
}

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

/* Header alignment */
.header-left {
    justify-self: start;
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-center {
    text-align: center;
}

.header-right {
    justify-self: end;
}

/* Slots layer */
.slots-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.slots-layer .slot {
    pointer-events: auto;
}

/* Modal extras */
.modal-icon {
    color: var(--success-text);
    margin-bottom: 20px;
}

.modal-icon.error {
    color: var(--error-text);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    border-radius: 10px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}

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

.stats-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

.stat-item {
    padding: 16px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 12px;
}

.stat-value {
    font-family: var(--font-display);
    font-size: 2rem;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-top: 4px;
}

/* Help modal */
.modal-help {
    text-align: left;
    position: relative;
}

.modal-help .modal-title {
    text-align: center;
}

.help-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.help-section h3 {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.help-section p {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-primary);
}

.help-section strong {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Start Screen */
.start-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-color);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.start-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.start-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    max-width: 400px;
    padding: 40px;
}

.start-title {
    font-family: var(--font-display);
    font-size: clamp(3rem, 10vw, 5rem);
    font-weight: 400;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}

.start-subtitle {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: 32px;
}

.start-description {
    margin-bottom: 40px;
    max-width: 320px;
}

.start-description p {
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--text-secondary);
    margin: 0;
}

.start-btn {
    padding: 18px 64px;
    background: var(--accent-primary);
    border: none;
    border-radius: 50px;
    color: white;
    font-family: var(--font-body);
    font-size: 1.1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    cursor: pointer;
    box-shadow: 0 4px 0 #1a3d28;
    transition: all 0.1s;
}

.start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #1a3d28;
}

.start-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #1a3d28;
}

.start-date {
    margin-top: 24px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    opacity: 0.6;
}

/* Timer */
.timer-display {
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Responsive - Tablet */
@media (max-width: 768px) {
    :root {
        --ring-width: min(96vw, 600px);
        --ring-height: calc(var(--ring-width) * 0.68);
        --slot-width: clamp(80px, calc(var(--ring-width) * 0.17), 110px);
        --slot-height: clamp(55px, calc(var(--ring-height) * 0.16), 75px);
        --pool-width: calc(var(--ring-width) * 0.46);
        --pool-height: calc(var(--ring-height) * 0.50);
    }
}

/* Responsive - Mobile */
@media (max-width: 600px) {
    :root {
        /* Taller slots, same width */
        --slot-width: clamp(56px, 16.5vw, 72px);
        --slot-height: clamp(48px, 13vw, 62px);
    }

    body {
        overflow: hidden;
    }

    .app-container {
        padding: 0 8px;
        height: 100vh;
        height: 100dvh;
    }

    .game-board {
        flex: 1;
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 0;
    }

    .ring-container {
        width: var(--ring-width);
        height: var(--ring-height);
        position: relative;
    }

    .slots-layer {
        position: absolute;
        inset: 0;
    }

    /* Smaller text in slots to fit */
    .slot {
        font-size: 0.65rem;
        border-radius: 8px;
    }

    /* Pool inside the ring */
    .pool-container {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: var(--pool-width);
        height: auto;
        max-height: var(--pool-height);
        padding: 0;
        z-index: 5;
    }

    .pool-inner {
        padding: 10px;
        background: var(--card-bg);
        border-radius: 12px;
        border: 1px solid rgba(0, 0, 0, 0.1);
        box-shadow: 0 2px 8px rgba(0,0,0,0.06);
        display: flex;
        flex-direction: column;
    }

    .word-pool {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 5px;
        padding: 0;
        width: 100%;
    }

    .pool-word {
        padding: 8px 4px;
        font-size: 0.7rem;
        min-height: 36px;
        border-radius: 8px;
    }

    .pool-message {
        font-size: 0.8rem;
        margin-bottom: 6px;
        font-weight: 500;
    }

    .submit-btn {
        padding: 10px 24px;
        font-size: 0.75rem;
        margin-top: 8px;
    }

    .feedback-message {
        font-size: 0.9rem;
    }

    /* Header */
    .game-header {
        display: grid;
        grid-template-columns: 50px 1fr 50px;
        grid-template-rows: auto auto;
        align-items: center;
        padding: 12px 8px 8px;
        row-gap: 12px;
    }

    .header-left {
        grid-column: 1;
        grid-row: 1;
        justify-self: start;
    }

    .header-left .timer-display {
        display: none;
    }

    .header-center {
        grid-column: 2;
        grid-row: 1;
        text-align: center;
    }

    .header-right {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-self: center;
    }

    .lives-container {
        padding: 8px 24px;
        gap: 12px;
    }

    .life-pip {
        width: 16px;
        height: 16px;
    }

    .game-title {
        font-size: 1.75rem;
    }

    .game-tagline {
        font-size: 0.7rem;
        margin-top: 2px;
        letter-spacing: 0.1em;
    }

    /* Modals */
    .modal {
        padding: 28px 20px;
        border-radius: 20px;
        width: 92%;
    }

    .modal-title {
        font-size: 1.75rem;
    }

    .modal-text {
        font-size: 1rem;
        margin-bottom: 24px;
    }

    .stats-summary {
        gap: 8px;
        margin-bottom: 24px;
    }

    .stat-item {
        padding: 12px 8px;
    }

    .stat-value {
        font-size: 1.2rem;
    }

    .stat-label {
        font-size: 0.65rem;
    }

    .btn {
        padding: 14px 24px;
        font-size: 0.9rem;
    }

    .modal-actions {
        flex-direction: column;
        gap: 10px;
    }

    .btn-secondary {
        margin-left: 0;
    }

    /* Start screen */
    .start-title {
        font-size: 2.75rem;
    }

    .start-subtitle {
        font-size: 0.8rem;
        margin-bottom: 24px;
    }

    .start-description {
        margin-bottom: 32px;
        padding: 0 16px;
    }

    .start-description p {
        font-size: 1rem;
    }

    .start-btn {
        padding: 16px 48px;
        font-size: 1rem;
    }

    .icon-btn {
        width: 44px;
        height: 44px;
    }

    .icon-btn svg {
        width: 20px;
        height: 20px;
    }

    .game-footer {
        padding: 12px 8px;
        font-size: 0.75rem;
    }

    .drag-ghost {
        padding: 14px 24px;
        font-size: 0.9rem;
        border-radius: 14px;
    }
}

/* Very small screens */
@media (max-width: 380px) {
    :root {
        --slot-width: clamp(48px, 14vw, 62px);
        --slot-height: clamp(36px, 10vw, 48px);
    }

    .game-title {
        font-size: 1.5rem;
    }

    .game-tagline {
        font-size: 0.6rem;
    }

    .slot {
        font-size: 0.65rem;
    }

    .pool-word {
        font-size: 0.8rem;
        padding: 12px 6px;
        min-height: 44px;
    }

    .word-pool {
        gap: 6px;
    }

    .submit-btn {
        padding: 12px 28px;
        font-size: 0.85rem;
    }

    .pool-message {
        font-size: 0.9rem;
    }

    .lives-container {
        padding: 6px 18px;
        gap: 10px;
    }

    .life-pip {
        width: 14px;
        height: 14px;
    }
}