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

body {
    font-family: 'Arial', sans-serif;
    background: #000;
    color: #fff;
    overflow-x: hidden; /* Always prevent horizontal scrolling */
    overflow-y: hidden; /* Default to hidden for gameplay */
}

/* Allow scrolling when game selector is visible (home page) */
body.home-page {
    overflow-y: auto;
    overflow-x: hidden; /* Ensure horizontal scrolling stays disabled */
}

#game-container {
    position: relative;
    max-width: 720px;
    height: 100vh;
    margin: 0 auto;
}

#video-bounds {

}

#video-player {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 100vw;
    max-height: 100vh;
    display: block;
    z-index: 1;
    object-fit: contain; /* Fit video within viewport with black bars if needed */
    object-position: center center; /* Explicitly center the video content */
}

#overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 720px;
    height: 100vh;
    max-width: 100vw;
    /* max-height: 177.78vw; */
    display: flex;
    /* flex-direction: column; */
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 2;
    /*background: rgba(0,0,0,0.9);*/
}

#prompt-text {
    position: absolute;
    top: 40px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 2rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    padding: 20px;
    background: rgba(0,0,0,0.6);
    border-radius: 10px;
    margin-bottom: 20px;
    display: none;
    max-width: 80%;
    text-align: center;
    white-space: pre-line; /* Respect \n as line breaks while still wrapping */
}

#button-display {
    font-size: 2rem;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.8);
    padding: 15px;
    background: rgba(255,255,255,0.2);
    border: 3px solid #fff;
    border-radius: 15px;
    display: none;
    animation: pulse 0.5s infinite;
}

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

#progress-bar {
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 30px;
    background: rgba(255,255,255,0.2);
    border: 2px solid #fff;
    border-radius: 15px;
    overflow: hidden;
    display: none;
}

#progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    width: 0%;
    transition: width 0.1s linear;
}

#mash-counter {
    position: absolute;
    top: 50%;
    right: 50px;
    transform: translateY(-50%);
    font-size: 3rem;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.8);
    display: none;
}

#choice-menu {
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    flex-direction: column;
    gap: 15px;
    pointer-events: auto;
    max-width: 90vw; /* Prevent buttons from exceeding viewport width */
    width: max-content; /* Allow natural width up to max-width */
}

.choice-button {
    font-size: 1.5rem;
    padding: 15px 30px;
    background: rgba(255,255,255,0.2);
    border: 2px solid #fff;
    border-radius: 10px;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s;
    max-width: 100%; /* Prevent button from exceeding parent container */
    box-sizing: border-box;
}

.choice-button:hover {
    background: rgba(255,255,255,0.4);
    transform: scale(1.05);
}

.choice-button.selected {
    background: rgba(76,175,80,0.6);
    border-color: #4CAF50;
}

/* Game Selector - Thumbnail Grid */
#game-selector {
    position: fixed; /* Changed from absolute to fixed for better scrolling behavior */
    top: 0;
    left: 0;
    width: 100%;
    min-height: 100vh; /* Allow container to grow with content */
    background: rgba(0, 0, 0, 0.95);
    display: none; /* Hidden by default - shown only when needed */
    flex-direction: column;
    pointer-events: auto;
    overflow: visible; /* Allow content to flow naturally */
}

#game-selector.visible {
    display: flex;
}

#game-selector-header {
    padding: 25px 40px;
    background: rgba(0, 0, 0, 0.9);
    border-bottom: 3px solid rgba(255, 255, 255, 0.3);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    min-height: 90px; /* Ensure header has minimum height */
    backdrop-filter: blur(10px); /* Add subtle blur effect */
}

#game-selector-header h1 {
    font-size: 1.8rem;
    margin: 0;
}

.load-button {
    padding: 10px 20px;
    background: rgba(255,255,255,0.2);
    border: 2px solid #fff;
    border-radius: 5px;
    color: #fff;
    cursor: pointer;
    white-space: nowrap;
    font-size: 1rem;
}

.load-button:hover {
    background: rgba(255,255,255,0.4);
}

#thumbnail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(180px, 45%), 1fr));
    gap: 20px;
    padding: 20px;
    max-width: 100%;
    min-height: calc(100vh - 140px); /* Ensure minimum height minus header */
    overflow: visible; /* Content flows naturally with body scroll */
    align-content: start;
}

