* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Quicksand', sans-serif;
    background: #fdf6e3;
    color: #4a4a4a;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px;
}

header {
    text-align: center;
    margin-bottom: 60px;
}

h1 {
    font-weight: 700;
    font-size: 3rem;
    margin-bottom: 10px;
    color: #5e5e5e;
}

.subtitle {
    font-size: 1.2rem;
    color: #7a7a7a;
}



.game-card {
    background: white;
    border: 3px solid #a0a0a0;
    border-radius: 20px;
    padding: 40px 30px;
    flex: 1 1 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.game-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
    border-color: #ff6b6b;
}

.game-card h2 {
    font-weight: 700;
    font-size: 1.8rem;
    margin-bottom: 15px;
    color: #5e5e5e;
}

.game-card p {
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 25px;
    color: #6a6a6a;
}

.play-icon {
    font-size: 2rem;
    font-weight: 700;
    color: #ff6b6b;
    transition: transform 0.3s ease;
}

.game-card:hover .play-icon {
    transform: translateX(10px);
}

#gameContainer {
    display: none;
    width: 100%;
    max-width: 1000px;
    flex-direction: column;
    align-items: center;
}

#gameContainer.visible {
    display: flex !important;
}

#liquidSortContainer {
    display: none;
}

#liquidSortContainer.visible {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 100%;
}

.game-board {
    display: flex;
    gap: 30px;
    align-items: flex-end;
    justify-content: center;
    flex-wrap: wrap;
}

#gameSelector {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    justify-content: center;
    max-width: 1200px;
    width: 100%;
}

#gameSelector.hidden {
    display: none;
}

.back-btn {
    margin-bottom: 30px;
    padding: 10px 25px;
    font-size: 1rem;
    border: 2px solid #ff6b6b;
    border-radius: 25px;
    background: white;
    color: #ff6b6b;
    cursor: pointer;
    font-family: 'Quicksand', sans-serif;
    transition: all 0.2s ease;
}

.back-btn:hover {
    background: #ff6b6b;
    color: white;
    transform: translateY(-2px);
}

.controls {
    display: flex;
    gap: 15px;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

button, select {
    font-family: 'Quicksand', sans-serif;
    font-size: 1rem;
    padding: 10px 20px;
    border: 2px solid #ff6b6b;
    border-radius: 25px;
    background: white;
    color: #ff6b6b;
    cursor: pointer;
    transition: all 0.2s ease;
}

button:hover, select:hover {
    background: #ff6b6b;
    color: white;
    transform: translateY(-2px);
}

button:active {
    transform: translateY(0);
}

.center-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.target-indicator {
    font-size: 1.2rem;
    font-weight: 700;
    color: #4a4a4a;
}

.target-color-preview {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.center-glass {
    width: 80px;
    height: 220px;
    border: 4px solid #a0a0a0;
    border-radius: 0 0 25px 25px;
    background: rgba(255, 255, 255, 0.3);
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column-reverse;
    transition: transform 0.6s ease;
}

.center-glass::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 8px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 25px 25px 0 0;
}

.glass-column {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-end;
    justify-content: center;
    max-width: 140px;
}

.glass {
    width: 60px;
    height: 160px;
    border: 4px solid #a0a0a0;
    border-radius: 0 0 20px 20px;
    background: rgba(255, 255, 255, 0.3);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.6s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column-reverse;
}

.glass:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.glass.selected {
    border-color: #ff6b6b;
    box-shadow: 0 0 0 4px rgba(255, 107, 107, 0.3);
    transform: scale(1.05);
}

.glass.pouring {
    animation: pourSource 1.2s ease-in-out;
    animation-delay: 0.4s;
    position: absolute;
    z-index: 100;
}

.glass.receiving {
    transform: translateY(-50px);
}

.center-glass.receiving {
    transform: none;
}

@keyframes pourSource {
    0% { transform: rotate(0) translateY(-30px) translateX(0); }
    50% { transform: rotate(-40deg) translateY(-30px) translateX(50px); }
    100% { transform: rotate(-40deg) translateY(-30px) translateX(50px); }
}

.glass::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 20px 20px 0 0;
}

