/* Game container and arena */
#game-container {
    transform: scale(0.7);
    transform-origin: center center;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: opacity var(--transition-slow), transform var(--transition-slow);
}
#game-container.sliding-out-left {
    transform: translateX(-100vw) scale(0.7);
    opacity: 0;
    pointer-events: none;
}

/* Extra zoom-out ONLY for huge arena */
#game-container.zoom-extra {
    transform: scale(0.6);
}

/* NEW: In huge arenas, keep info text closer — reduce excessive spacing */
#game-container.zoom-extra #damage-info-wrapper {
    margin-top: 12px; /* drastically reduce from default 20px */
}

/* NEW: Spacing tweaks for small arena to "space out the info" */
#game-container.arena-small #top-controls {
    transform: translateY(-40px); /* bring controls closer to reduce overlap */
    margin-bottom: 14px;          /* add breathing room below controls */
}

#game-container.arena-small #versus-display {
    margin-bottom: 28px; /* more space between VS and arena */
}

#game-container.arena-small #damage-info-wrapper {
    margin-top: 32px; /* push damage/info further from arena for clarity */
}

#game-container.arena-small #arena-wrapper {
    gap: 24px; /* slightly widen gap between sidebars and canvas */
}

/* NEW: Specific overrides for shrinking arena to reduce excessive spacing */
#game-container.arena-huge.zoom-extra #damage-info-wrapper {
    margin-top: 12px; /* drastically reduce from default 20px */
}

#game-container.arena-huge.zoom-extra #controls {
    margin-top: 25px; /* override the dynamic spacing to keep controls closer */
}

/* NEW: Customizer modal styles */
#customizer-menu {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 120;
}
#customizer-card {
    background: #ffffff;
    border: 4px solid var(--black);
    border-radius: var(--radius-lg);
    padding: 12px; /* was 14px */
    width: 340px;  /* was 360px */
    max-width: 92vw;
    max-height: 85vh; /* NEW: ensure content fits on small screens */
    overflow-y: auto; /* NEW: allow scrolling to reach Save button */
    box-shadow: var(--shadow-lg);
    font-family: 'Anton', sans-serif;
}
#customizer-card h2 {
    margin: 0 0 10px 0;
    font-size: 26px;
    text-shadow:
        -2px -2px 0 var(--black),
         2px -2px 0 var(--black),
        -2px  2px 0 var(--black),
         2px  2px 0 var(--black);
}
.customizer-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 6px 0;
}
.customizer-row label {
    min-width: 90px;
}
.customizer-row input, .customizer-row select {
    flex: 1;
    padding: 6px;
    border: 2px solid var(--black);
    border-radius: var(--radius-sm);
    font-family: 'Anton', sans-serif;
}
.customizer-actions {
    display: flex;
    justify-content: flex-end;
    margin: 4px 0 10px 0;
}
.customizer-close-btn {
    width: 100%;
    margin-top: 6px;
    background-color: var(--panel);
    color: white;
}
#customizer-card h3 {
    font-family: 'Anton', sans-serif;
    font-size: 18px;
    margin: 4px 0 8px 0;
}
.customizer-note {
    font-family: 'Comic Sans MS', cursive, sans-serif;
    font-size: 12px;
    color: #333;
    margin-top: 8px;
}
.customizer-note ul {
    margin: 4px 0 0 16px;
    padding: 0;
}

@media (orientation: landscape) {
  #customizer-card {
    width: 300px;      /* was 320px */
    padding: 8px;      /* was 10px */
    max-height: 78vh;  /* NEW: smaller in landscape so Save is reachable */
  }
  #customizer-card h2 {
    font-size: 20px;   /* was 22px */
  }
  .customizer-row {
    gap: 6px;
    margin: 4px 0;
  }
  .customizer-row input, .customizer-row select {
    padding: 3px;      /* was 4px */
    font-size: 13px;   /* was 14px */
  }
  #customizer-card h3 {
    font-size: 15px;   /* was 16px */
  }
}

