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

body {
    font-family: 'Special Elite', 'Courier New', monospace;
    background-color: #2d3a1f;
    min-height: 100vh;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 20px;
    position: relative;
    flex-direction: column;
    overflow-x: hidden;
}

/* Netting overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        repeating-linear-gradient(45deg, transparent, transparent 18px, rgba(0,0,0,0.2) 18px, rgba(0,0,0,0.2) 19px),
        repeating-linear-gradient(-45deg, transparent, transparent 18px, rgba(0,0,0,0.2) 18px, rgba(0,0,0,0.2) 19px),
        repeating-linear-gradient(90deg, transparent, transparent 35px, rgba(0,0,0,0.1) 35px, rgba(0,0,0,0.1) 36px),
        repeating-linear-gradient(0deg, transparent, transparent 35px, rgba(0,0,0,0.1) 35px, rgba(0,0,0,0.1) 36px);
    pointer-events: none;
    z-index: 1;
}

/* Scratchy texture overlay */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 15% 25%, rgba(139,90,43,0.15) 0%, transparent 40%),
        radial-gradient(ellipse at 85% 75%, rgba(0,0,0,0.2) 0%, transparent 40%),
        radial-gradient(ellipse at 50% 50%, rgba(139,90,43,0.08) 0%, transparent 60%),
        repeating-linear-gradient(92deg, transparent, transparent 4px, rgba(0,0,0,0.04) 4px, rgba(0,0,0,0.04) 5px),
        repeating-linear-gradient(178deg, transparent, transparent 7px, rgba(255,255,255,0.02) 7px, rgba(255,255,255,0.02) 8px);
    pointer-events: none;
    z-index: 1;
}

