/* Plinko Game v0.19.00 - main.css */

/* ================================ */
/* SECTION: Reset & Base Styles     */
/* ================================ */
/*
 * Purpose: Global reset and base typography/settings
 * - Zeroes margins/padding, sets box model
 * - Applies default font stack and dark theme base
 */
* {
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #fff;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    overflow-x: hidden;
}


/* ================================ */
/* SECTION: Header & Title          */
/* ================================ */
/*
 * Purpose: Page header with gradient title and subtitle
 * - Centered layout with responsive max-width
 */
.header {
    text-align: center;
    margin-bottom: 20px;
    width: 100%;
    max-width: 1100px;
}

h1 {
    font-size: 2.8rem;
    margin-bottom: 8px;
    background: linear-gradient(90deg, #4cc9f0, #4361ee);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.subtitle {
    font-size: 1.2rem;
    color: #a5b4fc;
    margin-bottom: 20px;
}


/* =================================================== */
/* SECTION: Footer Styles - Copyright and version info */
/* =================================================== */
/*
 * Purpose: Bottom footer with centered text.
 * - Small font for subtlety.
*/
footer {
    /* Purpose: Alignment and spacing */
    text-align: center;
    margin-top: 20px;
    padding: 20px 0;
    /* Purpose: Typography */
    font-size: 0.85rem;
    color: #777;
}
footer p {
    margin: 1px 0; /* Keeps the two lines close together */
}
/* Footer version link */
#versionLink {
    /* Purpose: Interaction */
    cursor: pointer;
    color: #777; /* #003087; */
    /* text-decoration: underline; */
}
#versionLink:hover {
    color: #E30613;
}


/* ================================ */
/* SECTION: Main Layout Containers  */
/* ================================ */
/*
 * Purpose: Core game wrapper and stats display
 * - Flex column layout for vertical stacking
 * - Dark semi-transparent backgrounds with borders/shadows
 */
.game-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1100px;
    background: rgba(30, 30, 46, 0.8);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border: 1px solid #2d2d44;
    flex: 1;
}

.stats-container {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    background: rgba(20, 20, 35, 0.8);
    padding: 15px;
    border-radius: 10px;
    border: 1px solid #3a3a5d;
}

.stat-box {
    text-align: center;
    flex: 1;
    padding: 10px;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: #4cc9f0;
    text-shadow: 0 0 8px rgba(76, 201, 240, 0.5);
}

.stat-label {
    font-size: 0.9rem;
    color: #a5b4fc;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.game-area {
    display: flex;
    gap: 20px;
    flex: 1;
    min-height: 0; /* Important for flex children to respect overflow */
}


/* ================================ */
/* SECTION: Controls Sidebar        */
/* ================================ */
/*
 * Purpose: Left sidebar with action buttons and settings
 * - Fixed width, vertical stack with gaps
 * - Collapsible control groups
 */
.controls {
    width: 230px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex-shrink: 0;
}

.control-group {
    background: rgba(20, 20, 35, 0.8);
    padding: 15px;
    border-radius: 10px;
    border: 1px solid #3a3a5d;
}

/* Hide content when collapsed (except title) */
.control-group.collapsed > *:not(.control-title) {
    display: none !important;
}

.control-title {
    font-size: 1.1rem;
    margin-bottom: 10px;
    color: #a5b4fc;
    border-bottom: 1px solid #3a3a5d;
    min-height: 28px;                  
    padding-bottom: 4px;
}


/* ================================ */
/* SECTION: Minimise Button */
/* ================================ */
/*
 * Purpose: Collapse/expand icon in control group titles
 * - Fixed square size, right-aligned
 * - Hover/active states with subtle glow
 */
.Minimise-btn {
    width: 24px !important;
    height: 24px !important;
    min-height: 24px !important;
    padding: 0 !important;
    font-size: 18px;
    line-height: 1;
    margin: 0 0 0 10px;
    border-radius: 4px;
    background: rgba(58, 58, 93, 0.6);
    border: 1px solid rgba(76, 201, 240, 0.3);
    color: #a5b4fc;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.Minimise-btn:hover {
    background: rgba(76, 201, 240, 0.3);
    color: #4cc9f0;
    border-color: #4cc9f0;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.Minimise-btn:active {
    transform: translateY(0);
}

