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

body {
    font-family: 'Jersey 10', 'Press Start 2P', cursive;
    background: #0a0a12;
    overflow: hidden;
    color: #fff;
}

/* Warm overlay for UI elements to match shader aesthetic */
#game-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 50%, rgba(20, 10, 5, 0.15) 100%);
    z-index: 5;
}

#game-container {
    width: 100vw;
    height: 100vh;
    position: relative;
}

#scene-container {
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
}

#scene-container canvas {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: radial-gradient(ellipse at center, #2a2a1a 0%, #12100a 70%);
    z-index: 100;
}

.hidden {
    display: none !important;
}

/* Start Screen */
.title-container {
    text-align: center;
    margin-bottom: 2rem;
}

.ascii-title {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(0.25rem, 1.2vw, 0.6rem);
    color: #8fd98a;
    text-shadow: 2px 2px 0 #2a4a28;
    letter-spacing: 0;
    line-height: 1.1;
    white-space: pre;
    image-rendering: pixelated;
    margin: 0;
}

.game-title {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(2rem, 8vw, 5rem);
    color: #8fd98a;
    text-shadow: 4px 4px 0 #2a4a28;
    letter-spacing: 0.1em;
    image-rendering: pixelated;
}

.player-inputs {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    justify-content: center;
}

.input-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.input-group label {
    font-size: 1.3rem;
    font-weight: bold;
    font-family: 'Press Start 2P', monospace;
}

.input-group input {
    padding: 0.8rem 1.2rem;
    font-size: 1.1rem;
    font-family: 'Press Start 2P', monospace;
    background: #000;
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-radius: 0;
    color: #fff;
    text-align: center;
    width: 180px;
    transition: none;
}

.input-group input:focus {
    outline: none;
    border-color: #4ade80;
    background: #111;
}

.arcade-btn {
    padding: 1rem 3rem;
    font-size: 1.3rem;
    font-family: 'Press Start 2P', monospace;
    background: #5a8a50;
    border: 4px solid #8fd98a;
    border-bottom-color: #2a3a22;
    border-right-color: #2a3a22;
    border-radius: 0;
    color: #fff;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    box-shadow: 4px 4px 0 #000;
    transition: none;
    image-rendering: pixelated;
}

.arcade-btn:hover {
    transform: none;
    background: #6a9a60;
}

.arcade-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 #000;
}

.arcade-btn.secondary {
    background: #475569;
    border-color: #94a3b8;
    border-bottom-color: #1e293b;
    border-right-color: #1e293b;
    box-shadow: 4px 4px 0 #000;
}

.rules-hint {
    display: none;
}

.rules-btn-small {
    margin-top: 1rem;
    padding: 0.6rem 1.5rem !important;
    font-size: 0.8rem !important;
}



/* Rules Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: linear-gradient(180deg, #1a1a12 0%, #0d0d08 100%);
    border: 4px solid #4a6a40;
    border-radius: 4px;
    max-width: 700px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 2rem;
    position: relative;
    box-shadow: 
        0 0 0 2px #000,
        0 0 40px rgba(74, 106, 64, 0.3),
        inset 0 0 100px rgba(0, 0, 0, 0.5);
    animation: modalIn 0.3s ease-out;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 2rem;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
}

.modal-close:hover {
    color: #ef4444;
    transform: scale(1.2);
}

.rules-title {
    font-family: 'Jersey 10', cursive;
    font-size: 1.5rem;
    color: #8fd98a;
    text-align: center;
    margin-bottom: 1.5rem;
    text-shadow: 2px 2px 0 #2a4a28;
}

.rules-section {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-left: 3px solid #4ade80;
    border-radius: 0 4px 4px 0;
}

.rules-section h3 {
    font-family: 'Jersey 10', cursive;
    font-size: 1rem;
    color: #e8c87a;
    margin-bottom: 0.8rem;
    letter-spacing: 0.05em;
}

.rules-section p {
    font-family: 'Jersey 10', sans-serif;
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.5;
    letter-spacing: 0.05em;
}

.rules-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.rules-section li {
    font-family: 'Jersey 10', sans-serif;
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.85);
    padding: 0.4rem 0;
    padding-left: 1.5rem;
    position: relative;
    letter-spacing: 0.05em;
    line-height: 1.4;
}

.rules-section li::before {
    content: '▸';
    position: absolute;
    left: 0;
    color: #4ade80;
}

.rules-section li strong {
    color: #fbbf24;
}

.solid-icon {
    color: #ffd700;
    font-size: 1.2em;
}

.stripe-icon {
    color: #3b82f6;
    font-size: 1.2em;
}

.foul-penalty {
    margin-top: 0.8rem;
    padding: 0.5rem;
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.5);
    border-radius: 4px;
    color: #fca5a5 !important;
    text-align: center;
}

.rules-footer {
    text-align: center;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.7rem;
}

/* Graphics Modal */
.graphics-content {
    max-width: 400px;
    padding: 1.5rem 2rem;
}

