:root {
    --primary: #3b82f6; /* Modern Blue */
    --primary-hover: #2563eb;
    --bg-color: #f8fafc; /* Light Grayish Blue */
    --card-bg: #ffffff;
    --text-main: #1e293b; /* Slate Dark */
    --text-light: #64748b; /* Slate Gray */
    --accent: #f59e0b; /* Amber/Orange */
    --success: #10b981; /* Emerald Green */
    --danger: #ef4444; /* Red */
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 12px;
    --font-main: 'Poppins', sans-serif;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    margin: 0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
}

#app {
    background: var(--card-bg);
    padding: 2.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 480px;
    text-align: center;
    position: relative;
    padding-bottom: 5rem;
    border: 1px solid var(--border);
}

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

.screen.active {
    display: block;
}

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

h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 1.5rem;
    letter-spacing: -0.025em;
}

h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 1rem;
}

/* Buttons & Controls */
button {
    padding: 12px 24px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: var(--primary);
    color: white;
    transition: all 0.2s ease;
    width: 100%;
    font-family: var(--font-main);
}

button:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

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

button.stats-btn {
    background: #f1f5f9;
    color: var(--text-light);
    border: 1px solid var(--border);
}

button.stats-btn:hover {
    background: #e2e8f0;
    color: var(--text-main);
    box-shadow: none;
}

input, select {
    background: #ffffff;
    color: var(--text-main);
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: var(--font-main);
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    ring: 2px solid rgba(59, 130, 246, 0.1);
}

.modes {
    display: flex;
    flex-direction: column;
    gap: 1.25rem; /* Větší mezera mezi tlačítky */
    margin-bottom: 2rem;
}

.modes button {
    padding: 16px 24px;
    font-size: 1rem;
}

.settings {
    background: #f8fafc;
    padding: 1.5rem; /* Více místa kolem dropdownu */
    border-radius: var(--radius);
    margin: 2.5rem 0; /* Větší horní i spodní odstup */
    text-align: left;
    border: 1px solid var(--border);
}

.settings label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-light);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.link-box {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.link-box input {
    font-size: 0.85rem;
    color: var(--text-light);
}

/* Game Interface */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
    padding: 0.75rem 1.25rem;
    border-radius: 50px;
    margin-bottom: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    border: 1px solid var(--border);
    font-size: 0.85rem;
}

#timer-container {
    width: 100%;
    background-color: #f1f5f9;
    height: 18px; /* O něco vyšší, aby se tam vešel text */
    border-radius: 10px;
    margin-bottom: 2rem;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border);
}

#timer-text {
    position: absolute;
    width: 100%;
    text-align: center;
    top: 0;
    left: 0;
    font-size: 0.7rem;
    font-weight: 800;
    line-height: 18px;
    color: var(--text-main);
    pointer-events: none;
}

#timer-bar {
    width: 100%;
    height: 100%;
    background: var(--primary);
}

.moves-container {
    display: flex;
    justify-content: center;
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.move-btn {
    width: 85px;
    height: 85px;
    font-size: 2.25rem;
    background: #ffffff;
    border: 2px solid var(--border);
    border-radius: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0;
}

.move-btn:hover {
    border-color: var(--primary);
    background: #eff6ff;
    transform: scale(1.05);
}

.move-btn.selected {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* Result Overlay */
#round-result {
    background: #ffffff;
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    border: 2px solid var(--primary);
    box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.1);
}

.result-display {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

#result-text {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-main);
}

#next-round-countdown {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-top: 0.5rem;
}

#queue-count-badge {
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 0.5rem;
    font-weight: 500;
}

button:hover #queue-count-badge {
    background: rgba(0, 0, 0, 0.1);
}

/* Footer */
footer {
    position: absolute;
    bottom: 1.5rem;
    left: 0;
    right: 0;
    font-size: 0.75rem;
    color: var(--text-light);
    font-weight: 500;
}

footer a {
    color: var(--text-light);
    text-decoration: none;
    transition: color 0.2s;
}

footer a:hover {
    color: var(--primary);
    text-decoration: underline;
}

#toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-main);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius);
    z-index: 3000;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    animation: toastDown 0.3s ease-out;
}

@keyframes toastDown {
    from { top: -50px; opacity: 0; }
    to { top: 20px; opacity: 1; }
}

/* Utility */
.hidden { display: none !important; }

.loader {
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 0.8s linear infinite;
    margin: 1.5rem auto;
}

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Game Footer */
.game-footer {
    display: flex;
    gap: 0.75rem;
    margin-top: 2rem;
}

.game-footer button {
    padding: 10px;
    font-size: 0.8rem;
    background: #f1f5f9;
    color: var(--text-light);
    border: 1px solid var(--border);
}

.game-footer button:hover {
    background: #e2e8f0;
    color: var(--text-main);
    box-shadow: none;
}

.game-footer #end-unlimited-btn {
    background: var(--danger);
    color: white;
    border: none;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 17, 19, 0.4);
    backdrop-filter: blur(8px);
    overflow-y: auto;
    padding-top: 2rem;
    padding-bottom: 2rem;
}

.modal-content {
    background-color: #ffffff;
    margin: auto;
    padding: 2.5rem;
    border-radius: var(--radius);
    width: 90%;
    max-width: 600px;
    position: relative;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalPop {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.close {
    position: absolute;
    right: 1.5rem;
    top: 1rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-light);
    cursor: pointer;
    transition: color 0.2s;
}

.close:hover {
    color: var(--danger);
}

.charts-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    margin-top: 2rem;
    margin-bottom: 1.5rem;
}

.chart-box {
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
}

.modal-footer {
    display: flex;
    gap: 0.5rem;
    margin-top: 2rem;
}

.modal-footer button, .modal-footer a {
    flex: 1;
    text-decoration: none;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.85rem;
}