/* Custom scrollbar for body when in home page mode */
body.home-page::-webkit-scrollbar {
    width: 8px;
}

body.home-page::-webkit-scrollbar-track {
    background: transparent;
}

body.home-page::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

body.home-page::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.game-thumbnail {
    position: relative;
    width: 100%; /* Take full grid cell width */
    aspect-ratio: 1 / 1; /* Maintain square ratio */
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    border: 3px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.game-thumbnail:hover {
    transform: scale(1.08) translateY(-5px);
    box-shadow: 0 12px 25px rgba(255, 255, 255, 0.4);
    border-color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.1);
    z-index: 10;
}

.game-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}


.loading-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.6);
}

#loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    pointer-events: none;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 6px solid rgba(255,255,255,0.3);
    border-top: 6px solid #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Click to Start Overlay */
#click-to-start {
    position: absolute;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    pointer-events: auto;
    z-index: 9999;
}

#click-to-start.visible {
    display: flex;
}

.click-to-start-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 15vh;
}

.click-to-start-text {
    display: inline-block;
    padding: 20px 60px;
    font-size: 1.5rem;
    font-weight: bold;
    color: #fff;
    text-transform: uppercase;
    border: 3px solid #fff;
    border-radius: 15px;
    background: linear-gradient(90deg, #007bff 0%, #ff7bd5 50%, #ffa347 100%);
    cursor: pointer;
    transition: all 0.3s ease;
    text-shadow: 2px 2px 8px rgba(0,0,0,0.4);
    box-shadow: 0 4px 10px rgba(0,0,0,0.25);
}

.click-to-start-text:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0,0,0,0.35);
}

.click-to-start-text:active {
    transform: scale(0.97);
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* Game End / Retry Button */
#game-end-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    pointer-events: auto;
    z-index: 10000;
    width: 80%;
}

#game-end-container.visible {
    display: flex;
}

#game-end-message {
    font-size: 2rem;
    font-weight: bold;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    padding: 20px;
    background: rgba(0,0,0,0.6);
    border-radius: 10px;
}

.beam-logo {
    img {
        height: 100px;
    }
}

#retry-button {
    width: 100%;
    font-size: 1.3rem;
    font-weight: bold;
    padding: 20px 40px;
    background: rgba(255,255,255,0.1);
    border: 3px solid #fff;
    border-radius: 15px;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s;
    text-shadow: 2px 2px 8px rgba(0,0,0,0.8);
    animation: pulse 1.5s infinite;
}

#retry-button:hover {
    background: rgba(255,255,255,0.2);
    transform: scale(1.05);
}

#play-another-button {
    font-size: 1.3rem;
    font-weight: bold;
    padding: 20px 60px;
    background: linear-gradient(90deg, #7b2ff7 0%, #f107a3 100%);
    border: 3px solid #fff;
    border-radius: 15px;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    text-shadow: 2px 2px 8px rgba(0,0,0,0.6);
    box-shadow: 0 4px 10px rgba(0,0,0,0.25);
    text-transform: uppercase;
    width: 100%;
}

#play-another-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0,0,0,0.35);
}

#play-another-button:active {
    transform: scale(0.97);
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* ===== New Interaction Styles ===== */

#build-your-own-button {
    font-size: 1.3rem;
    font-weight: bold;
    padding: 20px 60px;
    background: linear-gradient(90deg, #00c851 0%, #007bff 100%);
    border: 3px solid #fff;
    border-radius: 15px;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    text-shadow: 2px 2px 8px rgba(0,0,0,0.6);
    box-shadow: 0 4px 10px rgba(0,0,0,0.25);
    width: 100%;
}

#build-your-own-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0,0,0,0.35);
}

#build-your-own-button:active {
    transform: scale(0.97);
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* Stop Bar */
#stop-bar-container {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    width: 70%;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

#stop-bar-track {
    position: relative;
    width: 100%;
    height: 40px;
    background: rgba(255,255,255,0.2);
    border: 3px solid #fff;
    border-radius: 20px;
    overflow: visible;
}

#stop-bar-zones {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.stop-bar-zone {
    position: absolute;
    top: 0;
    height: 100%;
    background: rgba(76,175,80,0.4);
    border-left: 2px solid #4CAF50;
    border-right: 2px solid #4CAF50;
}

