:root {
    --blue: #1a5fb4;
    --blue-dark: #0b3d91;
    --blue-light: #d8e9f7;
    --white: #ffffff;
    --gray: #f4f7fb;
    --text: #1e293b;
    --radius: 1rem;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--gray);
    color: var(--text);
}

.site-header {
    background: linear-gradient(135deg, var(--blue), var(--blue-dark));
    color: var(--white);
    padding: 0.75rem 1rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.header-logo {
    flex: 1;
    text-align: center;
}

.site-logo {
    max-height: clamp(110px, 16vh, 200px);
    width: auto;
    max-width: min(720px, 85vw);
    display: block;
    margin: 0 auto;
}

.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;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
}

.menu-toggle,
.fullscreen-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 0.5rem;
    cursor: pointer;
    color: var(--white);
    flex-shrink: 0;
    transition: background 0.2s, opacity 0.2s;
}

.menu-toggle {
    flex-direction: column;
    gap: 5px;
    padding: 0 9px;
}

.fullscreen-toggle {
    font-size: 1.35rem;
    line-height: 1;
    padding: 0;
}

.menu-toggle:hover,
.fullscreen-toggle:hover {
    background: rgba(255, 255, 255, 0.35);
}

.menu-toggle span {
    display: block;
    height: 3px;
    background: var(--white);
    border-radius: 2px;
    width: 100%;
}

.fullscreen-toggle.hidden {
    display: none;
}

.game-board {
    position: relative;
    padding: 1rem;
    min-height: calc(100vh - 7rem);
}

.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, #ffffff 0%, var(--gray) 70%);
    z-index: 20;
    transition: opacity 0.4s ease;
}

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

.overlay-box {
    background: var(--white);
    padding: 2.5rem 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
    max-width: min(90%, 520px);
    width: 100%;
}

.waiting-logo {
    display: block;
    max-height: clamp(140px, 24vh, 280px);
    width: auto;
    max-width: 100%;
    margin: 0 auto 1.5rem;
}

.waiting-title {
    margin: 0 0 0.5rem;
    font-size: clamp(1.5rem, 4.5vw, 2.2rem);
    color: var(--blue-dark);
}

.waiting-text {
    margin: 0 0 1.25rem;
    font-size: 1.1rem;
    color: #55657d;
}

.waiting-dots {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin: 1.5rem 0;
}

.waiting-dots span {
    width: 12px;
    height: 12px;
    background: var(--blue);
    border-radius: 50%;
    animation: bounce 1.2s infinite ease-in-out both;
}

.waiting-dots span:nth-child(1) {
    animation-delay: 0s;
}

.waiting-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.waiting-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

.overlay-box .small {
    font-size: 0.95rem;
    color: #6b7280;
    margin: 0;
}

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

.grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: clamp(0.6rem, 1.2vw, 1.2rem);
    max-width: 1600px;
    margin: 0 auto;
    perspective: 1000px;
}

.card {
    appearance: none;
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform 0.25s ease, box-shadow 0.25s ease, opacity 0.25s ease;
    box-shadow: var(--shadow);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.card img {
    display: block;
    width: 100%;
    height: auto;
    pointer-events: none;
}

.card:hover,
.card:focus-visible {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
    outline: none;
}

.card.lowered {
    transform-origin: bottom center;
    transform: scale(0.78);
    opacity: 0.35;
    filter: grayscale(0.9);
    box-shadow: none;
}

.card.lowered:hover,
.card.lowered:focus-visible {
    opacity: 0.7;
    transform-origin: bottom center;
    transform: scale(0.86);
}

.card.winner {
    transform: scale(1.05);
    box-shadow: 0 0 0 5px #ffd700, 0 10px 30px rgba(0, 0, 0, 0.25);
    z-index: 5;
}

/* Modal */
.guess-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.guess-modal.open {
    display: flex;
}

.guess-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    animation: fadeIn 0.3s ease;
    z-index: 1;
}

.confetti {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 2;
}

.guess-content {
    position: relative;
    background: var(--white);
    border-radius: var(--radius);
    padding: 2rem;
    max-width: min(500px, 90vw);
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
    animation: popIn 0.45s cubic-bezier(0.22, 1.4, 0.36, 1);
    overflow: hidden;
    z-index: 3;
}

.guess-content img {
    display: block;
    width: 100%;
    max-width: 320px;
    margin: 0 auto 1.5rem;
    border-radius: 0.75rem;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
    animation: slideUp 0.5s ease;
}

