:root {
    --primary: #006400;
    --primary-hover: #004d00;
    --accent: #ff9800;
    --bg-color: #f4f4f4;
    --surface: #ffffff;
    --text-main: #333333;
    --text-muted: #666666;
    
    --board-border: #2c3e50;
    --cell-border: #dddddd;
    --cell-bg: #ffffff;
    --cell-selected: #c5e1a5;
    --cell-highlight: #dcedc8;
    --cell-same-number: #aed581;
    --cell-error: #ffcdd2;
    
    --text-given: #2c3e50;
    --text-input: #006400;
    --text-error: #e53935;
    
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

[data-theme="dark"] {
    --primary: #a8f0a8;
    --primary-hover: #81c784;
    --bg-color: #121212;
    --surface: #1e1e1e;
    --text-main: #f0f0f0;
    --text-muted: #a0a0a0;
    
    --board-border: #e0e0e0;
    --cell-border: #333333;
    --cell-bg: #1e1e1e;
    --cell-selected: #33691e;
    --cell-highlight: #558b2f;
    --cell-same-number: #1b5e20;
    --cell-error: #b71c1c;
    
    --text-given: #f0f0f0;
    --text-input: #a8f0a8;
    --text-error: #ff6b6b;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Open Sans', Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 {
    font-family: 'Montserrat', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.app-container {
    background: var(--surface);
    width: 100%;
    max-width: 500px;
    height: 100%;
    min-height: 100vh;
    margin: auto;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
    transition: var(--transition);
}

@media (min-width: 501px) {
    .app-container {
        height: 90vh;
        max-height: 850px;
        border-radius: 20px;
    }
}

header {
    background: linear-gradient(180deg, #006400 0%, #004d00 100%);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.header-btn {
    background: none;
    border: none;
    font-size: 1.3rem;
    color: #ffffff;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
}

.header-btn:hover {
    color: #a8f0a8;
    background-color: rgba(255, 255, 255, 0.1); /* Added a subtle background for hover */
    transform: scale(1.05);
}

h1 {
    font-size: 1.6rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 2px;
}
.highlight { color: var(--accent); }

main {
    flex: 1;
    position: relative;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
}

.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    height: 100%;
    width: 100%;
    animation: fadeIn 0.4s ease forwards;
}

.screen.active {
    display: flex;
}

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

/* ZAČETNI ZASLON */
.intro-text {
    text-align: center;
    margin: 3rem 0;
    font-size: 1.2rem;
    color: var(--text-muted);
}

.difficulty-options {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    width: 85%;
    max-width: 300px;
    margin: 0 auto;
}

.btn {
    padding: 1rem;
    border: 2px solid var(--primary);
    border-radius: 8px;
    background: var(--surface);
    color: var(--primary);
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    text-transform: uppercase;
    transition: var(--transition);
}

.btn:hover, .btn.primary-btn {
    background: var(--primary);
    color: var(--white);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.text-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    margin-top: 1rem;
}
.text-btn:hover {
    color: var(--text-main);
    background: none;
    box-shadow: none;
    transform: none;
}

/* IGRALNI ZASLON */
.hud {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 1.1rem;
    padding: 0 0.5rem;
}

#sudoku-board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    width: 100%;
    max-width: min(100%, 50vh, 450px);
    aspect-ratio: 1;
    border: 2px solid var(--board-border);
    margin: 0 auto;
}

.cell {
    background-color: var(--cell-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: clamp(1.2rem, 5vw, 1.8rem);
    font-weight: 500;
    cursor: pointer;
    color: var(--text-input);
    user-select: none;
    transition: background-color 0.2s ease, color 0.2s ease;
    border-right: 1px solid var(--cell-border);
    border-bottom: 1px solid var(--cell-border);
}

.cell.given { color: var(--text-given); font-weight: 700; cursor: default; }
.cell.selected { background-color: var(--cell-selected) !important; }
.cell.highlight { background-color: var(--cell-highlight); }
.cell.same-number { background-color: var(--cell-same-number); }
.cell.error { background-color: var(--cell-error); color: var(--text-error); animation: shake 0.4s; }

/* 3x3 mreža robovi */
.cell:nth-child(3n) { border-right: 2px solid var(--board-border); }
.cell:nth-child(9n) { border-right: none; }
.cell:nth-child(n+19):nth-child(-n+27),
.cell:nth-child(n+46):nth-child(-n+54) { border-bottom: 2px solid var(--board-border); }
.cell:nth-child(n+73) { border-bottom: none; }

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

.controls {
    display: flex;
    justify-content: space-around;
    width: 100%;
    margin: 0.8rem 0;
    max-width: 450px;
    align-self: center;
}

.control-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
    transition: var(--transition);
    padding: 0.4rem;
    border-radius: 8px;
}

.control-btn i { font-size: 1.3rem; color: var(--text-main); transition: var(--transition); }
.control-btn:hover { background: var(--cell-highlight); }
.control-btn:hover i { color: var(--primary); }

.numpad {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
    max-width: 450px;
    margin: 0 auto;
}

.num-btn {
    flex: 1 1 calc(11.11% - 0.4rem);
    min-width: 32px;
    background: var(--surface);
    border: 1px solid var(--cell-border);
    border-radius: 8px;
    padding: 0.6rem 0;
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.num-btn:active, .num-btn:hover { 
    background: var(--primary); 
    color: white; 
    border-color: var(--primary);
    transform: scale(0.97);
}

.num-btn.completed {
    background: var(--bg-color);
    color: var(--text-muted);
    border-color: transparent;
    opacity: 0.5;
    pointer-events: none;
    box-shadow: none;
}

/* KONEC IGRE */
.final-stats { margin: 2rem 0; font-size: 1.4rem; font-weight: 600; color: var(--text-main); }
#game-over-screen .btn { width: 80%; max-width: 300px; margin-bottom: 1rem; }

footer {
    text-align: center;
    padding: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-top: 1px solid var(--cell-border);
}