/* ===================================================================== */
/* SECTION: Settings Group Title Alignment - Right-align Minimise button */
/* ===================================================================== */
/*
 * Purpose: Ensures the Minimise button is properly positioned in the title bar
 * - Uses flexbox for space-between layout
 * - Targets the new #settings-group specifically
 */
#settings-group .control-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 0 5px 0;  /* optional: tighter spacing */
}


/* ================================ */
/* SECTION: Sliders & Labels        */
/* ================================ */
/*
 * Purpose: Consistent styling for all sliders and their labels/values
 * - Compact font sizes for sidebar fit
 * - Blue thumb and track matching theme
 */
.slider-container {
    margin: 15px 0;
    transition: margin 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
}

.slider-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.slider-value {
    color: #4cc9f0;
    font-size: 0.9rem;
    font-weight: bold;
}

input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: #2d2d44;
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #4cc9f0;
    cursor: pointer;
    box-shadow: 0 0 5px rgba(76, 201, 240, 0.8);
}


/* ================================ */
/* SECTION: Buttons & Hover States */
/* ================================ */
/*
 * Purpose: Primary action and reset buttons
 * - Blue gradient default, red danger hover on reset
 * - Compact height with touch-friendly size
 * - Lift/shadow hover effect
 */
button {
    background: linear-gradient(90deg, #4361ee, #3a0ca3);
    color: white;
    border: none;
    padding: 12px 15px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: normal;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 5px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.3);
    background: linear-gradient(90deg, #4cc9f0, #4361ee);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    background: #555;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* SECTION: Compact Action Buttons - Reduced height for main controls */
/*
 * Purpose: Slims down primary gameplay and reset buttons for better vertical space
 * - Applies only to visible action buttons, not Minimise icons
 * - Maintains good touch targets while tightening layout
 */
.controls button:not(.Minimise-btn) {
    padding: 8px 12px;
    font-size: 0.8rem;
    min-height: 36px;
    line-height: 1.3;
    margin-top: 6px;
}

.button-row {
  display: flex;          /* put buttons side-by-side */
  /* gap: 0.5rem;            /* small space between them */
  justify-content: space-between; /* first item at left, last at right */
  align-items: center;    /* optional vertical alignment */
}

/* =========================================================================== */
/* SECTION: Danger Button Hover - Red gradient only on hover for reset actions */
/* =========================================================================== */
/*
 * Purpose: Provides visual warning for destructive reset buttons
 * - Keeps default blue gradient like all other buttons
 * - Switches to red gradient on hover to indicate caution/danger
 * - Maintains consistent gradient direction (lighter → darker)
 * - Preserves lift, shadow, and active press feedback
 */
#reset-game:hover {
    background: linear-gradient(90deg, #66bb6a, #2e7d32);
    box-shadow: 0 6px 12px rgba(46, 125, 50, 0.45);
}

#reset-settings:hover {
    background: linear-gradient(90deg, #ff5252, #c62828);
    box-shadow: 0 6px 12px rgba(198, 40, 40, 0.45);
}

#reset-game:active,
#reset-settings:active {
    background: linear-gradient(90deg, #e53935, #b71c1c);
}

#reset-settings {
    margin-top: 24px;
}


/* ================================ */
/* SECTION: Plinko Board & Elements */
/* ================================ */
/*
 * Purpose: Main game board and falling pieces
 * - Absolute positioning for pegs, slots, balls
 * - Dark background with border
 */
.plinko-board-container {
    flex: 1;
    position: relative;
    min-height: 0; /* Important for flex children */
}

.plinko-board {
    position: absolute;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 20, 0.9);
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid #3a3a5d;
}