.guess-text {
    font-size: clamp(1.6rem, 5vw, 2.4rem);
    font-weight: 800;
    margin: 0;
    color: var(--blue-dark);
}

.guess-text.correct {
    color: #2e9d4e;
}

.guess-text.wrong {
    color: #c92a2a;
}

.guess-close {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    background: none;
    border: none;
    font-size: 2rem;
    color: #6b7280;
    cursor: pointer;
    line-height: 1;
    z-index: 5;
}

.guess-close:hover {
    color: #111827;
}

/* Confetti */
.confetti {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.confetti span {
    position: absolute;
    top: -10px;
    width: 10px;
    height: 10px;
    background: var(--c, #ff0);
    animation: fall linear forwards;
    opacity: 0.9;
}

@keyframes fall {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

@keyframes popIn {
    from { opacity: 0; transform: scale(0.7); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 1200px) {
    .grid { grid-template-columns: repeat(5, 1fr); }
}

@media (max-width: 900px) {
    .grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 600px) {
    .grid { grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
    .game-board { padding: 0.5rem; }
    .guess-content { padding: 1.2rem; }
}

@media (max-width: 400px) {
    .grid { grid-template-columns: repeat(2, 1fr); }
}

.admin-body {
    background: var(--white);
}

.admin-panel {
    max-width: 800px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

.admin-section {
    background: var(--gray);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.admin-section h2 {
    margin: 0 0 1rem;
    font-size: 1.2rem;
    color: var(--blue-dark);
}

.hidden-select {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1.1rem;
    border: 2px solid var(--blue);
    border-radius: 0.6rem;
    background: var(--white);
    color: var(--text);
    margin-bottom: 1rem;
}

.preview {
    text-align: center;
    min-height: 120px;
    padding: 1rem;
    background: var(--white);
    border-radius: var(--radius);
}

.preview img {
    max-width: 160px;
    border-radius: 0.75rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.preview .placeholder {
    color: #6b7280;
    margin: 0;
    padding-top: 2rem;
}

.actions {
    text-align: center;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 0.6rem;
    padding: 0.85rem 1.6rem;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    margin: 0.35rem;
    transition: transform 0.15s, box-shadow 0.15s;
}

.btn-primary {
    background: var(--blue);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--blue-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(26, 95, 180, 0.35);
}

.btn-secondary {
    background: #e2e8f0;
    color: #1e293b;
}

.btn-secondary:hover {
    background: #cbd5e1;
}

.status {
    margin-bottom: 1rem;
}

.badge {
    display: inline-block;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.95rem;
}

.badge.active {
    background: #d1fae5;
    color: #065f46;
}

.badge.inactive {
    background: #fee2e2;
    color: #991b1b;
}

.board-link {
    display: inline-block;
    background: var(--blue-light);
    color: var(--blue-dark);
    padding: 0.75rem 1.25rem;
    border-radius: 0.6rem;
    text-decoration: none;
    font-weight: 600;
}

.hint {
    color: #55657d;
    margin-bottom: 0.75rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 360px;
    margin: 3rem auto;
}

.login-form label {
    font-weight: 600;
    color: var(--blue-dark);
}

.login-form input {
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--blue);
    border-radius: 0.6rem;
}

.login-form button {
    padding: 0.8rem 1.2rem;
    background: var(--blue);
    color: var(--white);
    border: none;
    border-radius: 0.6rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}

.teacher-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 150;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.teacher-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.teacher-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: min(100%, 420px);
    height: 100%;
    background: var(--white);
    z-index: 160;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    overflow-y: auto;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    padding: 1.5rem;
}

.teacher-panel.open {
    transform: translateX(0);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.panel-header h2 {
    margin: 0;
    font-size: 1.4rem;
    color: var(--blue-dark);
}

.panel-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: #6b7280;
    cursor: pointer;
    line-height: 1;
    padding: 0 0.25rem;
}

.panel-close:hover {
    color: #111827;
}

/* Fullscreen grid */
.game-board:fullscreen {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray);
    padding: 1rem;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

.game-board:fullscreen .grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(5, 1fr);
    gap: clamp(0.5rem, 1.2vw, 1.2rem);
    width: 100%;
    height: 100%;
    max-width: 1600px;
    margin: 0;
    place-items: center;
}

.game-board:fullscreen .card {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-board:fullscreen .card img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