.liquid {
    width: 100%;
    transition: height 0.4s ease-in-out, background-color 0.3s ease;
    border-top: 1px solid rgba(255, 255, 255, 0.3);
}

.glass-content {
    display: flex;
    flex-direction: column-reverse;
    width: 100%;
    height: 100%;
}

.info-panel {
    text-align: center;
    margin-top: 20px;
    font-size: 1.1rem;
    color: #4a4a4a;
}

@keyframes confetti {
    0% { transform: translate(0, 0) rotate(0deg); opacity: 1; }
    100% { transform: translate(100px, 200px) rotate(720deg); opacity: 0; }
}

.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    top: -20px;
    z-index: 1000;
    animation: confetti 1.5s ease-out forwards;
}

.win-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

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

.win-message {
    font-size: 3rem;
    font-weight: 700;
    color: #ff6b6b;
    margin-bottom: 20px;
    text-align: center;
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

#tictactoeContainer {
    display: none;
    width: 100%;
}

#tictactoeContainer.visible {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
}

.ttt-mode-btn.active {
    background: #ff6b6b;
    color: white;
    border-color: #ff6b6b;
}

.ttt-status {
    font-size: 1.4rem;
    font-weight: 700;
    color: #5e5e5e;
    min-height: 2rem;
    text-align: center;
}

.ttt-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    width: min(360px, 80vw);
}

.ttt-cell {
    aspect-ratio: 1;
    background: white;
    border-radius: 18px;
    border: 3px solid #e0e0d8;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(2rem, 11vw, 3.8rem);
    font-weight: 700;
    font-family: 'Quicksand', sans-serif;
    transition: background-color 0.1s ease, border-color 0.1s ease, transform 0.1s ease;
    user-select: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.07);
}

.ttt-cell.clickable {
    cursor: pointer;
}

.ttt-cell.clickable:hover {
    border-color: #ff6b6b;
    background: rgba(255, 107, 107, 0.05);
    transform: scale(1.04);
}

.ttt-cell.x { color: #ff6b6b; border-color: #ff6b6b; }
.ttt-cell.o { color: #4ecdc4; border-color: #4ecdc4; }

.ttt-cell.winner {
    background: rgba(255, 230, 109, 0.45);
    border-color: #e8c83a;
}

#twozerofoureightContainer {
    display: none;
    width: 100%;
}

#twozerofoureightContainer.visible {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.tfe-score-group {
    display: flex;
    gap: 10px;
}

.tfe-score-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #bbada0;
    border-radius: 6px;
    padding: 6px 16px;
    min-width: 70px;
}

.tfe-score-label {
    font-size: 0.65rem;
    font-weight: 700;
    color: #eee4da;
    letter-spacing: 0.08em;
}

.tfe-score-val {
    font-size: 1.3rem;
    font-weight: 700;
    color: white;
}

.tfe-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 10px;
    background: #bbada0;
    border-radius: 8px;
    padding: 10px;
    width: min(420px, 92vw);
    aspect-ratio: 1 / 1;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
    touch-action: none;
}

.tfe-cell {
    background: rgba(238, 228, 218, 0.35);
    border-radius: 6px;
}

.tfe-tile {
    position: absolute;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Quicksand', sans-serif;
    font-weight: 700;
    font-size: clamp(1rem, 5vw, 2rem);
    color: #776e65;
    transition: left 0.12s ease, top 0.12s ease;
    z-index: 2;
    user-select: none;
}