.peg {
    position: absolute;
    width: 12px;
    height: 12px;
    background: radial-gradient(circle at 30% 30%, #4cc9f0, #4361ee);
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(76, 201, 240, 0.7);
}

.ball {
    position: absolute;
    border-radius: 50%;
    z-index: 10;
}

.slot {
    position: absolute;
    bottom: 0;
    height: 40px;
    background: rgba(30, 30, 50, 0.8);
    border-top: 3px solid #4cc9f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #4cc9f0;
    font-size: 1.2rem;
}


/* ================================ */
/* SECTION: Tooltip Styling */
/* ================================ */
/*
 * Purpose: Floating help popups for settings
 * - Dark semi-transparent background
 * - Arrow pointer, hover/focus show
 * - Mobile tap support via .visible class
 */
.tooltip-icon {
    cursor: help;
    color: #4cc9f0;
    font-size: 0.95rem;
    margin-left: 6px;
    margin-right: 2px;
    vertical-align: middle;
    display: inline-block;
}

.tooltip {
    visibility: hidden;
    width: 200px;
    background-color: rgba(35, 35, 55, 0.96);
    color: #f0f0ff;
    text-align: left;
    border-radius: 6px;
    padding: 10px 12px;
    position: absolute;
    z-index: 20;
    bottom: 140%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.18s ease, visibility 0.18s ease;
    font-size: 0.80rem !important;
    line-height: 1.45;
    border: 1px solid #4a4a7d;
    pointer-events: none;
    box-shadow: 0 4px 14px rgba(0,0,0,0.55);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

/* Tooltip Delay on Hover - Intentional linger only 
 * Purpose: Adds a short delay before tooltip appears on hover
 * - Prevents tooltip spam during quick mouse movements
 * - Shows immediately on hover-out (smooth close)
 * - Works well with existing transition timing
 */
.tooltip {
    
    /* NEW: Delay appearance by 300ms */
    transition: 
        opacity 0.18s ease 400ms,     /* 300ms delay on fade-in */
        visibility 0s linear 400ms;   /* visibility delayed too */
    
    /* When hiding: no delay (instant start of fade-out) */
    .button-tooltip-wrapper:hover &,
    .button-tooltip-wrapper:focus-within & {
        transition-delay: 1s, 1s;     /* override delay when shown */
    }
}

.tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -6px;
    border-width: 6px;
    border-style: solid;
    border-color: rgba(35, 35, 55, 0.96) transparent transparent transparent;
}

.slider-label:hover .tooltip,
.slider-label:focus-within .tooltip,
.tooltip-icon:hover + .tooltip,
.tooltip-icon:focus + .tooltip {
    visibility: visible;
    opacity: 1;
}

.tooltip.visible {
    visibility: visible !important;
    opacity: 1 !important;
}

.slider-label {
    position: relative;
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
}

.slider-value {
    margin-left: auto;
    padding-left: 8px;
}

.toggle-label {
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    position: relative;
}

.toggle-label .tooltip-icon {
    margin-left: 8px;
    font-size: 0.95rem;
}

.toggle-label .tooltip {
    bottom: 130%;
    left: 0;
    transform: translateX(0);
    width: 240px;
}

.toggle-label:hover .tooltip,
.toggle-label:focus-within .tooltip,
.toggle-label .tooltip-icon:hover + .tooltip,
.toggle-label .tooltip-icon:focus + .tooltip {
    visibility: visible;
    opacity: 1;
}

.toggle-switch {
    margin-right: 8px;
}


/* ================================ */
/* SECTION: Button Hover Tooltips - No icon version */
/* ================================ */
/*
 * Purpose: Displays tooltips when hovering over action buttons
 * - No visible trigger icon — appears only on button hover/focus
 * - Positioned above buttons with arrow pointing down
 * - Reuses existing .tooltip styles and transition
 */
.button-tooltip-wrapper {
    position: relative;
    display: inline-block;
}

.button-tooltip-wrapper button {
    /* Optional: subtle cursor hint that the button has extra info */
    /*cursor: help;*/
}

/* Position tooltips above the buttons */
.button-tooltip-wrapper .tooltip {
    bottom: 130%;              /* Slightly higher than sliders to clear button */
    left: 50%;
    transform: translateX(-50%);
    width: 240px;              /* Slightly narrower for button context */
    margin-bottom: 10px;
}

/* Arrow pointing downward (overrides your ::after if needed) */
.button-tooltip-wrapper .tooltip::after {
    top: 100%;
    border-color: rgba(35, 35, 55, 0.96) transparent transparent transparent;
}

/* Show on hover/focus of the wrapper */
.button-tooltip-wrapper:hover .tooltip,
.button-tooltip-wrapper:focus-within .tooltip {
    visibility: visible;
    opacity: 1;
}

/* Mobile: show below instead (better for small screens) */
@media (hover: none) {
    .button-tooltip-wrapper .tooltip {
        bottom: auto;
        top: 130%;
        margin-top: 10px;
        margin-bottom: 0;
    }
    
    .button-tooltip-wrapper .tooltip::after {
        top: auto;
        bottom: 100%;
        border-top-color: transparent;
        border-bottom-color: rgba(35, 35, 55, 0.96);
    }
}


/* ===================================================================== */
/* SECTION: Slot Positioning - Raise scoring slots for better visibility */
/* ===================================================================== */
/*
 * Purpose: Lifts the bottom scoring slots upward to prevent cutoff at screen bottom
 * - Adds a small upward offset so numbers are fully visible
 * - Keeps slots aligned below the peg grid
 * - Responsive: does not affect pegs or ball drop zone
 * - Uses negative margin for minimal layout shift
 */
.slot {
    position: absolute;
    transform: translateY(-20px); /* ← Use transform for smoother lift */
}


/* ==================================== */
/* SECTION: Drop Results – Time display */
/* ==================================== */
/*
 * Purpose: Smaller, muted drop time shown right-aligned in each result row
 * - Brackets format (8.234 s)
 * - Pushed to far right of row
 * - Slightly faded for secondary importance
 */
.score-row {
    display: flex;
    align-items: center;
    justify-content: space-between;     /* ← key: pushes time to right */
    gap: 12px;
    padding: 8px 12px;
    background: rgba(30, 30, 50, 0.5);
    border-radius: 8px;
    border: 1px solid rgba(58, 58, 93, 0.4);
}

.drop-time {
    font-size: 0.85rem;
    color: #a5b4fc;
    opacity: 0.85;
    white-space: nowrap;
    margin-left: auto;                  /* ensures far-right push */
}

/* SECTION: Drop Results – Ranked scores from last batch (5-10 words) */
/*
 * Purpose: Compact display of last drop scores in sidebar
 * - Hidden until first ball finishes
 * - Vertical list of swatch + score rows
 * - Matches dark theme with subtle accents
 */
.auto-drop-results {
    margin-top: 12px;
}

.score-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}


