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

body {
    font-family: 'Poppins', sans-serif;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.app-container {
    width: 100%;
    max-width: 500px;
    padding: 20px;
}

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

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 15px;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.best-times {
    display: flex;
    justify-content: center;
    gap: 15px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 10px 20px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.best-time-item {
    font-size: 0.9rem;
    font-weight: 600;
}

.screen {
    display: none;
    animation: fadeIn 0.4s ease-in-out;
}

.screen.active {
    display: block;
}

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

#setup-screen {
    text-align: center;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    padding: 40px;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
}

#setup-screen h2 {
    margin-bottom: 25px;
    font-weight: 600;
}

.mode-selectors {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
}

.mode-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mode-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.mode-btn.selected {
    background: #00d2ff;
    background: linear-gradient(to right, #3a7bd5, #3a6073);
    border-color: transparent;
    box-shadow: 0 5px 15px rgba(58, 123, 213, 0.4);
}

.primary-btn {
    background: linear-gradient(45deg, #ff512f, #dd2476);
    color: white;
    border: none;
    padding: 15px 40px;
    border-radius: 50px;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 20px rgba(221, 36, 118, 0.4);
}

.primary-btn:hover:not(:disabled) {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 12px 25px rgba(221, 36, 118, 0.6);
}

.primary-btn:disabled {
    background: #666;
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.5;
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    background: rgba(0, 0, 0, 0.2);
    padding: 15px 20px;
    border-radius: 16px;
}

.timer {
    font-size: 1.5rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

#board-container {
    background: rgba(255, 255, 255, 0.1);
    padding: 10px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

#board {
    display: grid;
    gap: 8px;
    width: 100%;
    aspect-ratio: 1 / 1;
    background: rgba(0, 0, 0, 0.2);
    padding: 8px;
    border-radius: 8px;
    position: relative;
}

.tile {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    font-weight: 700;
    color: white;
    cursor: pointer;
    user-select: none;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.15s ease-in-out;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.tile:active {
    transform: scale(0.95);
}

.tile.empty {
    background: transparent;
    box-shadow: none;
    cursor: default;
}

.overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 1;
    transition: opacity 0.3s ease;
}

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

.modal {
    background: white;
    color: #333;
    padding: 40px;
    border-radius: 24px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    transform: translateY(0) scale(1);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.overlay.hidden .modal {
    transform: translateY(30px) scale(0.9);
}

.modal h2 {
    font-size: 2.5rem;
    color: #2a5298;
    margin-bottom: 10px;
}

.result-time {
    font-size: 1.5rem;
    margin-bottom: 15px;
    font-weight: 600;
}

.new-record {
    color: #ff512f;
    font-weight: 700;
    font-size: 1.2rem;
    margin-bottom: 20px;
    animation: pulse 1s infinite alternate;
}

.new-record.hidden {
    display: none;
}

@keyframes pulse {
    from { transform: scale(1); }
    to { transform: scale(1.05); }
}

.result-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
}

.result-buttons .secondary-btn {
    color: #333;
    border-color: #ccc;
}

.result-buttons .secondary-btn:hover {
    background: #f0f0f0;
}