.graphics-title {
    font-family: 'Jersey 10', cursive;
    font-size: 1.5rem;
    color: #8fd98a;
    text-align: center;
    margin-bottom: 1.5rem;
    text-shadow: 2px 2px 0 #2a4a28;
}

.graphics-section {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.graphics-option {
    padding: 0.8rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-left: 3px solid #4ade80;
    border-radius: 0 4px 4px 0;
}

/* Toggle Switch */
.toggle-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-family: 'Jersey 10', sans-serif;
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.9);
}

.toggle-label input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-slider {
    position: relative;
    width: 50px;
    height: 26px;
    background: #333;
    border: 2px solid #555;
    border-radius: 0;
    transition: background 0.2s;
    box-shadow: inset 2px 2px 0 rgba(0,0,0,0.3);
}

.toggle-slider::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background: #888;
    border: 2px solid #aaa;
    top: 2px;
    left: 2px;
    transition: transform 0.2s, background 0.2s;
    box-shadow: 2px 2px 0 rgba(0,0,0,0.3);
}

.toggle-label input:checked + .toggle-slider {
    background: #2a5a2a;
    border-color: #4ade80;
}

.toggle-label input:checked + .toggle-slider::after {
    transform: translateX(24px);
    background: #4ade80;
    border-color: #8fd98a;
}

/* Slider */
.slider-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'Jersey 10', sans-serif;
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 0.5rem;
}

.slider-value {
    background: #000;
    padding: 0.2rem 0.6rem;
    border: 2px solid #555;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.7rem;
    color: #4ade80;
}

.graphics-slider {
    width: 100%;
    height: 20px;
    -webkit-appearance: none;
    appearance: none;
    background: #222;
    border: 2px solid #555;
    border-radius: 0;
    outline: none;
    cursor: pointer;
}

.graphics-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 24px;
    background: #4ade80;
    border: 2px solid #8fd98a;
    border-radius: 0;
    cursor: pointer;
    box-shadow: 2px 2px 0 rgba(0,0,0,0.5);
}

.graphics-slider::-moz-range-thumb {
    width: 16px;
    height: 24px;
    background: #4ade80;
    border: 2px solid #8fd98a;
    border-radius: 0;
    cursor: pointer;
    box-shadow: 2px 2px 0 rgba(0,0,0,0.5);
}

.graphics-option.disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* Select dropdown styling */
.select-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'Jersey 10', sans-serif;
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.9);
}

.graphics-select {
    background: #000;
    color: #4ade80;
    border: 2px solid #555;
    border-radius: 0;
    padding: 0.4rem 0.8rem;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.6rem;
    cursor: pointer;
    outline: none;
    min-width: 80px;
    text-align: center;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8'%3E%3Cpath fill='%234ade80' d='M0 2l4 4 4-4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 24px;
}

.graphics-select:hover {
    border-color: #4ade80;
}

.graphics-select:focus {
    border-color: #4ade80;
    box-shadow: 0 0 0 1px #4ade80;
}

.graphics-select option {
    background: #111;
    color: #4ade80;
    padding: 0.5rem;
}

.graphics-footer {
    text-align: center;
    padding-top: 1rem;
    margin-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.8rem;
    font-family: 'Jersey 10', sans-serif;
}

/* Scrollbar styling for rules */
.rules-content::-webkit-scrollbar {
    width: 8px;
}

.rules-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

.rules-content::-webkit-scrollbar-thumb {
    background: #4a6a40;
    border-radius: 4px;
}

