:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --accent-color: #fbbf24;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --lawn-green: #22c55e;
    --fence-brown: #78350f;
    --font-main: 'Outfit', sans-serif;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-main);
    margin: 0;
    padding: 0;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
}

.game-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    padding: 1rem;
    max-width: 100%;
    max-height: 100%;
}

/* Landscape Mode: Panels on Left and Right */
@media (orientation: landscape) {
    .game-layout {
        flex-direction: row;
    }
    .ui-panel {
        flex-direction: column;
        min-width: 120px;
    }
}

/* Portrait Mode: Panels on Top and Bottom */
@media (orientation: portrait) {
    .game-layout {
        flex-direction: column;
    }
    .ui-panel {
        flex-direction: row;
        width: 100%;
        justify-content: space-around;
        align-items: center;
    }
    .game-title {
        font-size: 1.5rem !important;
    }
    .stat-item .value {
        font-size: 1.2rem !important;
    }
}

.ui-panel {
    display: flex;
    gap: 1.5rem;
    background: var(--card-bg);
    padding: 1.2rem;
    border-radius: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
}

.game-title {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    background: linear-gradient(to bottom, #fbbf24, #f59e0b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin: 0;
}

.controls-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
}

.label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
    margin-bottom: 0.1rem;
    text-transform: uppercase;
}

.value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent-color);
    font-variant-numeric: tabular-nums;
}

.canvas-wrapper {
    position: relative;
    padding: 6px;
    background: var(--fence-brown);
    border-radius: 14px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3), 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

canvas {
    display: block;
    border-radius: 6px;
    background-color: var(--lawn-green);
    image-rendering: pixelated;
    max-width: 100%;
    max-height: 100%;
}

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

.value-animate {
    animation: pulse 0.2s ease-out;
}

/* UI Overlay & Modals */
.ui-btn-icon {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.2) 0%, rgba(245, 158, 11, 0.1) 100%);
    border: 2px solid var(--accent-color);
    color: var(--accent-color);
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.2), inset 0 0 10px rgba(245, 158, 11, 0.1);
    position: relative;
    overflow: hidden;
}

.ui-btn-icon:hover {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.3) 0%, rgba(245, 158, 11, 0.2) 100%);
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.3);
}

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

.pause-bars {
    display: flex;
    gap: 4px;
    width: 16px;
    height: 18px;
}

.pause-bars::before,
.pause-bars::after {
    content: '';
    display: block;
    width: 6px;
    height: 100%;
    background-color: var(--accent-color);
    border-radius: 2px;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
    transition: all 0.3s ease;
}

/* Play state (Triangle) */
.ui-btn-icon.is-paused .pause-bars {
    transform: translateX(2px);
}

.ui-btn-icon.is-paused .pause-bars::before {
    width: 0;
    height: 0;
    background: transparent;
    border-left: 14px solid var(--accent-color);
    border-top: 9px solid transparent;
    border-bottom: 9px solid transparent;
    box-shadow: none;
    border-radius: 0;
}

.ui-btn-icon.is-paused .pause-bars::after {
    opacity: 0;
    width: 0;
}

.ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: 6px;
}

.modal {
    background: linear-gradient(135deg, #451a03 0%, #78350f 100%);
    padding: 2rem;
    border-radius: 24px;
    border: 4px solid #92400e;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    text-align: center;
    max-width: 85%;
    animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal h2 {
    font-size: 1.8rem;
    margin-bottom: 0.8rem;
    color: var(--accent-color);
}

.modal p {
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.ui-btn {
    background: var(--lawn-green);
    color: #064e3b;
    border: none;
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 0 #15803d;
    text-transform: uppercase;
}

.ui-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.level-toast {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
}

.level-toast h2 {
    font-size: 2.5rem;
    color: white;
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.level-toast p {
    font-size: 1.2rem;
    color: var(--accent-color);
    font-weight: 700;
}
