/* KenKen Game Styles */

:root {
    --cage-border: #333;
    --cell-border: #aaa;
    --cell-selected: #f0f8ff;
    --cell-highlighted: #e6f2ff;
    --cell-conflict: #ffebee;
    --cell-correct: #e8f5e9;
    --cell-incorrect: #ffebee;
    --cell-hint: #fff9c4;
    --target-color: #666;
    --notes-color: #888;
    --game-bg: #f9f9f9;
    --board-bg: #fff;
    --transition-speed: 0.3s;
}

/* Game Layout */
body.fullscreen {
    overflow: hidden;
}

.game-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1rem;
    background-color: var(--game-bg);
    border-radius: var(--border-radius);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

body.fullscreen .game-container {
    max-width: 100%;
    width: 100%;
    height: 100vh;
    margin: 0;
    padding: 2rem;
    border-radius: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background-color: var(--header-bg);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

body.fullscreen .game-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.game-nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

#fullscreen-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: background-color 0.3s ease;
}

#fullscreen-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

/* Game Info Section */
.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.game-stats {
    display: flex;
    gap: 1.5rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: white;
    padding: 0.75rem 1.25rem;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.stat-item span:first-child {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.25rem;
}

.stat-item span:last-child {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
}

.game-controls {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.game-button {
    padding: 0.75rem 1.25rem;
    border: none;
    border-radius: var(--border-radius);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.game-button.primary {
    background-color: var(--primary-color);
    color: white;
}

.game-button.primary:hover {
    background-color: var(--accent-color);
}

.game-button.secondary {
    background-color: #e0e0e0;
    color: #333;
}

.game-button.secondary:hover {
    background-color: #d0d0d0;
}

.game-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.difficulty-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#difficulty-select {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
}

/* Gameplay Area */
.gameplay-area {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* KenKen Board */
.kenken-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    max-width: 500px;
    width: 100%;
    aspect-ratio: 1/1;
    border: 2px solid var(--cage-border);
    background-color: var(--board-bg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.kenken-cell {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.75rem;
    font-weight: bold;
    border: 1px solid var(--cell-border);
    background-color: white;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s ease;
}

.kenken-cell:focus {
    outline: none;
}

.kenken-cell.selected {
    background-color: var(--cell-selected);
    z-index: 1;
}

.kenken-cell.highlighted {
    background-color: var(--cell-highlighted);
}

.kenken-cell.conflict {
    background-color: var(--cell-conflict);
}

.kenken-cell.correct {
    background-color: var(--cell-correct);
}

.kenken-cell.incorrect {
    background-color: var(--cell-incorrect);
}

.kenken-cell.hint {
    background-color: var(--cell-hint);
}

.cage {
    position: relative;
}

.cage-border-top {
    border-top: 2px solid var(--cage-border);
}

.cage-border-right {
    border-right: 2px solid var(--cage-border);
}

.cage-border-bottom {
    border-bottom: 2px solid var(--cage-border);
}

.cage-border-left {
    border-left: 2px solid var(--cage-border);
}

.cage-target {
    position: absolute;
    top: 2px;
    left: 2px;
    font-size: 0.75rem;
    font-weight: normal;
    color: var(--target-color);
    z-index: 2;
}

.cell-value {
    font-size: 1.75rem;
    font-weight: bold;
}

.cell-notes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 90%;
    height: 90%;
    font-size: 0.7rem;
    color: var(--notes-color);
}

.cell-note {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Input Panel */
.input-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 300px;
    width: 100%;
}

.number-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.number-btn {
    padding: 1rem 0;
    font-size: 1.25rem;
    font-weight: bold;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s ease;
}

.number-btn:hover {
    background-color: var(--cell-highlighted);
}

.number-btn:active {
    transform: scale(0.95);
}

.action-buttons {
    display: flex;
    justify-content: space-around;
    margin-top: 0.5rem;
}

.action-button {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 60px;
    height: 60px;
    font-size: 1.5rem;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-button:hover {
    background-color: var(--cell-highlighted);
}

.action-button:active {
    transform: scale(0.95);
}

.action-button.active {
    background-color: var(--primary-color);
    color: white;
}

/* Game Tutorial */
.game-tutorial {
    max-width: 800px;
    margin: 0 auto 2rem;
    padding: 1.5rem;
    background-color: white;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.game-tutorial h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
}

.instructions-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.instruction-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.instruction-number {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 2rem;
    height: 2rem;
    background-color: var(--primary-color);
    color: white;
    font-weight: bold;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Game Message (Victory/Game Over) */
.game-message {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.4s ease-in-out;
}

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

.message-content {
    background-color: white;
    border-radius: var(--border-radius);
    padding: 2rem;
    text-align: center;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    animation: pop-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes pop-in {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.message-content h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.message-stats {
    margin: 1.5rem 0;
    font-size: 1.2rem;
}

.message-stats p {
    margin: 0.5rem 0;
}

.message-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* Footer */
.game-footer {
    text-align: center;
    padding: 2rem;
    margin-top: 2rem;
    background-color: var(--footer-bg);
    color: var(--footer-text);
}

body.fullscreen .game-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    margin-top: 0;
    padding: 1rem;
}

/* Board size variations */
.kenken-board.size-3 {
    grid-template-columns: repeat(3, 1fr);
    font-size: 2rem;
}

.kenken-board.size-4 {
    grid-template-columns: repeat(4, 1fr);
}

.kenken-board.size-5 {
    grid-template-columns: repeat(5, 1fr);
}

.kenken-board.size-6 {
    grid-template-columns: repeat(6, 1fr);
    font-size: 1.5rem;
}

/* Responsive Adjustments */
@media (max-width: 900px) {
    .gameplay-area {
        flex-direction: column;
        align-items: center;
    }
    
    .input-panel {
        max-width: 500px;
    }
    
    .number-pad {
        grid-template-columns: repeat(6, 1fr);
    }
}

@media (max-width: 768px) {
    .game-info {
        flex-direction: column;
        align-items: stretch;
    }
    
    .game-stats {
        justify-content: space-between;
    }
    
    .kenken-board {
        max-width: 100%;
    }
    
    .number-pad {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 480px) {
    .game-header {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
    
    .stat-item {
        padding: 0.5rem 1rem;
    }
    
    .stat-item span:last-child {
        font-size: 1.25rem;
    }
    
    .kenken-board.size-6 .kenken-cell {
        font-size: 1.25rem;
    }
    
    .kenken-board.size-6 .cage-target {
        font-size: 0.6rem;
    }
    
    .instruction-item {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
}

/* Accessibility */
.kenken-cell:focus {
    outline: 3px solid var(--primary-color);
}

.kenken-cell:focus:not(:focus-visible) {
    outline: none;
}

/* Animations */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.pulse-animation {
    animation: pulse 0.5s ease-in-out;
}

.victory-cell {
    animation: correct-match 0.5s ease-in-out;
}

@keyframes correct-match {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --cage-border: #555;
        --cell-border: #444;
        --cell-selected: #1a3f5f;
        --cell-highlighted: #1c394f;
        --cell-conflict: #4f2020;
        --cell-correct: #1e3e2e;
        --cell-incorrect: #4f2020;
        --cell-hint: #4b4a30;
        --target-color: #aaa;
        --notes-color: #999;
        --game-bg: #222;
        --board-bg: #333;
    }
    
    .kenken-cell {
        background-color: #333;
        color: #eee;
    }
    
    .stat-item, .game-tutorial, .number-btn, .action-button {
        background-color: #333;
        color: #eee;
    }
    
    .message-content {
        background-color: #333;
        color: #eee;
    }
    
    .game-button.secondary {
        background-color: #444;
        color: #eee;
    }
    
    .game-button.secondary:hover {
        background-color: #555;
    }
}