#stop-bar-indicator {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 50px;
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 0 10px rgba(255,255,255,0.8);
    transition: none;
}

#stop-bar-indicator.stopped {
    width: 12px;
    height: 60px;
}

#stop-bar-indicator.stopped.success {
    background: #4CAF50;
    box-shadow: 0 0 15px rgba(76,175,80,1);
}

#stop-bar-indicator.stopped.failure {
    background: #f44336;
    box-shadow: 0 0 15px rgba(244,67,54,1);
}

#stop-bar-prompt {
    font-size: 1.5rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    color: #fff;
}

/* Swipe Indicator */
#swipe-indicator {
    display: none;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 20px;
    font-size: 2rem;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.8);
}

.swipe-arrow {
    display: inline-block;
    transition: all 0.3s;
}

.swipe-arrow.current {
    animation: pulse 0.5s infinite;
    color: #fff;
}

.swipe-arrow.completed {
    color: #4CAF50;
    opacity: 1.0;
    text-shadow: 0 0 10px rgba(76, 175, 80, 0.8);
}

/* Double Tap Indicator */
#double-tap-indicator {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.double-tap-prompt {
    font-size: 2rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    padding: 15px 30px;
    background: rgba(255,255,255,0.2);
    border: 2px solid #fff;
    border-radius: 10px;
}

.double-tap-dots {
    display: flex;
    gap: 20px;
}

.tap-dot {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid #fff;
    background: rgba(255,255,255,0.2);
    transition: all 0.2s;
}

.tap-dot.filled {
    background: #fff;
    box-shadow: 0 0 15px rgba(255,255,255,0.8);
}

.double-tap-result {
    font-size: 2.5rem;
    font-weight: bold;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.8);
    padding: 20px 40px;
    border-radius: 15px;
    animation: resultPop 0.3s ease-out;
}

.double-tap-result.success {
    color: #4CAF50;
    background: rgba(76,175,80,0.3);
    border: 3px solid #4CAF50;
}

.double-tap-result.failure {
    color: #f44336;
    background: rgba(244,67,54,0.3);
    border: 3px solid #f44336;
}

@keyframes resultPop {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* ===== Phase 2 Interaction Styles ===== */

/* Charge Bar */
#charge-bar-container {
    position: absolute;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

#charge-bar-track {
    position: relative;
    width: 100%;
    height: 40px;
    background: rgba(255,255,255,0.2);
    border: 3px solid #fff;
    border-radius: 20px;
    overflow: hidden;
}

#charge-bar-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #2196F3, #03A9F4);
    transition: width 0.05s linear;
}

#charge-bar-fill.charging {
    box-shadow: 0 0 20px rgba(33,150,243,0.8);
}

#charge-bar-fill.overcharged {
    background: linear-gradient(90deg, #f44336, #ff5722);
    box-shadow: 0 0 20px rgba(244,67,54,1);
}

#charge-bar-zones {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.charge-bar-zone.target {
    position: absolute;
    top: 0;
    height: 100%;
    background: rgba(76,175,80,0.4);
    border-left: 2px solid #4CAF50;
    border-right: 2px solid #4CAF50;
}

.charge-bar-zone.overcharge {
    position: absolute;
    top: 0;
    height: 100%;
    background: rgba(244,67,54,0.3);
    border-left: 3px solid #f44336;
}

#charge-bar-prompt {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 20px;
    font-size: 1.5rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    color: #fff;
    white-space: nowrap;
}

#charge-bar-result {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 20px;
    font-size: 2.5rem;
    font-weight: bold;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.8);
    padding: 15px 30px;
    border-radius: 15px;
    animation: resultPop 0.3s ease-out;
    display: none;
    white-space: nowrap;
}

#charge-bar-result.success {
    color: #4CAF50;
    background: rgba(76,175,80,0.3);
    border: 3px solid #4CAF50;
}

#charge-bar-result.failure {
    color: #f44336;
    background: rgba(244,67,54,0.3);
    border: 3px solid #f44336;
}

/* Target Click */
#target-click-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    pointer-events: none;
}

.target-dot {
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    border: 3px solid #fff;
    box-shadow: 0 0 15px rgba(255,255,255,0.6);
    transform: translate(-50%, -50%);
    transition: all 0.2s;
    animation: targetPulse 1s infinite;
}