.rules-content::-webkit-scrollbar-thumb:hover {
    background: #5a8a50;
}

/* Game UI */
#game-ui {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

#top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.9) 0%, transparent 100%);
    image-rendering: pixelated;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #111;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5);
    transition: all 0.1s steps(3);
    opacity: 0.6;
}

.player-info.active {
    opacity: 1;
    background: #222;
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.02);
}

.player-name {
    font-weight: bold;
    font-size: 2rem;
}

.ball-icons {
    margin-left: 0.5rem;
}

.ball-type {
    font-size: 1.5rem;
    padding: 0.2rem 0.5rem;
    border-radius: 0;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
    white-space: nowrap;
}

.ball-type.solids-type {
    color: #ffd700;
    border-color: rgba(255, 215, 0, 0.4);
    text-shadow: 1px 1px 0 #000;
}

.ball-type.stripes-type {
    color: #60a5fa;
    border-color: rgba(96, 165, 250, 0.4);
    text-shadow: 1px 1px 0 #000;
}

.ball-type.open-type {
    color: rgba(255, 255, 255, 0.5);
    font-style: italic;
}

.ball-type .remaining-count {
    opacity: 0.7;
    font-size: 1.5rem; /* Match SOLIDS/STRIPES text size */
}

@media (max-width: 768px) {
    .ball-type .remaining-count {
        font-size: 1.3rem; /* 2x bigger on mobile */
    }
}

#turn-display {
    text-align: center;
}

#current-turn {
    font-family: 'Jersey 10', cursive;
    font-size: 2.2rem;
    font-weight: bold;
    letter-spacing: 0.1em;
    padding: 0.5rem 1.5rem;
    background: #000;
    border: 2px solid #4ade80;
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.5);
    text-shadow: 2px 2px 0 #000;
}

#current-turn.p1-turn { color: #ef4444; }
#current-turn.p2-turn { color: #3b82f6; }

#power-meter {
    position: absolute;
    right: 2rem;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 200px;
    background: #000;
    border: 3px solid #555;
    box-shadow: 
        inset 0 0 0 2px #222,
        4px 4px 0 rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

#power-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: #4ade80;
    transition: height 0.02s steps(20), background-color 0.1s steps(5);
    box-shadow: inset -2px 0 0 rgba(0, 0, 0, 0.3);
}

#power-label {
    position: absolute;
    bottom: -28px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.75rem;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.6);
    white-space: nowrap;
    text-shadow: 1px 1px 0 #000;
    letter-spacing: 0.1em;
}

/* Crosshair - Pixel Style */
#crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 15;
    image-rendering: pixelated;
}

.crosshair-dot {
    width: 4px;
    height: 4px;
    background: #fff;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 
        0 0 0 1px #000,
        0 -8px 0 #fff,
        0 8px 0 #fff,
        -8px 0 0 #fff,
        8px 0 0 #fff,
        0 -9px 0 #000,
        0 9px 0 #000,
        -9px 0 0 #000,
        9px 0 0 #000;
}

.crosshair-ring {
    width: 24px;
    height: 24px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
}

.crosshair-ring::before,
.crosshair-ring::after {
    content: '';
    position: absolute;
    background: rgba(255, 255, 255, 0.6);
}

.crosshair-ring::before {
    width: 10px;
    height: 2px;
    top: 50%;
    left: -14px;
    transform: translateY(-50%);
    box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.5);
}

.crosshair-ring::after {
    width: 10px;
    height: 2px;
    top: 50%;
    right: -14px;
    transform: translateY(-50%);
    box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.5);
}

#game-ui.top-view #crosshair {
    display: none;
}

#controls-hint {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    background: #000;
    border: 2px solid rgba(255, 255, 255, 0.2);
    padding: 0.5rem 1rem;
    text-align: center;
    line-height: 1.5;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5);
    text-shadow: 1px 1px 0 #000;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#controls-hint.hints-hidden {
    opacity: 0;
    visibility: hidden;
}