.ball-swatch {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.12);
    cursor: pointer;  /* Indicates clickability */
}

.score-value {
    font-weight: 600;
    font-size: 1.05rem;
    color: #ffd60a;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}


/* ================================ */
/* SECTION: Media Queries - Responsive Adjustments */
/* ================================ */
/*
 * Purpose: Mobile and tablet layout adaptations
 * - Stack controls and board vertically on small screens
 * - Adjust font sizes, heights, and padding
 */
@media (max-width: 900px) {
    .game-area {
        flex-direction: column;
    }
    
    .controls {
        width: 100%;
    }
    
    .plinko-board-container {
        height: 500px;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .game-container {
        padding: 15px;
    }
}

@media (max-width: 600px) {
    .stats-container {
        flex-wrap: wrap;
    }
    
    .stat-box {
        flex-basis: 50%;
        margin-bottom: 10px;
    }
    
    .plinko-board-container {
        height: 400px;
    }
    
    .header, .game-container, .instructions {
        padding: 10px;
    }
}


/* ================================ */
/* SECTION: Future Physics Placeholders */
/* ================================ */
/*
 * Purpose: Disabled sliders for upcoming features
 * - Lower opacity and cursor change for disabled state
 * - Right-aligned "Coming in..." note
 */
.future-physics input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.future-physics small {
    display: block;
    text-align: right;
    color: #888;
    font-size: 0.8rem;
    margin-top: 4px;
}

/* Slightly tighter spacing for placeholders */
.future-physics .slider-label {
    font-size: 0.85rem; /* Even smaller to differentiate */
}















/* SECTION: Sound Controls Styling - Volume slider & toggle switch */
/*
 * Purpose: Consistent look for new sound-related inputs
 * - Matches existing blue gradient theme (#4cc9f0 / #4361ee)
 * - Smooth transitions and hover effects
 * - Toggle styled as modern switch (iOS-like)
*/

.toggle-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}

.toggle-label {
    color: #c5c8e0;
    font-size: 0.95rem;
}

/* Toggle switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #2d2d44;
    transition: .3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

input:checked + .slider {
    background: linear-gradient(90deg, #4361ee, #4cc9f0);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

/* Hover / focus states */
.toggle-switch:hover .slider,
.toggle-switch input:focus + .slider {
    box-shadow: 0 0 0 2px rgba(76, 201, 240, 0.3);
}

/* Slider value display consistency */
#volume-value {
    color: #4cc9f0;
    font-weight: bold;
}