#ai-maker-menu {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 121;
}
#ai-maker-card {
    background: #ffffff;
    border: 4px solid var(--black);
    border-radius: var(--radius-lg);
    padding: 12px;
    width: 420px;
    max-width: 94vw;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    font-family: 'Anton', sans-serif;
}
#ai-maker-card h2 { margin: 0 0 10px 0; font-size: 24px; }
#ai-maker-card h3 { margin: 10px 0 8px 0; font-size: 18px; }
.ai-maker-row { display: flex; gap: 8px; align-items: center; margin: 6px 0; }
.ai-maker-row label { min-width: 120px; }
.ai-maker-row input, #ai-prompt {
    flex: 1; padding: 6px; border: 2px solid var(--black); border-radius: var(--radius-sm); font-family: 'Anton', sans-serif;
}
.ai-maker-actions { display: flex; gap: 8px; justify-content: flex-end; margin: 6px 0 10px 0; }
.ai-preview { background: #f7f7f7; border: 2px solid var(--black); padding: 8px; font-family: Space Mono, monospace; font-size: 12px; white-space: pre-wrap; }
.ai-gallery { display: flex; flex-direction: column; gap: 8px; }
.ai-gallery-item {
    display: flex; align-items: center; gap: 10px; padding: 8px; border: 2px solid var(--black); border-radius: 8px; background: #fff;
}
.ai-gallery-item .meta { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.ai-gallery-item .actions { display: flex; gap: 6px; }
.ai-gallery-item .author { font-size: 12px; color: #333; }
.ai-gallery-empty { font-size: 14px; color: #333; }

#arena-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    position: relative; /* Add position relative to contain absolute children */
}

#gameCanvas {
    border: 5px solid var(--black);
    background-color: var(--white);
    touch-action: none;           /* prevent page scroll/zoom during drag */
    -ms-touch-action: none;       /* IE/Edge legacy */
    user-select: none;            /* avoid text/image selection while dragging */
    -webkit-user-select: none;    /* Safari */
}

/* Stack container to position blackout/text over the canvas only */
#canvas-stack {
    position: relative;
    display: inline-block; /* fit to canvas size */
}

/* Full-cover blackout + message during shrink transitions */
#arena-shrinking-overlay {
    position: absolute;
    inset: 0;
    background: #000;               /* turn arena black while shrinking */
    display: none;                  /* toggled by JS when shrinking is active */
    align-items: center;
    justify-content: center;
    pointer-events: none;           /* allow clicks to pass through if needed */
    z-index: 2;                     /* above canvas, below sidebars since it only covers canvas area */
}

#arena-shrinking-overlay .shrinking-text {
    color: #fff;
    font-family: 'Anton', sans-serif;
    font-size: 44px;
    text-shadow:
        -2px -2px 0 var(--black),
         2px -2px 0 var(--black),
        -2px  2px 0 var(--black),
         2px  2px 0 var(--black),
         4px 4px 6px rgba(0,0,0,0.4);
    animation: float 3s ease-in-out infinite; /* subtle floating */
}

/* Selection panels */
.selection-box {
    width: 180px; /* was 150px - make sidebars slightly wider */
    border: 5px solid var(--black);
    background-color: var(--panel);
    padding: 15px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overflow-y: auto; /* Allow vertical scroll */
    overflow-x: hidden; /* Hide horizontal scroll */
}

/* Polished slim scrollbars for side panels */
.selection-box {
    scrollbar-width: thin;              /* Firefox */
    scrollbar-color: white transparent; /* Changed to white */
}
.selection-box::-webkit-scrollbar {
    width: 10px;
}
.selection-box::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 10px;
    box-shadow: none;
}
.selection-box::-webkit-scrollbar-thumb {
    background: white; /* Changed to white */
    border-radius: 10px;
    border: 2px solid white; /* Changed to white */
}
.selection-box::-webkit-scrollbar-thumb:hover {
    background: #f0f0f0; /* Slightly off-white for hover */
}
/* Add these new styles to remove scrollbar arrows */
.selection-box::-webkit-scrollbar-button {
    display: none;
}

.selection-box > *:first-child { margin-top: 0; }
.selection-box > *:last-child { margin-bottom: 0; }

.weapon-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.weapon-display {
    margin: 10px 0;
    padding: 10px;
    border: 4px solid var(--black);
    background-color: #f8f8f8;
    border-radius: var(--radius-sm);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all var(--transition-fast);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    box-sizing: border-box; /* ADDED: Ensure padding and border are included in the width */
}
.weapon-display:hover {
    background-color: var(--white);
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}
.weapon-display.selected {
    transform: scale(1.1) translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}