.target-dot.current {
    background: rgba(255,235,59,0.4);
    border-color: #FFEB3B;
    box-shadow: 0 0 25px rgba(255,235,59,1);
    animation: targetPulse 0.5s infinite;
}

.target-dot.hit {
    background: rgba(76,175,80,0.6);
    border-color: #4CAF50;
    animation: targetHit 0.3s ease-out;
    pointer-events: none;
}

@keyframes targetPulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.1); }
}

@keyframes targetHit {
    0% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
}

#target-click-hud {
    position: absolute;
    top: 50%;
    right: 50px;
    transform: translateY(-50%);
    font-size: 3rem;
    font-weight: bold;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.8);
    display: none;
    color: #fff;
}

/* ===== Phase 3 Interaction Styles ===== */

/* Rapid Tap */
#rapid-tap-container {
    position: absolute;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

#rapid-tap-track {
    position: relative;
    width: 100%;
    height: 40px;
    background: rgba(255,255,255,0.2);
    border: 3px solid #fff;
    border-radius: 20px;
    overflow: hidden;
}

#rapid-tap-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #FF6B6B, #FFE66D);
    transition: width 0.1s ease-out;
    box-shadow: 0 0 20px rgba(255,107,107,0.8);
}

#rapid-tap-prompt {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 20px;
    font-size: 2rem;
    font-weight: bold;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.8);
    color: #fff;
    white-space: nowrap;
    animation: pulse 0.5s infinite;
}

/* Trace Line */
#trace-line-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    display: none;
    pointer-events: all;
}

#trace-line-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: all;
    touch-action: none; /* Prevent Safari touch handling interference */
    user-select: none; /* Prevent text selection during drag */
    -webkit-user-select: none;
    -webkit-touch-callout: none; /* Prevent Safari long-press menu */
    z-index: 10; /* Ensure canvas is above video */
    border: 3px solid red; /* DEBUG: Make canvas visible */
}

#trace-line-hud {
    position: absolute;
    top: 40px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.5rem;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    padding: 10px 20px;
    background: rgba(0,0,0,0.6);
    border-radius: 10px;
    pointer-events: none;
}

.trace-line-deviation {
    color: #fff;
    transition: color 0.2s;
}

.trace-line-deviation.safe {
    color: #4CAF50;
}

.trace-line-deviation.warning {
    color: #FF9800;
}

.trace-line-deviation.danger {
    color: #f44336;
}

.trace-line-result {
    margin-top: 10px;
    font-size: 2rem;
    animation: resultPop 0.3s ease-out;
}

.trace-line-result.failure {
    color: #f44336;
}

#trace-line-svg {
    width: 100%;
    height: 100%;
}

.trace-path {
    fill: none;
    stroke: #4CAF50;
    stroke-width: 6;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0.6;
}

.trace-path-outline {
    fill: none;
    stroke: rgba(255,255,255,0.3);
    stroke-width: 12;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.trace-drawn {
    fill: none;
    stroke: #2196F3;
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.trace-drawn.failed {
    stroke: #f44336;
}

.trace-point {
    fill: #fff;
    stroke: #4CAF50;
    stroke-width: 2;
}

/* Phase 4: Dice and Input Interactions */

/* Dice Roll */
#dice-roll-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    background: rgba(0, 0, 0, 0.85);
    padding: 40px 60px;
    border-radius: 15px;
    border: 3px solid #4CAF50;
}

#dice-display {
    display: flex;
    gap: 15px;
}

.die {
    width: 80px;
    height: 80px;
    background: white;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    font-weight: bold;
    color: #333;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    animation: diceRoll 0.5s ease-out;
}

@keyframes diceRoll {
    0% { transform: rotate(0deg) scale(0.5); }
    50% { transform: rotate(360deg) scale(1.2); }
    100% { transform: rotate(720deg) scale(1); }
}

#dice-total {
    font-size: 36px;
    color: #4CAF50;
    font-weight: bold;
}

/* RPG Dice */
#rpg-dice-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    background: rgba(0, 0, 0, 0.9);
    padding: 40px 60px;
    border-radius: 15px;
    border: 3px solid #9C27B0;
}