/* Mobile hint inside mobile-controls */
#controls-hint-mobile {
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.5);
    background: #000;
    border: 2px solid rgba(255, 255, 255, 0.2);
    padding: 0.3rem 0.6rem;
    text-align: center;
    line-height: 1.4;
    box-shadow: 2px 2px 0 #000;
    text-shadow: 1px 1px 0 #000;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    display: none;
    min-height: 24px;
    order: 3;
}

#controls-hint-mobile.hints-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Mobile power meter inside mobile-controls */
#power-meter-mobile {
    display: none;
    order: 1;
    position: relative;
    height: 14px;
    width: 130px;
    background: #000;
    border: 3px solid #888;
    border-bottom-color: #333;
    border-right-color: #333;
    box-shadow: 
        3px 3px 0 #000,
        inset 0 0 0 2px #000;
    image-rendering: pixelated;
}

#power-fill-mobile {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0%;
    height: 100%;
    background: #4ade80;
    transition: width 0.02s steps(20), background-color 0.1s steps(5);
    box-shadow: inset -2px 0 0 rgba(0, 0, 0, 0.3);
}

#power-label-mobile {
    position: absolute;
    top: -16px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.6rem;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.6);
    white-space: nowrap;
    text-shadow: 1px 1px 0 #000;
    letter-spacing: 0.1em;
}

#message-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #000;
    padding: 1rem 2rem;
    border: 4px solid #4ade80;
    box-shadow: 
        inset 0 0 0 2px #000,
        inset 0 0 0 4px #2a6a30,
        8px 8px 0 rgba(0, 0, 0, 0.5);
    animation: messageIn 0.2s steps(4);
    image-rendering: pixelated;
}

@keyframes messageIn {
    from { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

#message-text {
    font-family: 'Jersey 10', cursive;
    font-size: 1.3rem;
    font-weight: bold;
    color: #4ade80;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-shadow: 2px 2px 0 #000;
    image-rendering: pixelated;
}

/* Ball pocketed notifications - centered on screen */
.ball-pocketed-notification {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    display: flex;
    align-items: center;
    gap: 12px;
    background: #000;
    border: 3px solid #ffd700;
    padding: 12px 20px;
    box-shadow: 
        inset 0 0 0 2px #000,
        inset 0 0 0 3px #8a6a00,
        6px 6px 0 rgba(0, 0, 0, 0.6);
    opacity: 0;
    transition: transform 0.2s steps(5), opacity 0.15s steps(3);
    z-index: 100;
    image-rendering: pixelated;
}

.ball-pocketed-notification.show {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

/* Stack multiple notifications vertically from center */
.ball-pocketed-notification:nth-child(2) { top: calc(50% + 70px); }
.ball-pocketed-notification:nth-child(3) { top: calc(50% + 140px); }
.ball-pocketed-notification:nth-child(4) { top: calc(50% + 210px); }

.pocketed-ball-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Jersey 10', cursive;
    font-size: 20px;
    font-weight: bold;
    color: #000;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: inset -2px -2px 0 rgba(0, 0, 0, 0.3), 2px 2px 0 rgba(0, 0, 0, 0.5);
    position: relative;
    text-shadow: none;
}

.pocketed-ball-icon .stripe-mark {
    position: absolute;
    width: 100%;
    height: 8px;
    background: #fff;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    border-radius: 0;
    opacity: 0.9;
}

.pocketed-text {
    font-family: 'Jersey 10', cursive;
    font-size: 24px;
    font-weight: bold;
    color: #ffd700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-shadow: 2px 2px 0 #000;
}

/* Game Over Screen */
#game-over-screen {
    background: radial-gradient(ellipse at center, #2a2a1a 0%, #12100a 70%);
}

.winner-title {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(1.6rem, 6vw, 3.1rem);
    color: #e8c87a;
    text-shadow: 4px 4px 0 #8a6a30;
    margin-bottom: 2rem;
    animation: winnerPulse 1s ease-in-out infinite;
}

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

.final-stats {
    background: rgba(255, 255, 255, 0.1);
    padding: 1.5rem 3rem;
    border-radius: 0;
    border: 3px solid rgba(255, 255, 255, 0.2);
    margin-bottom: 2rem;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    gap: 3rem;
    padding: 0.5rem 0;
    font-size: 1.2rem;
}

.end-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

/* Confetti */
.confetti-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    top: -20px;
    width: 10px;
    height: 10px;
    animation: confettiFall 3s linear infinite;
}