@keyframes tfe-pop {
    0%   { transform: scale(0); }
    60%  { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes tfe-merge-pop {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.tfe-tile-new   { animation: tfe-pop 0.18s ease; }
.tfe-tile-merge { animation: tfe-merge-pop 0.18s ease; }

.tfe-2    { background: #eee4da; }
.tfe-4    { background: #ede0c8; }
.tfe-8    { background: #f2b179; color: #f9f6f2; }
.tfe-16   { background: #f59563; color: #f9f6f2; }
.tfe-32   { background: #f67c5f; color: #f9f6f2; }
.tfe-64   { background: #f65e3b; color: #f9f6f2; }
.tfe-128  { background: #edcf72; color: #f9f6f2; font-size: clamp(0.85rem, 4.5vw, 1.7rem); }
.tfe-256  { background: #edcc61; color: #f9f6f2; font-size: clamp(0.85rem, 4.5vw, 1.7rem); }
.tfe-512  { background: #edc850; color: #f9f6f2; font-size: clamp(0.85rem, 4.5vw, 1.7rem); }
.tfe-1024 { background: #edc53f; color: #f9f6f2; font-size: clamp(0.7rem, 3.5vw, 1.4rem); }
.tfe-2048 { background: #edc22e; color: #f9f6f2; font-size: clamp(0.7rem, 3.5vw, 1.4rem); }

.tfe-over-overlay {
    position: absolute;
    inset: 0;
    background: rgba(238, 228, 218, 0.73);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tfe-over-msg {
    font-size: 2.5rem;
    font-weight: 700;
    color: #776e65;
}

.tfe-hint {
    font-size: 0.95rem;
    color: #9a9a9a;
    text-align: center;
}

#sudokuContainer {
    display: none;
    width: 100%;
}

#sudokuContainer.visible {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.sudoku-status {
    display: flex;
    gap: 30px;
    font-size: 1.1rem;
    font-weight: 700;
    color: #5e5e5e;
}

.sudoku-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    border: 3px solid #5e5e5e;
    width: min(450px, 90vw);
    aspect-ratio: 1 / 1;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    overflow: hidden;
}

.sudoku-cell {
    border-right: 1px solid #d0d0d0;
    border-bottom: 1px solid #d0d0d0;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: clamp(0.85rem, 2.5vw, 1.3rem);
    font-weight: 700;
    font-family: 'Quicksand', sans-serif;
    transition: background-color 0.1s ease;
    user-select: none;
}

.sudoku-cell.box-border-right  { border-right:  2px solid #5e5e5e; }
.sudoku-cell.box-border-bottom { border-bottom: 2px solid #5e5e5e; }

.sudoku-cell.given      { color: #2a2a2a; background: #f0f0ea; }
.sudoku-cell.filled     { color: #4ecdc4; }
.sudoku-cell.error      { color: #ff6b6b; }

.sudoku-cell.selected    { background: rgba(255, 107, 107, 0.28) !important; }
.sudoku-cell.highlighted { background: rgba(255, 107, 107, 0.07) !important; }
.sudoku-cell.same-number { background: rgba(255, 107, 107, 0.18) !important; }

.notes-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
    height: 100%;
    padding: 1px;
}

.notes-grid span {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(0.3rem, 0.9vw, 0.48rem);
    font-weight: 600;
    color: #7a7a7a;
    line-height: 1;
}

.sudoku-numpad {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    width: min(450px, 90vw);
}

.num-btn {
    font-family: 'Quicksand', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    padding: 12px 8px;
    border: 2px solid #d0d0d0;
    border-radius: 10px;
    background: white;
    color: #4a4a4a;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.num-btn:hover {
    background: #ff6b6b;
    color: white;
    border-color: #ff6b6b;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(255, 107, 107, 0.3);
}

.num-btn:active { transform: translateY(0); }

.erase-btn {
    border-color: #ff6b6b;
    color: #ff6b6b;
}

.notes-active {
    background: #4ecdc4 !important;
    color: white !important;
    border-color: #4ecdc4 !important;
}

@media (max-width: 768px) {
    .glass {
        width: 50px;
        height: 140px;
    }
    
    .center-glass {
        width: 70px;
        height: 200px;
    }
    
    h1 { font-size: 2rem; }
}

@media (max-width: 480px) {
    .glass.pouring {
        transform: rotate(-35deg) translateY(-25px) translateX(40px);
    }
    
    .glass.receiving {
        transform: translateY(-40px);
    }
    
    .center-glass.receiving {
        transform: none;
    }
}