#rpg-dice-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.rpg-die-label {
    font-size: 24px;
    color: #9C27B0;
    font-weight: bold;
}

.rpg-dice-rolls {
    display: flex;
    gap: 10px;
}

.rpg-die {
    min-width: 70px;
    height: 70px;
    background: linear-gradient(145deg, #b39ddb, #7b1fa2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: bold;
    color: white;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
    animation: diceRoll 0.6s ease-out;
}

#rpg-dice-result {
    font-size: 32px;
    color: white;
    font-weight: bold;
}

.rpg-dice-modifier {
    color: #9C27B0;
}

.rpg-dice-target {
    margin-top: 10px;
    font-size: 20px;
    color: #aaa;
}

.rpg-dice-success {
    color: #4CAF50;
}

.rpg-dice-failure {
    color: #f44336;
}

/* Random Value */
#random-value-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    background: rgba(0, 0, 0, 0.85);
    padding: 40px 60px;
    border-radius: 15px;
    border: 3px solid #FF9800;
}

#random-value-display {
    font-size: 48px;
    font-weight: bold;
    color: #FF9800;
}

.random-value-result {
    font-size: 32px;
    font-weight: bold;
}

.random-value-result.success {
    color: #4CAF50;
}

.random-value-result.failure {
    color: #f44336;
}

/* Number Input */
#number-input-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    background: rgba(0, 0, 0, 0.9);
    padding: 30px;
    border-radius: 15px;
    border: 3px solid #2196F3;
    z-index: 1000;
    pointer-events: auto;
}

#number-input-display {
    font-size: 64px;
    font-weight: bold;
    color: #2196F3;
    min-width: 200px;
    text-align: center;
    padding: 20px;
    background: rgba(33, 150, 243, 0.1);
    border-radius: 10px;
    border: 2px solid #2196F3;
}

#number-input-keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.number-key {
    width: 80px;
    height: 80px;
    font-size: 32px;
    font-weight: bold;
    background: rgba(33, 150, 243, 0.2);
    border: 2px solid #2196F3;
    border-radius: 10px;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
}

.number-key:hover {
    background: rgba(33, 150, 243, 0.4);
    transform: scale(1.05);
}

.number-key:active {
    transform: scale(0.95);
    background: rgba(33, 150, 243, 0.6);
}

.number-key.backspace {
    background: rgba(255, 152, 0, 0.2);
    border-color: #FF9800;
    color: #FF9800;
}

.number-key.backspace:hover {
    background: rgba(255, 152, 0, 0.4);
}

.number-key.confirm {
    background: rgba(76, 175, 80, 0.2);
    border-color: #4CAF50;
    color: #4CAF50;
}

.number-key.confirm:hover {
    background: rgba(76, 175, 80, 0.4);
}

#number-input-container.confirmed #number-input-display {
    border-color: #4CAF50;
    color: #4CAF50;
}

/* Mobile responsive styles */
@media (max-width: 768px) {
    #prompt-text {
        font-size: 1.2rem;
        padding: 12px 16px;
        max-width: 90%;
        width: 90%;
        top: 20px;
        white-space: pre-line; /* Keep newline handling on mobile */
        word-wrap: break-word;
        overflow-wrap: break-word;
        box-sizing: border-box;
    }

    .choice-button {
        font-size: 1.1rem;
        padding: 10px 16px;
        white-space: normal;
        word-wrap: break-word;
    }

    #choice-menu {
        position: absolute;
        left: 5%;
        right: 5%;
        bottom: 2vh;
        width: auto;
        max-width: 90vw;
        transform: none;
        gap: 10px;
        max-height: 25vh;
        overflow-y: auto;
        overflow-x: hidden; /* Prevent horizontal scrolling on mobile */
        padding: 8px;
        box-sizing: border-box;
    }

    #mash-counter {
        top: 35%;
        left: 50%;
        right: auto;
        transform: translate(-50%, -50%);
        font-size: 2.5rem;
    }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
    #prompt-text {
        font-size: 1rem;
        padding: 10px 12px;
        top: 10px;
    }

    .choice-button {
        font-size: 1rem;
        padding: 10px 14px;
    }

    #choice-menu {
        bottom: 11vh;
        gap: 6px;
        max-height: 20vh;
        padding: 6px;
    }

    #mash-counter {
        font-size: 2rem;
    }
}
