/* ===== Word Search Game ===== */
.ws-container {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.ws-grid-wrapper {
    order: 1;
    flex: 0 0 auto;
    overflow: auto;
    touch-action: pan-y;
}

.ws-panel {
    order: 2;
    flex: 1 0 360px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ws-panel-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #64748b;
    margin-bottom: 0.25rem;
    letter-spacing: 0.05em;
}

.ws-groups-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
    grid-auto-flow: dense;
}

.ws-group {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    transition: border-left-color 0.3s;
    font-size: 0.8rem;
    cursor: default;
}


.ws-group.found {
    border-left-width: 4px;
    padding-left: calc(0.6rem - 3px);
    padding-right: 34px;
}

.ws-group.found::after {
    content: '✓';
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    font-size: 1.4rem;
    font-weight: 800;
    color: #22c55e;
}

.ws-group.found .ws-group-definition {
    text-decoration: line-through;
    color: #94a3b8;
}

.ws-group-color {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
    margin-top: 3px;
}

.ws-group-word {
    font-weight: 700;
    font-size: 0.75rem;
    margin-bottom: 2px;
}

.ws-group-definition {
    color: #64748b;
    font-size: 0.92rem;
    line-height: 1.4;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.ws-group-definition:hover:not(.blurred) {
    opacity: 0.7;
}

.ws-group-definition:focus {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

.ws-group.blurred .ws-group-definition {
    filter: blur(4px);
    transition: filter 0.4s ease;
    cursor: pointer;
}

.ws-group:not(.blurred) .ws-group-definition {
    filter: none;
    transition: filter 0.4s ease;
}

.ws-grid {
    display: inline-flex;
    flex-direction: column;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    cursor: default;
    touch-action: none;
    min-width: min-content;
}

.ws-row {
    display: flex;
}

.ws-cell {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: monospace;
    font-size: 1.5rem;
    font-weight: 900;
    border: 1px solid #f1f5f9;
    transition: background 0.1s;
}

.ws-cell.selecting {
    background: #dbeafe !important;
    color: #1d4ed8;
}

.ws-cell.found-0  { background: #fde68a; }
.ws-cell.found-1  { background: #bbf7d0; }
.ws-cell.found-2  { background: #bfdbfe; }
.ws-cell.found-3  { background: #fecaca; }
.ws-cell.found-4  { background: #ddd6fe; }
.ws-cell.found-5  { background: #fed7aa; }
.ws-cell.found-6  { background: #a5f3fc; }
.ws-cell.found-7  { background: #d9f99d; }
.ws-cell.found-8  { background: #fbcfe8; }
.ws-cell.found-9  { background: #fef08a; }
.ws-cell.found-10 { background: #99f6e4; }
.ws-cell.found-11 { background: #e0e7ff; }

.ws-counter {
    font-size: 0.85rem;
    color: #64748b;
    text-align: center;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #e2e8f0;
}

.ws-intro {
    text-align: center;
    padding: 3rem 1rem;
}

.ws-intro-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.pwc-btn-start {
    background: #6366f1;
    color: white;
    border: none;
    padding: 16px 40px;
    border-radius: 12px;
    font-weight: 800;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: inline-block;
    margin-top: 20px;
}
.pwc-btn-start:hover {
    opacity: 0.95;
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(99, 102, 241, 0.3);
}
.pwc-btn-start:active {
    transform: translateY(1px);
    box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.2);
}

@media (max-width: 900px) {
    .ws-container { flex-direction: column; }
    .ws-panel { flex: none; width: 100%; order: 2; }
    .ws-grid-wrapper { order: 1; }
    .ws-cell { width: 40px; height: 40px; font-size: 0.9rem; }
    .ws-groups-list { grid-template-columns: 1fr 1fr 1fr; }
}

@media (max-width: 600px) {
    body { padding: 0.5rem; }
    .ws-container { flex-direction: column; justify-content: flex-start; gap: 0.5rem; padding-bottom: 160px; }
    .ws-panel { display: none; }
    .ws-grid-wrapper {
        width: 100%;
        display: flex;
        justify-content: center;
        order: 1;
        overflow-x: hidden;
        overflow-y: visible;
        touch-action: manipulation;
        user-select: none;
    }
    .ws-grid {
        transform-origin: top center;
        transition: transform 0.2s ease-out;
    }
    .ws-cell {
        width: 36px !important;
        height: 36px !important;
        font-size: 1.2rem !important;
        font-weight: 900 !important;
        line-height: 1 !important;
        border: 0.5px solid #f1f5f9;
        flex-shrink: 0 !important;
        cursor: pointer;
    }
    .ws-cell.selecting {
        background: #3b82f6 !important;
        color: white;
        box-shadow: 0 0 8px rgba(59, 130, 246, 0.8);
        border-radius: 4px;
    }
    .ws-counter { display: none; }
    .ws-drawer { max-height: 50vh; }
}

    .ws-modal-content {
        max-width: calc(100vw - 2rem);
        width: calc(100vw - 2rem);
        max-height: 85vh;
    }

    .ws-modal-word {
        font-size: 1.1rem;
    }

    .ws-modal-definition {
        font-size: 16px;
    }

    .ws-modal-header {
        padding: 1.2rem;
    }

    .ws-modal-body {
        padding: 1.2rem;
    }
}

/* ===== Description Panel (Desktop) ===== */
.ws-description-panel {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    position: relative;
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ws-description-content {
    padding-right: 44px;
}

.ws-description-text {
    font-size: 0.95rem;
    line-height: 1.6;
    color: #475569;
}

.ws-description-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #64748b;
    cursor: pointer;
    padding: 0;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.2s ease;
}

.ws-description-close:hover {
    background: #e2e8f0;
}

.ws-description-close:focus {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

/* ===== Accordion (Mobile) ===== */
.ws-group-expanded {
    padding: 0.75rem 0;
    border-top: 1px solid #e2e8f0;
    margin-top: 0.5rem;
}

.ws-group-description-expanded {
    font-size: 0.85rem;
    line-height: 1.5;
    color: #475569;
}

.ws-group.accordion-open {
    background: #f0f4f8;
    grid-column: 1 / -1;
}

/* ===== Drawer (Mobile) ===== */
.ws-drawer {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 2px solid #e2e8f0;
    border-radius: 12px 12px 0 0;
    z-index: 40;
    max-height: 50vh;
    min-height: 100px;
    overflow-y: auto;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
    animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.ws-drawer-handle {
    width: 40px;
    height: 4px;
    background: #cbd5e1;
    border-radius: 2px;
    margin: 12px auto 0;
    cursor: grab;
}

.ws-drawer-handle:active {
    cursor: grabbing;
}

.ws-drawer-content {
    padding: 12px 16px;
    display: none;
    overflow-y: auto;
    max-height: calc(100% - 60px);
}

.ws-drawer-title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #64748b;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

.ws-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
}

.ws-drawer-title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #64748b;
    letter-spacing: 0.05em;
    margin: 0;
}

.ws-drawer-toggle {
    font-size: 1.2rem;
    color: #64748b;
    transition: transform 0.2s ease;
    cursor: pointer;
}

.ws-drawer-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.ws-drawer-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    transition: all 0.2s ease;
    position: relative;
    min-height: 60px;
}

.ws-drawer-item:hover {
    background: #f0f4f8;
    border-color: #cbd5e1;
}

.ws-drawer-color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
    margin-top: 2px;
}

.ws-drawer-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.ws-drawer-word {
    display: none;
}

.ws-drawer-definition {
    font-size: 1.3rem;
    color: #475569;
    line-height: 1.6;
    font-weight: 500;
}

.ws-drawer-item.found {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.ws-drawer-item.found .ws-drawer-definition {
    text-decoration: line-through;
    color: #94a3b8;
}

.ws-drawer-item.found::after {
    content: '✓';
    position: absolute;
    right: 10px;
    top: 10px;
    font-size: 1.4rem;
    font-weight: 800;
    color: #22c55e;
    animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ws-drawer-counter {
    text-align: right;
    font-size: 0.8rem;
    color: #94a3b8;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
    }
    100% {
        box-shadow: 0 0 12px 4px rgba(34, 197, 94, 0);
    }
}

@keyframes popIn {
    0% {
        transform: scale(0) rotate(-45deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

@media (max-width: 600px) {
    .ws-drawer {
        display: block;
    }
}

@media (max-width: 600px) {
    .ws-drawer {
        max-height: 50vh;
    }
    .ws-drawer-content {
        padding: 12px 16px;
    }
    .ws-drawer-list {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .ws-drawer-item {
        padding: 12px;
        min-height: 50px;
    }
    .ws-drawer-definition {
        font-size: 1.1rem;
    }
}

@media (max-width: 380px) {
    .ws-cell { width: 32px; height: 32px; font-size: 0.8rem; }
    .ws-drawer-item {
        padding: 6px 8px;
    }
    .ws-drawer-word {
        font-size: 0.75rem;
    }
    .ws-drawer-definition {
        font-size: 0.95rem;
    }
}