/* SECTION: Enhanced visual feedback for physics hits */
/*
 * Purpose: Temporary glow and flash effects when ball hits peg
 * - Peg flash: brief white/yellow radial gradient
 * - Ball glow boost: stronger shadow on impact
*/

.peg.flash {
    background: radial-gradient(circle at 30% 30%, #ffffff, #ffff99) !important;
    transition: background 0.12s ease-out;
}

/* SECTION: Enhanced visual feedback for physics hits */
/*
 * Purpose: Temporary glow boost when ball hits peg or another ball
 * - Increases shadow intensity briefly
 * - Uses the ball's own shadow color (set inline)
 */
.ball.glow-boost {
    box-shadow: 0 0 20px currentColor !important;
    transition: box-shadow 0.2s ease-out;
}

/* SECTION: Ball-Ball Collision Flash - Red burst at impact */
/*
 * Purpose: Temporary visual explosion at collision point
 * - Bright red radial gradient that scales and fades
 * - Matches peg flash style but more intense
*/
.ball-collision-flash {
    position: absolute;
    width: 20px;
    height: 20px;
    left: -10px;
    top: -10px;
    background: radial-gradient(circle, #ff4444 0%, #ff0000 50%, rgba(255,0,0,0) 70%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 50;
    transform: scale(0);
    opacity: 1;
    transition: all 0.3s ease-out;
}


/* SECTION: Unsupported Messages - For phones and portrait tablets */
/*
 * Purpose: Full-screen overlay messages for unsupported setups
 * - Phones blocked in BOTH portrait and landscape (up to ~956 px width)
 * - Tablets blocked only in portrait; allowed in landscape
 * - Uses fixed positioning to cover viewport
 * - Matches dark theme with gradient headings
 */
.unsupported-message {
    display: none;
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #fff;
    text-align: center;
    padding: 20vh 5vw 0;
    z-index: 9999;
    overflow-y: auto;
}

.unsupported-message h2 {
    font-size: 2.2rem;
    margin-bottom: 1.2rem;
    background: linear-gradient(90deg, #ff6b6b, #ff4444);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.unsupported-message p {
    font-size: 1.25rem;
    line-height: 1.5;
    color: #d0d0ff;
    max-width: 600px;
    margin: 0 auto;
}

/* Reuse the same gradient and shadow as the main header h1 */
.unsupported-title {
    font-size: 3.2rem;                /* Slightly larger for impact */
    margin: 0 0 1.5rem 0;
    background: linear-gradient(90deg, #4cc9f0, #4361ee);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    text-align: center;
}

/* Make title smaller on very narrow screens (portrait phones) */
@media (max-width: 500px) {
    .unsupported-title {
        font-size: 2.4rem;
    }
}

/* Optional: Center everything vertically better if desired */
.unsupported-message {
    display: none;
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #fff;
    text-align: center;
    padding: 15vh 5vw 0;
    z-index: 9999;
    overflow-y: auto;
}

/* Hide game elements when showing message */
@media (max-width: 959px) {
    /* Purpose: All phones — any orientation (covers up to iPhone 16 Pro Max landscape ~956 px) */
    .header,
    .game-container,
    footer {
        display: none !important;
    }
    #phone-unsupported {
        display: block;
    }
}

@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
    /* Purpose: Tablets in portrait — ask to rotate (iPad Mini portrait ~768 px, etc.) */
    .header,
    .game-container,
    footer {
        display: none !important;
    }
    #rotate-device {
        display: block;
    }
}


/* SECTION: Tablet Landscape Fit - Prevent scroll on typical tablets */
/*
 * Purpose: Makes board fit full available height on tablets in landscape
 * - Uses flex + calc to fill remaining space after header/stats
 * - Slightly reduces vertical peg spacing and top offset for breathing room
 * - Targets ≥1024px wide + landscape (covers most iPads/Android tablets)
 * - Keeps horizontal max-width safe
 */
@media (min-width: 1024px) and (orientation: landscape) {
    /* Purpose: Make game-container take almost full viewport height */
    .game-container {
        max-height: calc(100vh - 40px); /* leaves small margin for browser chrome */
        overflow: hidden; /* prevent any inner scroll */
    }

    /* Purpose: Let board container expand to fill remaining flex space */
    .plinko-board-container {
        flex: 1 1 auto; /* grow and shrink as needed */
        min-height: 0;  /* important for flex child overflow */
        height: auto;   /* override any previous fixed height */
    }

    /* Purpose: Reduce vertical density slightly to fit more comfortably */
    /* (these are global constants, but we can override via :root or inline if preferred) */
    :root {
        --peg-spacing-y: 30px;     /* was 35px */
        --peg-top-offset: 40px;    /* was 50px */
    }

    /* Purpose: Override peg creation spacing in JS (via CSS var fallback) */
    /* If you prefer not changing JS constants, add this instead: */
    /* .peg { transform: translateY(-5px); } */ /* minor squeeze alternative */

    /* Optional tighter stats/header on tablets */
    .stats-container {
        padding: 10px;
        margin-bottom: 10px;
    }
    .header {
        margin-bottom: 10px;
    }
    h1 {
        font-size: 2.4rem; /* slightly smaller title */
    }
}


/* Fix SETTINGS cutoff on tablet landscape */
@media (min-width: 1024px) and (orientation: landscape) {

    /* Purpose: Auto-collapse SETTINGS group to save vertical space */
    #settings-group {
        /* Force collapsed state on load – user can expand manually */
    }

    /* Optional: Make controls scrollable if still tall after collapse */
    .controls {
        max-height: calc(100vh - 180px); /* rough estimate: header+stats+padding+footer */
        overflow-y: auto;
        padding-right: 8px; /* space for scrollbar */
    }

    /* Purpose: Tighten spacing inside SETTINGS for better fit */
    .slider-container {
        margin: 10px 0;          /* was ~15px */
    }

    .slider-label {
        font-size: 0.85rem;      /* slightly smaller labels */
    }

    .toggle-container {
        margin-top: 8px;         /* tighter than 12px */
    }

    button:not(.Minimise-btn) {
        padding: 8px 12px;       /* already compact, but reinforce */
        font-size: 0.75rem;
    }

    /* Optional: Slightly smaller control group padding */
    .control-group {
        padding: 12px;           /* was 15px */
    }
}