@keyframes confettiFall {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

footer {
    position: fixed;
    bottom: 0.5rem;
    right: 1rem;
    z-index: 1000;
}

footer a {
    color: rgba(255, 255, 255, 0.3);
    text-decoration: none;
    font-size: 0.75rem;
    transition: color 0.3s;
}

footer a:hover {
    color: rgba(255, 255, 255, 0.6);
}

/* Mobile Controls */
.mobile-controls {
    display: none;
}

#mobile-controls {
    display: none;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 200px;
    pointer-events: none;
    z-index: 20;
    image-rendering: pixelated;
}

#shoot-btn-zone {
    position: absolute;
    right: 20px;
    bottom: 30px;
    pointer-events: auto;
}

/* Pixel-style shoot button */
#shoot-btn {
    width: 100px;
    height: 50px;
    border-radius: 0;
    background: #c41e1e;
    border: 4px solid #ff6b6b;
    border-bottom-color: #6b0000;
    border-right-color: #6b0000;
    color: #fff;
    font-family: 'Jersey 10', cursive;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 
        4px 4px 0 #000,
        inset 0 0 0 2px #000;
    transition: all 0.05s steps(2);
    text-shadow: 2px 2px 0 #000;
    image-rendering: pixelated;
    letter-spacing: 0.05em;
}

#shoot-btn:active,
#shoot-btn.charging {
    transform: translate(2px, 2px);
    box-shadow: 
        2px 2px 0 #000,
        inset 0 0 0 2px #000;
    background: #ff4444;
    border-color: #ffaaaa;
    border-bottom-color: #880000;
    border-right-color: #880000;
}

/* Pixel-style top view button */
#top-view-btn {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 20px;
    width: 100px;
    height: 36px;
    border-radius: 0;
    background: #333;
    border: 3px solid #888;
    border-bottom-color: #111;
    border-right-color: #111;
    color: #fff;
    font-family: 'Jersey 10', cursive;
    font-size: 0.9rem;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 
        3px 3px 0 #000,
        inset 0 0 0 2px #000;
    transition: background 0.05s steps(2), border-color 0.05s steps(2), box-shadow 0.05s steps(2);
    image-rendering: pixelated;
    letter-spacing: 0.05em;
}