.ad-banner {
    height: 100px;
    width: calc(100vw - 50px);
    margin: 0 25px;
    background: rgba(0,0,0,0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 25px;
}

/* Help button */
.help-btn {
    position: absolute;
    top: 18px;
    right: 18px;
    z-index: 2000;
    width: 54px;
    height: 54px;
    border: 4px solid #1a2410;
    border-radius: 50% 52% 48% 50% / 50% 50% 46% 54%;
    background: radial-gradient(circle at 30% 30%, #d9c77a 0%, #c5a94d 18%, #5a6d33 48%, #2e3d1e 100%);
    color: #f5e6a3;
    font-family: 'Black Ops One', monospace;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: rotate(12deg);
    box-shadow:
        inset 0 5px 8px rgba(255,255,255,0.25),
        inset 0 -8px 10px rgba(0,0,0,0.35),
        0 8px 18px rgba(0,0,0,0.45);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.help-btn::before {
    content: '';
    position: absolute;
    inset: 7px;
    border-radius: 50%;
    border: 3px solid rgba(26, 36, 16, 0.7);
    box-shadow: inset 0 0 0 2px rgba(245, 230, 163, 0.2);
}

.help-btn:hover {
    transform: rotate(12deg) scale(1.06);
    box-shadow:
        inset 0 5px 8px rgba(255,255,255,0.3),
        inset 0 -8px 10px rgba(0,0,0,0.4),
        0 10px 20px rgba(0,0,0,0.5);
}

.help-btn:active {
    transform: rotate(12deg) scale(0.96);
}

/* Main wrapper for positioning */
.main-wrapper {
    position: relative;
    z-index: 10;
    display: flex;
    align-items: stretch;
    height: 75vh;
}

/* Slide-out table panel - drawer style */
.table-panel {
    position: relative;
    width: 280px;
    z-index: 5;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s;
    display: flex;
    opacity: 0;
    overflow: hidden;
}

.table-panel.open {
    width: 280px;
    opacity: 1;
}

/* Yellow pad paper */
.pad-paper {
    flex: 1;
    background:
        repeating-linear-gradient(
            transparent,
            transparent 27px,
            rgba(107, 155, 209, 0.5) 27px,
            rgba(107, 155, 209, 0.5) 28px
        ),
        linear-gradient(
            to right,
            transparent 44px,
            rgba(220, 60, 60, 0.6) 45px,
            transparent 46px
        ),
        radial-gradient(ellipse at 30% 20%, rgba(139,90,43,0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(139,90,43,0.06) 0%, transparent 50%),
        #f5e6a3;
    padding: 20px 15px 20px 55px;
    box-shadow:
        4px 4px 15px rgba(0,0,0,0.6),
        -2px 0 8px rgba(0,0,0,0.3),
        inset 0 0 30px rgba(139,90,43,0.1);
    transform: rotate(-1.5deg);
    position: relative;
    border-radius: 2px;
    display: flex;
    flex-direction: column;
}

/* Paper holes */
.pad-paper::before {
    content: '';
    position: absolute;
    top: 40px;
    left: 18px;
    width: 12px;
    height: 12px;
    background: #2d3a1f;
    border-radius: 50%;
    box-shadow:
        0 80px 0 #2d3a1f,
        0 160px 0 #2d3a1f,
        0 240px 0 #2d3a1f,
        0 320px 0 #2d3a1f,
        0 400px 0 #2d3a1f;
}

/* Paper edge curl */
.pad-paper::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 30px;
    height: 30px;
    background: linear-gradient(225deg, #2d3a1f 0%, #2d3a1f 50%, #e8d48b 50%, #f5e6a3 100%);
    border-radius: 0 2px 0 0;
}

.pad-paper h3 {
    font-family: 'Special Elite', monospace;
    color: #1a3a5c;
    margin-bottom: 15px;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 2px;
    border-bottom: 2px solid #1a3a5c;
    padding-bottom: 8px;
}

.pad-paper table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Special Elite', monospace;
    color: #1a3a5c;
    font-size: 13px;
    flex: 1;
}

.pad-paper th {
    text-align: left;
    padding: 6px 10px;
    color: #1a3a5c;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 1px;
    border-bottom: 2px solid #1a3a5c;
}

.pad-paper td {
    padding: 4px 10px;
    line-height: 28px;
}

.pad-paper tr:hover td {
    background: rgba(107, 155, 209, 0.15);
}

/* Vertical slider container */
.slider-container {
    width: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 20px 10px;
    background: rgba(0,0,0,0.2);
    border-left: 2px solid #1a2410;
    position: relative;
}
.slider-container::before {
    content: '';
    background: #4a644090;
    position: absolute;
    top: 80px;
    left: 20px;
    bottom: 30px;
    right: 20px;
    display: block;
    border-radius: 10px;
    z-index: 1;
}

.slider-label {
    font-family: 'Black Ops One', monospace;
    color: #f5e6a3;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
    margin-left: -7px;
}

/* Vertical range slider */
input[type="range"].vertical-slider {
    writing-mode: vertical-lr;
    direction: rtl;
    width: 34px;
    height: 100%;
    background: transparent;
    -webkit-appearance: none;
    appearance: none;
    z-index: 10;
    margin-top: 45px;
}

input[type="range"].vertical-slider::-webkit-slider-track {
    width: 16px;
    background:
        linear-gradient(90deg,
            rgba(0,0,0,0.35) 0%,
            rgba(0,0,0,0.05) 45%,
            rgba(255,255,255,0.12) 50%,
            rgba(0,0,0,0.05) 55%,
            rgba(0,0,0,0.35) 100%),
        linear-gradient(180deg, #6b5535 0%, #3f3320 100%);
    border: 2px solid #1a2410;
    border-radius: 8px;
    box-shadow:
        inset 2px 0 4px rgba(0,0,0,0.6),
        inset -2px 0 4px rgba(0,0,0,0.6),
        inset 0 0 6px rgba(0,0,0,0.5),
        0 1px 2px rgba(255,255,255,0.15);
}

input[type="range"].vertical-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 34px;
    height: 22px;
    background: linear-gradient(180deg, #5a6d33 0%, #3d4f1e 100%);
    border: 3px solid #1a2410;
    border-radius: 4px;
    cursor: grab;
    box-shadow:
        inset 0 2px 4px rgba(255,255,255,0.2),
        inset 0 -2px 4px rgba(0,0,0,0.4),
        0 2px 5px rgba(0,0,0,0.6);
    z-index: 20;
}

input[type="range"].vertical-slider::-moz-range-track {
    width: 16px;
    background:
        linear-gradient(90deg,
            rgba(0,0,0,0.35) 0%,
            rgba(0,0,0,0.05) 45%,
            rgba(255,255,255,0.12) 50%,
            rgba(0,0,0,0.05) 55%,
            rgba(0,0,0,0.35) 100%),
        linear-gradient(180deg, #6b5535 0%, #3f3320 100%);
    border: 2px solid #1a2410;
    border-radius: 8px;
    box-shadow:
        inset 2px 0 4px rgba(0,0,0,0.6),
        inset -2px 0 4px rgba(0,0,0,0.6),
        inset 0 0 6px rgba(0,0,0,0.5);
}

input[type="range"].vertical-slider::-moz-range-thumb {
    width: 34px;
    height: 22px;
    background: linear-gradient(180deg, #5a6d33 0%, #3d4f1e 100%);
    border: 3px solid #1a2410;
    border-radius: 4px;
    cursor: pointer;
    box-shadow:
        inset 0 2px 4px rgba(255,255,255,0.2),
        inset 0 -2px 4px rgba(0,0,0,0.4),
        0 2px 5px rgba(0,0,0,0.6);
    z-index: 20;
}

/* Main container - Ammo crate */
.container {
    position: relative;
    z-index: 10;
    background:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 38px,
            rgba(0,0,0,0.25) 38px,
            rgba(0,0,0,0.25) 40px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 3px,
            rgba(0,0,0,0.06) 3px,
            rgba(0,0,0,0.06) 4px
        ),
        radial-gradient(ellipse at 20% 30%, rgba(139,90,43,0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 70%, rgba(0,0,0,0.2) 0%, transparent 50%),
        linear-gradient(135deg, #4a5d23 0%, #3d4f1e 30%, #4a5d23 60%, #3d4f1e 100%);
    padding: 2.5rem;
    border-radius: 4px;
    box-shadow:
        inset 0 2px 4px rgba(255,255,255,0.1),
        inset 0 -2px 4px rgba(0,0,0,0.3),
        0 10px 30px rgba(0,0,0,0.5),
        0 0 0 4px #2d3a1f,
        0 0 0 8px #5a6d33,
        0 0 0 12px #2d3a1f;
    text-align: center;
    width: 600px;
}

/* Drawer connection border */
.container::before {
    content: '';
    position: absolute;
    top: 0;
    left: -4px;
    width: 4px;
    height: 100%;
    background: #2d3a1f;
    border-left: 2px solid #5a6d33;
}

/* Metal corner rivets */
.rivet {
    position: absolute;
    width: 24px;
    height: 24px;
    background: radial-gradient(circle at 35% 35%, #8a8a8a 0%, #5a5a5a 50%, #3a3a3a 100%);
    border-radius: 50%;
    box-shadow:
        inset 0 2px 3px rgba(255,255,255,0.4),
        inset 0 -2px 3px rgba(0,0,0,0.6),
        0 2px 4px rgba(0,0,0,0.5);
}

.rivet.tl { top: 12px; left: 12px; }
.rivet.tr { top: 12px; right: 12px; }
.rivet.bl { bottom: 12px; left: 12px; }
.rivet.br { bottom: 12px; right: 12px; }

/* Stencil marks */
.stencil-mark {
    position: absolute;
    font-family: 'Black Ops One', monospace;
    color: rgba(245, 230, 163, 0.12);
    font-size: 50px;
    text-transform: uppercase;
    letter-spacing: 5px;
    pointer-events: none;
}

.stencil-mark.top-right {
    top: 50px;
    right: 25px;
    transform: rotate(5deg);
}

.stencil-mark.bottom-left {
    bottom: 50px;
    left: 25px;
    transform: rotate(-3deg);
}

h2 {
    font-family: 'Black Ops One', monospace;
    color: #f5e6a3;
    text-transform: uppercase;
    letter-spacing: 4px;
    font-size: 1.6rem;
    margin-bottom: 0.5rem;
    text-shadow:
        2px 2px 0 rgba(0,0,0,0.6),
        -1px -1px 0 rgba(0,0,0,0.3);
}

.subtitle {
    font-family: 'Special Elite', monospace;
    color: #c9b458;
    font-size: 0.85rem;
    letter-spacing: 2px;
    margin-bottom: 1.5rem;
    text-transform: uppercase;
    opacity: 0.8;
}

input[type="number"] {
    width: 100%;
    padding: 12px;
    font-size: 1.2rem;
    font-family: 'Special Elite', monospace;
    margin: 10px 0;
    border: 3px solid #1a2410;
    border-radius: 2px;
    box-sizing: border-box;
    text-align: center;
    background:
        repeating-linear-gradient(transparent, transparent 27px, rgba(107,155,209,0.3) 27px, rgba(107,155,209,0.3) 28px),
        #f5e6a3;
    color: #2d3a1f;
    box-shadow:
        inset 0 2px 4px rgba(0,0,0,0.2),
        0 2px 4px rgba(0,0,0,0.3);
}

input[type="number"]:focus {
    outline: none;
    border-color: #c9b458;
    background:
        repeating-linear-gradient(transparent, transparent 27px, rgba(107,155,209,0.3) 27px, rgba(107,155,209,0.3) 28px),
        #fff8dc;
}

input[type="number"]::placeholder {
    color: #8b7355;
    font-style: italic;
}

.result {
    font-family: 'Black Ops One', monospace;
    font-size: 1.8rem;
    font-weight: bold;
    color: #c9b458;
    margin-top: 15px;
    min-height: 50px;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.6);
    letter-spacing: 2px;
}

/* HIT / MISS shot buttons */
.shot-actions {
    display: flex;
    gap: 14px;
    justify-content: center;
    margin: 6px 0 4px;
}

.shot-btn {
    flex: 1;
    max-width: 160px;
    padding: 12px 0;
    font-family: 'Black Ops One', monospace;
    font-size: 1.1rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: #f5e6a3;
    border: 3px solid #1a2410;
    border-radius: 3px;
    cursor: pointer;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.6);
    box-shadow:
        inset 0 2px 4px rgba(255,255,255,0.2),
        inset 0 -3px 6px rgba(0,0,0,0.4),
        0 3px 6px rgba(0,0,0,0.5);
    transition: transform 0.12s ease, filter 0.12s ease;
}

.shot-btn:hover {
    filter: brightness(1.12);
}

.shot-btn:active {
    transform: translateY(2px);
    box-shadow:
        inset 0 2px 6px rgba(0,0,0,0.5),
        0 1px 2px rgba(0,0,0,0.5);
}

.hit-btn {
    background: linear-gradient(180deg, #5a8a35 0%, #3f6d1e 55%, #2e5216 100%);
}

.miss-btn {
    background: linear-gradient(180deg, #a83a2f 0%, #8a2a20 55%, #6d1f18 100%);
}

canvas {
    border: 3px solid #1a2410;
    border-radius: 2px;
    margin-top: 20px;
    max-width: 100%;
    box-shadow:
        inset 0 0 20px rgba(0,0,0,0.3),
        0 4px 8px rgba(0,0,0,0.4);
}

.info {
    font-family: 'Special Elite', monospace;
    font-size: 0.8rem;
    color: #c9b458;
    margin-top: 20px;
    text-align: left;
    background: rgba(0,0,0,0.3);
    padding: 12px;
    border-radius: 2px;
    line-height: 1.6;
    border-left: 4px solid #c9b458;
}

.info strong {
    color: #f5e6a3;
}

/* Shot History panel (right-side notepad) */
.history-panel {
    position: relative;
    width: 280px;
    z-index: 5;
    display: flex;
}

.history-paper {
    transform: rotate(1.5deg);
    padding: 20px 20px 20px 55px;
    overflow: hidden;
}

.history-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: #1a3a5c rgba(0,0,0,0.05);
}

.history-scroll::-webkit-scrollbar {
    width: 8px;
}

.history-scroll::-webkit-scrollbar-track {
    background: rgba(26, 58, 92, 0.1);
    border-radius: 4px;
}

.history-scroll::-webkit-scrollbar-thumb {
    background: #1a3a5c;
    border-radius: 4px;
}

.history-empty {
    font-family: 'Special Elite', monospace;
    color: #1a3a5c;
    font-size: 12px;
    font-style: italic;
    opacity: 0.6;
    line-height: 28px;
}

.history-entry {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Special Elite', monospace;
    color: #1a3a5c;
    font-size: 13px;
    line-height: 28px;
    border-bottom: 1px dashed rgba(26, 58, 92, 0.25);
}

.history-entry .hist-num {
    font-weight: bold;
    opacity: 0.7;
    min-width: 30px;
}

.history-entry .hist-data {
    flex: 1;
}

.history-entry .hist-status {
    font-family: 'Black Ops One', monospace;
    font-size: 11px;
    letter-spacing: 1px;
    padding: 1px 8px;
    border-radius: 3px;
    color: #f5e6a3;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.4);
}

.history-entry.hit .hist-status {
    background: #3f6d1e;
    border: 1px solid #234010;
}

.history-entry.miss .hist-status {
    background: #8a2a20;
    border: 1px solid #4d150f;
}

.clear-history-btn {
    margin-top: 12px;
    padding: 8px 0;
    width: 100%;
    font-family: 'Black Ops One', monospace;
    font-size: 0.75rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #f5e6a3;
    background: linear-gradient(180deg, #7a3b2f 0%, #5f2a20 55%, #491f18 100%);
    border: 2px solid #1a2410;
    border-radius: 3px;
    cursor: pointer;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.6);
    box-shadow:
        inset 0 2px 4px rgba(255,255,255,0.15),
        inset 0 -3px 6px rgba(0,0,0,0.4),
        0 3px 6px rgba(0,0,0,0.5);
    transition: transform 0.12s ease, filter 0.12s ease;
    flex-shrink: 0;
}

.clear-history-btn:hover {
    filter: brightness(1.15);
}

.clear-history-btn:active {
    transform: translateY(2px);
    box-shadow:
        inset 0 2px 6px rgba(0,0,0,0.5),
        0 1px 2px rgba(0,0,0,0.5);
}

/* Tour tooltips */
.tour-tooltip {
    position: absolute;
    background: linear-gradient(180deg, #5a6d33 0%, #4a5d23 50%, #3d4f1e 100%);
    border: 3px solid #1a2410;
    border-radius: 6px;
    padding: 15px;
    color: #f5e6a3;
    font-family: 'Special Elite', monospace;
    font-size: 13px;
    line-height: 1.5;
    box-shadow:
        0 6px 20px rgba(0,0,0,0.6),
        inset 0 2px 4px rgba(255,255,255,0.1);
    z-index: 2000;
    display: none;
    max-width: 250px;
}

.tour-tooltip.visible {
    display: block;
    animation: tooltipFadeIn 0.3s ease-out;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tour-tooltip::before {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    background: #5a6d33;
    border: 3px solid #1a2410;
    transform: rotate(45deg);
}

.tour-tooltip.arrow-left::before {
    left: -9px;
    top: 50%;
    margin-top: -6px;
    border-right: none;
    border-top: none;
}

.tour-tooltip.arrow-bottom::before {
    bottom: -9px;
    left: 50%;
    margin-left: -6px;
    border-left: none;
    border-top: none;
}

.tour-tooltip.arrow-top::before {
    top: -9px;
    left: 50%;
    margin-left: -6px;
    border-right: none;
    border-bottom: none;
}

.tour-tooltip .tooltip-title {
    font-family: 'Black Ops One', monospace;
    font-size: 14px;
    margin-bottom: 8px;
    color: #c9b458;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.tour-tooltip .tooltip-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: #c9b458;
    border: 2px solid #1a2410;
    border-radius: 50%;
    color: #1a2410;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.tour-tooltip .tooltip-close:hover {
    background: #f5e6a3;
    transform: scale(1.1);
}

.tour-tooltip .tooltip-close:active {
    transform: scale(0.95);
}

/* Tooltip positions are set dynamically in JS (anchored to their targets). */
#tooltip1,
#tooltip2 {
    position: fixed;
}

/* =========================================
   MOBILE RESPONSIVE STYLES (Max Width: 768px)
   ========================================= */
@media (max-width: 768px) {
    body {
        padding: 20px 15px;
        justify-content: flex-start;
        padding-top: 40px;
    }

    /* Hide non-essential desktop elements */
    .ad-banner,
    .table-panel,
    canvas,
    .info,
    .subtitle,
    .stencil-mark,
    .container::before { /* Hides the drawer connection line */
        display: none !important;
    }

    .main-wrapper {
        height: auto;
        width: 100%;
        flex-direction: column;
        align-items: center;
    }

    /* Scale down the Ammo Crate for mobile */
    .container {
        width: 100%;
        max-width: 500px;
        padding: 2rem 1.25rem;
        margin: 0;
        /* Simplify shadow to prevent edge clipping */
        box-shadow:
            inset 0 2px 4px rgba(255,255,255,0.1),
            inset 0 -2px 4px rgba(0,0,0,0.3),
            0 8px 20px rgba(0,0,0,0.5);
        border-radius: 8px;
    }

    .rivet { width: 16px; height: 16px; }
    .rivet.tl { top: 10px; left: 10px; }
    .rivet.tr { top: 10px; right: 10px; }
    .rivet.bl { bottom: 10px; left: 10px; }
    .rivet.br { bottom: 10px; right: 10px; }

    h2 {
        font-size: 1.4rem;
        letter-spacing: 2px;
        margin-bottom: 1.5rem;
    }

    /* Enlarge inputs and buttons for touch screens */
    input[type="number"] {
        font-size: 1.5rem;
        padding: 16px;
        margin: 15px 0;
    }

    .result {
        font-size: 1.6rem;
        margin: 20px 0 10px;
        min-height: 40px;
    }

    .shot-actions {
        gap: 12px;
        margin: 20px 0 10px;
    }

    .shot-btn {
        padding: 16px 0;
        font-size: 1.1rem;
    }

    /* --- Mobile History Overlay (Bottom Sheet) --- */
    .history-panel {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        z-index: 9999;
        background: rgba(45, 58, 31, 0.95); /* Darkened backdrop */
        display: flex;
        justify-content: center;
        align-items: center;

        /* Hidden off-screen by default */
        transform: translateY(100%);
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        pointer-events: none;
    }

    .history-panel.mobile-open {
        transform: translateY(0);
        pointer-events: auto;
    }

    .history-panel .history-paper {
        width: 92%;
        max-width: 450px;
        height: 85vh;
        max-height: 700px;
        transform: rotate(0deg); /* Flatten paper for mobile */
        padding: 30px 20px 20px 55px;
        display: flex;
        flex-direction: column;
        box-shadow: 0 15px 40px rgba(0,0,0,0.8);
    }

    .history-scroll {
        flex: 1;
        margin-bottom: 15px;
    }

    /* Floating Action Button for History */
    .history-toggle-btn {
        display: flex !important;
        position: fixed;
        bottom: 25px;
        right: 25px;
        width: 64px;
        height: 64px;
        border-radius: 50%;
        background: linear-gradient(180deg, #5a8a35 0%, #3f6d1e 100%);
        border: 4px solid #1a2410;
        color: #f5e6a3;
        font-family: 'Black Ops One', monospace;
        font-size: 28px;
        cursor: pointer;
        box-shadow: 0 6px 15px rgba(0,0,0,0.6);
        z-index: 1000;
        align-items: center;
        justify-content: center;
        transition: transform 0.2s;
    }

    .history-toggle-btn:active { transform: scale(0.92); }

    /* Close button inside the history modal */
    .close-history-btn {
        display: block !important;
        position: absolute;
        top: 12px;
        right: 12px;
        background: #8a2a20;
        border: 2px solid #1a2410;
        color: #f5e6a3;
        width: 32px;
        height: 32px;
        border-radius: 50%;
        font-family: 'Special Elite', monospace;
        font-size: 18px;
        font-weight: bold;
        cursor: pointer;
        z-index: 10;
        box-shadow: 0 2px 5px rgba(0,0,0,0.4);
    }
}

/* =========================================
   DESKTOP OVERRIDES (Min Width: 769px)
   ========================================= */
@media (min-width: 769px) {
    .history-toggle-btn,
    .close-history-btn {
        display: none !important;
    }

    /* Ensure history panel behaves normally on desktop */
    .history-panel {
        position: relative;
        width: 280px;
        transform: none;
        pointer-events: auto;
    }
}