.weapon-display:active {
    background-color: var(--offwhite-3);
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}
.weapon-display.selected:active {
    transform: scale(1.08) translateY(0);
}
.weapon-display img { 
    image-rendering: pixelated;
    width: 60px;
    height: 60px;
}

/* Damage/versus */
#damage-info-wrapper {
    display: flex;
    justify-content: space-between;
    width: auto;
    margin-top: 20px; /* was 5px; lower the info text area a bit */
    box-sizing: border-box;
    position: relative;
    pointer-events: none; /* Prevent interference with other elements */
    padding: 0 20px; /* add a bit of side padding by default */
}

#damage-info-wrapper > * {
    pointer-events: auto; /* Re-enable pointer events for child elements */
}

.damage-display {
    font-size: 34px;
    text-shadow:
        -2px -2px 0 var(--black),
         2px -2px 0 var(--black),
        -2px  2px 0 var(--black),
         2px  2px 0 var(--black),
         4px 4px 6px rgba(0,0,0,0.4);
    width: 280px;
    box-sizing: border-box;
    height: 45px;
    margin: 5px 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    white-space: nowrap;
}
#damage-display-left { 
    text-align: left; 
    padding-left: 24px; /* more space from canvas */
    transform: translateX(-28px); /* push further left */
}
#damage-display-right { 
    text-align: right; 
    padding-right: 24px; /* more space from canvas */
    transform: translateX(28px); /* push further right */
}

/* Styles specific to FFA damage info wrapper and its children */
#damage-info-wrapper[style*="flex-direction: column"] { /* Targeting FFA layout */
}

.weapon-name-ffa {
    font-size: 30px; /* Slightly larger than the value */
    color: white;
    text-shadow:
        -2px -2px 0 var(--black),
         2px -2px 0 var(--black),
        -2px  2px 0 var(--black),
         2px  2px 0 var(--black),
         4px 4px 6px rgba(0,0,0,0.4);
    margin-top: 10px; /* Spacing from previous element */
    margin-bottom: 2px; /* Spacing to the value below it */
    text-align: center;
    width: 100%; /* Ensure it takes full width of parent column */
    box-sizing: border-box;
}

.damage-display.ffa-value-display {
    font-size: 24px; /* As previously set for FFA */
    text-align: center; /* Centered as requested */
    width: 100%; /* Ensure it takes full width of parent column (200px) */
    height: 35px; /* As previously set for FFA */
    margin: 0; /* Remove top/bottom margin, controlled by weapon-name-ffa */
    padding: 0; /* Remove padding */
}

/* Override specific left/right alignment for damage displays when they are used in FFA context */
#damage-display-left.ffa-value-display,
#damage-display-right.ffa-value-display {
    text-align: center;
    padding-left: 0;
    padding-right: 0;
}

/* NEW: Top controls row above the VS text */
#top-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    /* Visually move the button row higher without affecting layout flow */
    margin-top: 0;
    margin-bottom: 10px;
    transform: translateY(-40px); /* lowered from -70px */
}

#versus-display {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    /* Place VS text closer to the arena */
    margin-bottom: 20px;
    font-size: 44px;
    font-family: 'Anton', sans-serif;
    height: 55px;
}
.versus-text {
    text-shadow:
        -2px -2px 0 var(--black),
         2px -2px 0 var(--black),
        -2px  2px 0 var(--black),
         2px  2px 0 var(--black),
         4px 4px 6px rgba(0,0,0,0.4);
}
.versus-icon {
    width: 46px;
    height: 46px;
    image-rendering: pixelated;
}
.versus-icon.flipped { transform: scaleX(-1); }

/* Smaller info text specifically for Unarmed */
.damage-display .unarmed-info {
    font-size: 26px;
    line-height: 1.3; /* Increased from 1.05 for more spacing between lines */
}

#game-container.arena-tiny #top-controls {
    transform: translateY(-30px);
    margin-bottom: 10px;
}
#game-container.arena-tiny #versus-display { margin-bottom: 24px; }
#game-container.arena-tiny #damage-info-wrapper { margin-top: 28px; }