#top-view-btn:active,
#top-view-btn.active {
    transform: translateX(-50%);
    box-shadow: 
        3px 3px 0 #000,
        inset 0 0 0 2px #000;
    background: #4a8a4a;
    border-color: #8fd98a;
    border-bottom-color: #2a4a2a;
    border-right-color: #2a4a2a;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    #top-bar {
        flex-direction: column;
        gap: 0.4rem;
        padding: 0.5rem 1rem;
    }
    
    .player-info {
        padding: 0.3rem 0.6rem;
        font-size: 0.9rem;
    }
    
    #turn-display {
        margin: 0.4rem 0;
    }
    
    /* Mobile controls container - flexbox layout from bottom */
    #mobile-controls {
        display: flex;
        flex-direction: column;
        align-items: center;
        position: absolute;
        bottom: 70px; /* Raised significantly to avoid footer overlap */
        left: 0;
        right: 0;
        gap: 10px;
        pointer-events: none;
        z-index: 20;
    }
    
    /* Order from bottom: TOP VIEW -> hint -> SHOOT -> power meter */
    #top-view-btn {
        order: 4;
        position: static;
        transform: none !important; /* Prevent any shifting on active state */
        pointer-events: auto;
        width: 160px; /* 2x size */
        height: 52px; /* 2x size */
        font-size: 0.7rem; /* 2x size */
        border-width: 4px;
    }
    
    #top-view-btn:active,
    #top-view-btn.active {
        transform: none !important; /* No shifting on mobile */
    }
    
    /* Hide desktop hint on mobile */
    #controls-hint {
        display: none !important;
    }
    
    /* Show mobile hint */
    #controls-hint-mobile {
        display: block;
        order: 3;
    }
    
    #controls-hint-mobile.hints-hidden {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        /* Keep height so layout doesn't shift */
    }
    
    /* 2x size for shoot button on mobile */
    #shoot-btn {
        width: 160px !important;
        height: 80px !important;
        font-size: 0.9rem !important;
        border-width: 6px;
    }
    
    /* 2x size for power meter on mobile */
    #power-meter-mobile {
        width: 220px !important;
        height: 24px !important;
        border-width: 4px;
    }
    
    #power-label-mobile {
        font-size: 0.8rem !important;
        top: -20px;
    }
    
    #shoot-btn-zone {
        order: 2;
        position: static;
        transform: none;
        pointer-events: auto;
    }
    
    /* Hide desktop power meter on mobile */
    #power-meter {
        display: none !important;
    }
    
    /* Show mobile power meter */
    #power-meter-mobile {
        display: block;
        order: 1;
    }
    
    .desktop-controls {
        display: none;
    }
    
    .mobile-controls {
        display: inline;
    }
    
    .player-inputs {
        gap: 1rem;
    }
    
    .input-group input {
        width: 140px;
        padding: 0.6rem 1rem;
    }
    
    .arcade-btn {
        padding: 0.8rem 2rem;
        font-size: 0.9rem;
    }
    
    .ascii-title {
        font-size: clamp(0.15rem, 0.9vw, 0.4rem);
    }
    
    /* Show crosshair on mobile */
    #crosshair {
        display: block;
    }
    
    .crosshair-dot {
        width: 3px;
        height: 3px;
        box-shadow: 
            0 0 0 1px #000,
            0 -6px 0 #fff,
            0 6px 0 #fff,
            -6px 0 0 #fff,
            6px 0 0 #fff,
            0 -7px 0 #000,
            0 7px 0 #000,
            -7px 0 0 #000,
            7px 0 0 #000;
    }
    
    .crosshair-ring {
        width: 20px;
        height: 20px;
        border: 2px solid rgba(255, 255, 255, 0.4);
    }
    
    .crosshair-ring::before {
        width: 8px;
        left: -11px;
    }
    
    .crosshair-ring::after {
        width: 8px;
        right: -11px;
    }
    
    .game-title {
        font-size: clamp(1.3rem, 5vw, 2.6rem);
    }
    
    .rules-content {
        max-width: 95vw;
        max-height: 80vh;
        padding: 1rem;
        margin: 10px;
    }
    
    .rules-title {
        font-size: 0.9rem;
    }
    
    .rules-section h3 {
        font-size: 0.65rem;
    }
    
    .rules-section p,
    .rules-section li {
        font-size: 1rem;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    #mobile-controls {
        bottom: 65px;
        gap: 8px;
    }
    
    #shoot-btn {
        width: 140px !important;
        height: 64px !important;
        font-size: 0.75rem !important;
    }
    
    #top-view-btn {
        width: 140px !important;
        height: 44px !important;
        font-size: 0.6rem !important;
    }
    
    #power-meter-mobile {
        width: 180px !important;
        height: 20px !important;
    }
    
    #power-label-mobile {
        font-size: 0.7rem !important;
        top: -18px;
    }
    
    #controls-hint-mobile {
        font-size: 0.6rem;
        padding: 0.3rem 0.5rem;
        min-height: 22px;
    }
    
    .player-name {
        font-size: 0.8rem;
    }
    
    #current-turn {
        font-size: 0.6rem;
        padding: 0.4rem 1rem;
    }
    
    .ascii-title {
        font-size: clamp(0.12rem, 0.7vw, 0.3rem);
    }
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
    #mobile-controls {
        bottom: 40px;
        gap: 6px;
    }
    
    #shoot-btn {
        width: 120px !important;
        height: 50px !important;
        font-size: 0.6rem !important;
    }
    
    #top-view-btn {
        width: 120px !important;
        height: 38px !important;
        font-size: 0.55rem !important;
    }
    
    #power-meter-mobile {
        width: 140px !important;
        height: 18px !important;
    }
    
    #power-label-mobile {
        font-size: 0.6rem !important;
        top: -16px;
    }
    
    #controls-hint-mobile {
        font-size: 0.55rem;
        padding: 0.2rem 0.4rem;
        min-height: 18px;
    }
    
    #top-bar {
        flex-direction: row;
        padding: 0.3rem 0.5rem;
    }
    
    .player-info {
        font-size: 0.7rem;
    }
}