@media (min-width: 1024px) and (orientation: landscape) {

    /* Auto-collapse SETTINGS */
    #settings-group {
        /* force collapsed – or call forceCollapseControlGroup in JS */
    }

    .controls {
        max-height: calc(100vh - 180px);
        overflow-y: auto;
        padding-right: 8px;
    }

    /* CHANGE START: Stats bar reductions */
    .stats-container {
        padding: 10px;
        margin-bottom: 12px;
    }

    .stat-value {
        font-size: 2.2rem;
    }

    .stat-label {
        font-size: 0.8rem;
    }

    .stat-box {
        padding: 6px;
    }
}

/* SECTION: Browser Warning Banner */
/*
 * Purpose: Non-intrusive top banner for unsupported/poorly-performing browsers
 * - Fixed/sticky appearance just below header
 * - Centered content with close button
 * - Subtle colors matching dark theme
 * - Responsive – smaller on narrow screens
*/
.browser-warning {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto 12px;
    background: rgba(255, 140, 0, 0.18);
    border: 1px solid rgba(255, 140, 0, 0.35);
    border-radius: 8px;
    padding: 10px 16px;
    color: #ffcc80;
    font-size: 0.95rem;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.warning-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    position: relative;
}

.warning-content span {
    flex: 1;
}

#dismiss-safari-warning {
    background: none;
    border: none;
    color: #ffcc80;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

#dismiss-safari-warning:hover {
    opacity: 1;
}

/* Smaller text on narrow screens */
@media (max-width: 600px) {
    .browser-warning {
        font-size: 0.9rem;
        padding: 8px 12px;
    }
}


/* SECTION: Canvas Board – High-performance rendering layer */
/*
 * Purpose: Replaces DOM-based plinko board with GPU-accelerated canvas
 * - Full size of container, crisp on retina/high-DPI screens
 * - Enables smooth 60 fps even with many balls
 * - Maintains dark theme background compatibility
*/
.plinko-board-container {
    position: relative;
    flex: 1;
    min-height: 400px;
    background: rgba(20, 20, 35, 0.4);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #2d2d44;
    box-sizing: border-box;          /* ← important */
    padding: 0;                      /* ← remove any padding */
    margin: 0;                       /* ← ensure no extra margin */
}

#plinko-canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    touch-action: none;
}

/* Hide leftover DOM pegs/balls during transition */
.peg, .ball {
    display: none !important;
}