:root {
    --bg-color: #000;
    --text-color: #fff;
    --border-color: rgba(255, 255, 255, 0.2);
    --highlight-color: rgba(255, 255, 255, 0.1);
    --accent-color: #fff;
    --shadow-color: rgba(255, 255, 255, 0.05);
    --transition-time: 0.4s;
    --switch-width: 34px;
    --switch-height: 18px;
    --thumb-size: 14px;
    --switch-bg: #333;
    --switch-active-bg: #444;
    --grid-line-width: 2px;
    --board-max-width: 260px;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    padding-bottom: 100px;
    padding-top: 80px;
    overflow-x: hidden;
    box-sizing: border-box;
}

.container {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin: 0 auto;
    padding-top: 0;
    padding-bottom: 80px;
    overflow: visible;
    position: relative;
    flex: 1;
}

.game-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    position: relative;
}

/* Game Board Styles */
.game-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 0;
    aspect-ratio: 1/1;
    margin: 0 auto;
    max-width: var(--board-max-width);
    width: 100%;
    position: relative;
    background-image: 
        linear-gradient(to right, transparent 33%, rgba(255, 255, 255, 0.7) 33%, rgba(255, 255, 255, 0.7) calc(33% + var(--grid-line-width)), transparent calc(33% + var(--grid-line-width))),
        linear-gradient(to right, transparent 66%, rgba(255, 255, 255, 0.7) 66%, rgba(255, 255, 255, 0.7) calc(66% + var(--grid-line-width)), transparent calc(66% + var(--grid-line-width))),
        linear-gradient(to bottom, transparent 33%, rgba(255, 255, 255, 0.7) 33%, rgba(255, 255, 255, 0.7) calc(33% + var(--grid-line-width)), transparent calc(33% + var(--grid-line-width))),
        linear-gradient(to bottom, transparent 66%, rgba(255, 255, 255, 0.7) 66%, rgba(255, 255, 255, 0.7) calc(66% + var(--grid-line-width)), transparent calc(66% + var(--grid-line-width)));
    background-size: 100% 100%;
    background-repeat: no-repeat;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    overflow: hidden;
}

.cell {
    background-color: transparent;
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    aspect-ratio: 1/1;
    font-size: 2.5rem;
    font-weight: 700;
    cursor: pointer;
    position: relative;
    z-index: 2;
    -webkit-tap-highlight-color: transparent !important;
    outline: none;
    user-select: none;
    transition: none;
}

/* Remove focus/active state styling */
.cell:focus,
.cell:active,
.cell:hover {
    background-color: transparent;
    outline: none;
    box-shadow: none;
}

/* Complete X redesign with more subtle animations */
.cell.x {
    position: relative;
    z-index: 3;
    animation: markFadeIn 0.2s ease-out forwards;
}

@keyframes markFadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

.cell.x::before, 
.cell.x::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 70%;
    height: 3px;
    background-color: var(--text-color);
    border-radius: 1.5px;
    transition: opacity 0.2s ease-in-out;
}

.cell.x::before {
    transform: translate(-50%, -50%) rotate(45deg);
    animation: drawX1 0.2s ease-out forwards;
}

.cell.x::after {
    transform: translate(-50%, -50%) rotate(-45deg);
    animation: drawX2 0.2s ease-out forwards;
    animation-delay: 0.1s;
    transition: opacity 0.2s ease-in-out;
}

@keyframes drawX1 {
    0% { 
        transform: translate(-50%, -50%) rotate(45deg) scaleX(0);
        opacity: 1;
    }
    100% { 
        transform: translate(-50%, -50%) rotate(45deg) scaleX(1);
        opacity: 1;
    }
}

@keyframes drawX2 {
    0% { 
        transform: translate(-50%, -50%) rotate(-45deg) scaleX(0);
        opacity: 1;
    }
    100% { 
        transform: translate(-50%, -50%) rotate(-45deg) scaleX(1);
        opacity: 1;
    }
}

/* Completely revised O mark for better reliability */
.cell.o {
    position: relative;
    z-index: 3;
}

.cell.o::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60%;
    height: 60%;
    border: 3px solid var(--text-color);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 1;
    will-change: transform, opacity, border-color;
    transition: opacity 0.2s ease-in-out;
}

/* Make O always visible from the start, then animate in */
.cell.o::before {
    animation: oAppear 0.3s ease-out forwards;
}

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

/* X additional animations - more subtle */
.cell.x.animated::before {
    animation: subtleGlowX 1.5s ease-out forwards;
}

.cell.x.animated::after {
    animation: subtleGlowX 1.5s ease-out forwards;
    animation-delay: 0.1s;
}

@keyframes subtleGlowX {
    0% { 
        box-shadow: 0 0 0px rgba(255, 255, 255, 0); 
        opacity: 1;
    }
    30% { 
        box-shadow: 0 0 2px rgba(255, 255, 255, 0.3); 
        opacity: 1;
    }
    100% { 
        box-shadow: 0 0 0px rgba(255, 255, 255, 0); 
        opacity: 1;
    }
}

/* O additional animations - more subtle */
.cell.o.animated::before {
    animation: subtleGlowO 1.5s ease-out forwards;
    animation-play-state: running;
}

@keyframes subtleGlowO {
    0% { 
        border-color: var(--text-color); 
        opacity: 1;
    }
    30% { 
        border-color: rgba(255, 255, 255, 0.6); 
        opacity: 0.5;
    }
    100% { 
        border-color: var(--text-color); 
        opacity: 1;
    }
}

/* Shadow effect animation */
.cell.shadow-burst::before, .cell.shadow-burst::after {
    animation: subtleShadowBurst 0.5s ease-out forwards;
}

@keyframes subtleShadowBurst {
    0% { filter: drop-shadow(0 0 0px rgba(255, 255, 255, 0)); }
    50% { filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.3)); }
    100% { filter: drop-shadow(0 0 0px rgba(255, 255, 255, 0)); }
}

/* Refined spin-in animation for X */
.cell.x.spin-in::before {
    animation: spinInX1 0.3s ease-out forwards;
}

.cell.x.spin-in::after {
    animation: spinInX2 0.3s ease-out forwards;
    animation-delay: 0.05s;
}

@keyframes spinInX1 {
    0% { 
        transform: translate(-50%, -50%) rotate(0deg) scaleX(0);
        opacity: 0;
    }
    100% { 
        transform: translate(-50%, -50%) rotate(45deg) scaleX(1);
        opacity: 1;
    }
}

@keyframes spinInX2 {
    0% { 
        transform: translate(-50%, -50%) rotate(0deg) scaleX(0);
        opacity: 0;
    }
    100% { 
        transform: translate(-50%, -50%) rotate(-45deg) scaleX(1);
        opacity: 1;
    }
}

/* Subtle color effects */
.cell.color-flash {
    animation: subtleColorFlash 0.7s forwards;
}

@keyframes subtleColorFlash {
    0% { filter: brightness(1); }
    30% { filter: brightness(1.1); }
    100% { filter: brightness(1); }
}

/* Gentle float animation */
.cell.floating {
    animation: gentleFloat 2s ease-in-out infinite;
}

@keyframes gentleFloat {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-2px); }
    100% { transform: translateY(0px); }
}

/* Refined fade out animations */
.cell.fading.x::before,
.cell.fading.x::after {
    height: 2px;
    background-image: linear-gradient(to right, rgba(255, 128, 128, 0.9) 50%, transparent 50%);
    background-position: 0 0;
    background-size: 10px 10px;
    animation: fadeOutX 0.4s forwards;
}

/* Restore rotation variables */
.cell.fading.x::before {
    --rotation: 45deg;
}

.cell.fading.x::after {
    --rotation: -45deg;
}

@keyframes fadeOutX {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) rotate(var(--rotation)) scaleX(1);
        background-color: var(--text-color);
        background-image: none;
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) rotate(var(--rotation)) scaleX(0.7);
        background-color: transparent;
        background-image: linear-gradient(to right, rgba(255, 128, 128, 1) 50%, transparent 50%);
        height: 2px;
    }
}

.cell.fading.o::before {
    animation: fadeOutO 0.4s forwards;
    opacity: 1;
}

@keyframes fadeOutO {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
        border-color: var(--text-color);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(0.7);
        border-color: rgba(255, 128, 128, 1);
        border-width: 2px;
        border-style: dashed;
    }
}

/* Style for next-to-fade indicators - light red with striped pattern */
.cell.next-to-fade.x::before, 
.cell.next-to-fade.x::after {
    animation: redStripedIndicatorX 0.3s ease-out forwards;
}

.cell.next-to-fade.o::before {
    animation: redStripedIndicatorO 0.3s ease-out forwards;
}

@keyframes redStripedIndicatorX {
    0% { 
        background-color: var(--text-color);
    }
    100% { 
        background-color: #ff6b6b;
    }
}

@keyframes redStripedIndicatorO {
    0% {
        border-color: var(--text-color);
    }
    100% {
        border-color: #ff6b6b;
    }
}

/* Make winning marks more obvious */
.cell.winning.x::before, 
.cell.winning.x::after {
    background-color: rgba(255, 255, 255, 0.9);
    height: 4px;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.7);
    animation: pulseLine 1.5s infinite;
}

.cell.winning.o::before {
    opacity: 1 !important;
    border-color: rgba(255, 255, 255, 0.9);
    border-width: 4px;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.7);
    animation: pulseCircle 1.5s infinite;
}

@keyframes pulseLine {
    0% {
        box-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
    }
    50% {
        box-shadow: 0 0 15px rgba(255, 255, 255, 0.8);
    }
    100% {
        box-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
    }
}

@keyframes pulseCircle {
    0% {
        box-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
    }
    50% {
        box-shadow: 0 0 15px rgba(255, 255, 255, 0.8);
    }
    100% {
        box-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
    }
}

/* Remove zoom bounce effect */
.cell.zoom-bounce {
    animation: none;
}

@keyframes zoomBounce {
    0% { opacity: 0; }
    100% { opacity: 0; }
}

/* Remove shimmer effect */
.cell.shimmer::before::after, .cell.shimmer::after::after {
    display: none;
}

@keyframes shimmerEffect {
    0% { opacity: 0; }
    100% { opacity: 0; }
}

.game-controls {
    display: flex;
    justify-content: center;
    margin-top: 1.5rem;
    width: 100%;
    position: relative;
    padding-bottom: 0;
}

#reset-btn {
    background-color: transparent;
    color: var(--text-color);
    border: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    opacity: 0;
    position: fixed;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%) scale(0.8);
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 10;
}

#reset-btn.reset-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(5px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

#reset-btn:hover {
    opacity: 1;
    transform: translateX(-50%) scale(1.1);
}

#reset-btn svg {
    width: 24px;
    height: 24px;
}

#reset-btn.hidden {
    display: none;
}

/* General hidden class */
.hidden {
    display: none;
}

/* Show the reset button with animation when game ends */
#reset-btn:not(.hidden) {
    opacity: 0.8;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: translateX(-50%) scale(0.95);
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.3);
    }
    70% {
        transform: translateX(-50%) scale(1);
        box-shadow: 0 0 0 8px rgba(255, 255, 255, 0);
    }
    100% {
        transform: translateX(-50%) scale(0.95);
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
    }
}

/* Modern Switch Toggle */
.switch-container {
    position: fixed;
    top: 25px;
    right: 15px;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 100;
    background-color: rgba(0, 0, 0, 0.8);
    padding: 4px 8px;
    border-radius: 12px;
    -webkit-tap-highlight-color: transparent;
}

.switch-label {
    color: var(--text-color);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    min-width: 30px;
    text-align: right;
    position: relative;
    overflow: hidden;
    display: inline-block;
}

/* Mode text animations - only apply to switch container elements */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes glowPulse {
    0% {
        text-shadow: 0 0 0 rgba(255, 255, 255, 0);
    }
    50% {
        text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
    }
    100% {
        text-shadow: 0 0 0 rgba(255, 255, 255, 0);
    }
}

.switch-container .switch-label {
    animation: glowPulse 2s infinite;
}

.switch-container.text-changing .switch-label {
    animation: fadeOutDown 0.3s forwards;
}

.switch-container.text-changed .switch-label {
    animation: fadeInUp 0.3s forwards;
}

.switch {
    position: relative;
    width: var(--switch-width);
    height: var(--switch-height);
    background-color: var(--switch-bg);
    border-radius: 999px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
    padding: 0 2px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

.switch.checked {
    background-color: var(--switch-active-bg);
}

.switch-thumb {
    position: absolute;
    left: 2px;
    width: var(--thumb-size);
    height: var(--thumb-size);
    background-color: var(--text-color);
    border-radius: 50%;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.switch.checked .switch-thumb {
    transform: translateX(calc(var(--switch-width) - var(--thumb-size) - 4px));
}

/* Disable highlight on touch/click for all interactive elements */
button, 
input, 
select, 
textarea, 
[role="button"],
.cell {
    -webkit-tap-highlight-color: transparent !important;
    outline: none;
}

/* Responsiveness */
@media (max-width: 480px) {
    body {
        padding-top: 70px; /* Slightly less on mobile */
    }
    
    .switch-container {
        top: 20px;
    }
    
    .cell {
        min-height: 60px;
    }
    :root {
        --board-max-width: 220px;
    }
    
    .container {
        padding-bottom: 100px;
    }
    
    .game-controls {
        padding-bottom: 0;
    }
    
    #reset-btn {
        bottom: 60px;
    }
    
    #reset-btn.reset-icon {
        width: 40px;
        height: 40px;
    }
    
    #reset-btn svg {
        width: 22px;
        height: 22px;
    }
}

/* Score display */
.score-container {
    position: fixed;
    bottom: 15px;
    right: 15px;
    background-color: rgba(0, 0, 0, 0.7);
    color: var(--text-color);
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 20;
    user-select: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.3s ease;
}

.score-container:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

.score-container.resetting {
    background-color: rgba(50, 50, 50, 0.8);
    transform: scale(1.05);
}

.score-divider {
    margin: 0 3px;
    opacity: 0.7;
}

#player1-score, #player2-score {
    font-weight: 600;
    min-width: 10px;
    text-align: center;
}

/* Tooltip */
.tooltip {
    position: fixed;
    bottom: 45px;
    right: 15px;
    background-color: rgba(0, 0, 0, 0.9);
    color: var(--text-color);
    font-size: 11px;
    padding: 6px 10px;
    border-radius: 6px;
    z-index: 25;
    pointer-events: none;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    max-width: 150px;
    text-align: center;
    white-space: nowrap;
    visibility: hidden;
}

.tooltip::after {
    content: '';
    position: absolute;
    bottom: -5px;
    right: 15px;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid rgba(0, 0, 0, 0.9);
}

.tooltip.visible {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
}

@media (max-width: 480px) {
    .score-container {
        bottom: 10px;
        right: 10px;
        font-size: 11px;
        padding: 4px 8px;
    }
    
    .tooltip {
        bottom: 40px;
        right: 10px;
        font-size: 10px;
    }
}

/* Ensure O marks are always visible */
.cell.o.visible::before {
    opacity: 1 !important;
    visibility: visible !important;
}

/* Override any animations that might cause O disappearance */
.cell.o::before {
    -webkit-backface-visibility: visible !important;
    backface-visibility: visible !important;
    visibility: visible !important;
}

/* Info icon */
.info-icon {
    position: fixed;
    bottom: 15px;
    left: 15px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background-color: rgba(20, 20, 20, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 100;
    padding: 4px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.info-icon svg {
    color: var(--text-color);
    opacity: 0.9;
    width: 16px;
    height: 16px;
}

/* Info tooltip */
.info-tooltip {
    position: fixed;
    bottom: 50px;
    left: 15px;
    background-color: rgba(10, 10, 10, 0.95);
    color: var(--text-color);
    border-radius: 8px;
    z-index: 150;
    opacity: 0;
    transform: translateY(10px) scale(0.95);
    transition: opacity 0.3s ease, transform 0.3s ease;
    width: 250px;
    max-width: 80vw;
    font-size: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    visibility: hidden;
    pointer-events: none;
}

.info-tooltip.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    visibility: visible;
    pointer-events: auto;
}

.info-content {
    padding: 12px;
}

.info-content h3 {
    margin: 0 0 8px 0;
    font-size: 14px;
    font-weight: 600;
    opacity: 0.9;
}

.info-content ul {
    margin: 0;
    padding-left: 18px;
    list-style-type: disc;
    line-height: 1.4;
    opacity: 0.8;
}

.info-content li {
    margin-bottom: 5px;
}

.tooltip-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.dont-show-again {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    opacity: 0.7;
    cursor: pointer;
}

.dont-show-again input {
    margin: 0;
    cursor: pointer;
}

#close-tooltip {
    background-color: rgba(255, 255, 255, 0.2);
    color: var(--text-color);
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

#close-tooltip:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

/* Styled "Got it" button */
.got-it-btn {
    background-color: rgba(255, 255, 255, 0.15);
    color: var(--text-color);
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 100px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.got-it-btn:hover {
    background-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.got-it-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Mobile adjustments */
@media (max-width: 480px) {
    .info-icon {
        bottom: 10px;
        left: 10px;
        width: 22px;
        height: 22px;
    }
    
    .info-tooltip {
        bottom: 40px;
        left: 10px;
        font-size: 11px;
        max-width: 90vw;
    }
}

/* Score info tooltip positioning */
#score-info-tooltip {
    bottom: 50px;
    left: auto;
    right: 15px;
}

/* Add a pointer to the score tooltip */
#score-info-tooltip::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid rgba(10, 10, 10, 0.95);
}

@media (max-width: 480px) {
    #score-info-tooltip {
        bottom: 40px;
        right: 10px;
    }
}

/* Remove difficulty selector styles since we're only using hard mode now */
.difficulty-selector {
    display: none;
}

.difficulty-options {
    display: none;
}

.difficulty-option {
    display: none;
}

body.human-mode .difficulty-selector {
    display: none;
}

@media (max-width: 480px) {
    .difficulty-selector {
        display: none;
    }
    
    .difficulty-option {
        display: none;
    }
}

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

.api-key-modal.hidden {
    display: none;
}

.modal-content {
    background-color: #111;
    border-radius: 12px;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.modal-content h3 {
    margin: 0 0 1rem 0;
    color: var(--text-color);
    font-size: 1.5rem;
    text-align: center;
}

.modal-content p {
    margin: 0 0 1rem 0;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.5;
}

#api-key-input {
    width: 100%;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    font-size: 14px;
    margin-bottom: 1.5rem;
    box-sizing: border-box;
}

#api-key-input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.6);
    background-color: rgba(255, 255, 255, 0.15);
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 1rem;
}

.api-button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.api-button:not(.secondary) {
    background-color: rgba(255, 255, 255, 0.9);
    color: #000;
}

.api-button:not(.secondary):hover {
    background-color: rgba(255, 255, 255, 1);
    transform: translateY(-1px);
}

.api-button.secondary {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.api-button.secondary:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.api-help {
    font-size: 12px;
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
    margin: 0;
}

.api-help a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
}

.api-help a:hover {
    color: var(--text-color);
    text-decoration: underline;
}

/* AI Status Indicator */
.ai-status {
    position: fixed;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
    overflow: visible;
}

.ai-status-label {
    color: rgba(255, 255, 255, 0.6);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.ai-status-container {
    position: relative;
    overflow: visible;
    min-width: 40px;
    height: 18px;
    display: flex;
    align-items: center;
    transition: width 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
    flex-shrink: 0;
}

.ai-status-text {
    position: relative;
    white-space: nowrap;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
    width: auto;
    display: inline-block;
    overflow: visible;
}

.ai-status-text.fade-out {
    opacity: 0;
    transform: translateX(-20px);
    filter: blur(4px);
}

.ai-status-text.fade-in {
    opacity: 1;
    transform: translateX(0);
    filter: blur(0px);
}

.ai-status.gemini .ai-status-text {
    color: #4ade80;
}

.ai-status.fallback .ai-status-text {
    color: #fbbf24;
}

.ai-status.thinking .ai-status-text {
    color: #60a5fa;
    animation: thinking-pulse 1.5s ease-in-out infinite;
}

@keyframes thinking-pulse {
    0%, 100% { 
        opacity: 0.7;
        transform: scale(1);
    }
    50% { 
        opacity: 1;
        transform: scale(1.02);
    }
}

/* Add a subtle glow effect */
.ai-status.gemini {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), 0 0 20px rgba(74, 222, 128, 0.1);
}

.ai-status.thinking {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), 0 0 20px rgba(96, 165, 250, 0.15);
}

/* AI Thinking Panel Styles */
.ai-panel-toggle {
    position: fixed;
    top: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-color);
    padding: 12px;
    cursor: pointer;
    display: none; /* Hidden by default, shown only in AI mode */
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    transition: all var(--transition-time) ease;
    backdrop-filter: blur(10px);
    z-index: 1000;
    opacity: 0.8;
}

.ai-panel-toggle:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.9);
    border-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.ai-panel-toggle svg {
    transition: transform var(--transition-time) ease;
    opacity: 0.9;
}

.ai-panel-toggle:hover svg {
    transform: rotate(5deg) scale(1.1);
    opacity: 1;
}

.ai-thinking-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 350px;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    border-right: 1px solid var(--border-color);
    backdrop-filter: blur(15px);
    z-index: 1001;
    transform: translateX(-100%);
    transition: transform var(--transition-time) ease;
    overflow-y: auto;
    overflow-x: hidden;
}

.ai-thinking-panel:not(.hidden) {
    transform: translateX(0);
}

.ai-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.ai-panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-color);
    font-weight: 600;
    font-size: 0.95rem;
}

.ai-panel-title svg {
    animation: thinking-pulse 2s ease-in-out infinite;
}

.ai-panel-close {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
    opacity: 0.7;
}

.ai-panel-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}

.ai-panel-content {
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.ai-thinking-section {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.ai-thinking-section:last-child {
    border-bottom: none;
}

.ai-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-weight: 600;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.9);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ai-status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    animation: status-pulse 1.5s ease-in-out infinite;
}

.ai-status-indicator.thinking {
    background: #fbbf24;
    animation: thinking-blink 0.8s ease-in-out infinite alternate;
}

.ai-status-indicator.idle {
    background: #6b7280;
    animation: none;
}

@keyframes status-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

@keyframes thinking-blink {
    0% { opacity: 0.3; }
    100% { opacity: 1; }
}

.ai-thinking-text {
    color: var(--text-color);
    font-size: 0.9rem;
    line-height: 1.5;
    background: rgba(255, 255, 255, 0.03);
    padding: 16px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    min-height: 60px;
    white-space: pre-wrap;
    font-family: 'Inter', monospace;
}

.ai-reasoning-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.reasoning-step {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.reasoning-step:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

.step-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    min-width: 110px;
}

.step-result {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
    text-align: right;
    flex: 1;
    margin-left: 12px;
}

.step-result.positive {
    color: #4ade80;
    font-weight: 500;
}

.step-result.negative {
    color: #f87171;
}

.step-result.neutral {
    color: #fbbf24;
}

.game-state-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.state-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 6px;
}

.state-label {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.8);
}

.state-value {
    font-size: 0.85rem;
    color: var(--text-color);
    font-weight: 500;
    font-family: 'Inter', monospace;
}

.ai-model-info {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(0, 0, 0, 0.3);
}

.model-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.2);
    border-radius: 6px;
    color: #4ade80;
    font-size: 0.8rem;
    font-weight: 500;
    justify-content: center;
}

.model-badge svg {
    opacity: 0.8;
}

/* Panel Toggle Animation */
.ai-panel-toggle.panel-open {
    opacity: 1;
    background: rgba(0, 0, 0, 0.95);
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.05);
}

.ai-panel-toggle.panel-open svg {
    transform: rotate(10deg) scale(1.05);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .ai-panel-toggle {
        left: 15px;
        top: 15px;
        width: 44px;
        height: 44px;
        padding: 10px;
    }
    
    .ai-thinking-panel {
        width: 100vw;
        transform: translateX(-100%);
    }
    
    .ai-thinking-panel:not(.hidden) {
        transform: translateX(0);
    }
    
    .ai-section-title {
        font-size: 0.8rem;
    }
    
    .step-label {
        font-size: 0.8rem;
        min-width: 90px;
    }
    
    .step-result {
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .ai-panel-toggle {
        left: 10px;
        top: 10px;
        width: 40px;
        height: 40px;
        padding: 8px;
    }
    
    .ai-panel-toggle.panel-open {
        transform: scale(1.1);
        opacity: 1;
    }
}

/* Celebration Emoji System */
.celebration-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease-out;
}

.celebration-container:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.celebration-emoji {
    font-size: 4rem;
    margin-bottom: 0.5rem;
    animation: celebrationSlideIn 0.6s ease-out;
}

.celebration-text {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-color);
    text-align: center;
    opacity: 0;
    animation: celebrationTextSlideUp 0.8s ease-out 0.3s forwards;
}

@keyframes celebrationSlideIn {
    0% {
        transform: translateX(-100px) scale(0.3);
        opacity: 0;
    }
    50% {
        transform: translateX(10px) scale(1.1);
        opacity: 0.8;
    }
    100% {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

@keyframes celebrationTextSlideUp {
    0% {
        transform: translateY(30px);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Floating emoji animation with linear movement */
.celebration-container.floating-emojis::before {
    content: '';
    position: absolute;
    top: -100px;
    left: -100px;
    right: -100px;
    bottom: -100px;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><text y="50" font-size="20">🎉</text></svg>') repeat;
    animation: linearFloatingEmojis 3s ease-out;
    opacity: 0.6;
    pointer-events: none;
    z-index: -1;
}

@keyframes linearFloatingEmojis {
    0% {
        transform: translateY(100px) translateX(-50px);
        opacity: 0;
    }
    25% {
        opacity: 0.8;
        transform: translateY(50px) translateX(-25px);
    }
    75% {
        opacity: 0.6;
        transform: translateY(-100px) translateX(25px);
    }
    100% {
        transform: translateY(-200px) translateX(50px);
        opacity: 0;
    }
}

/* Enhanced celebrations with linear movement */
.celebration-container.special-win .celebration-emoji {
    animation: specialLinearCelebration 1s ease-out;
}

@keyframes specialLinearCelebration {
    0% {
        transform: translateY(50px) scale(0.2);
        opacity: 0;
    }
    25% {
        transform: translateY(20px) scale(0.8);
        opacity: 0.7;
    }
    50% {
        transform: translateY(-10px) scale(1.2);
        opacity: 1;
    }
    75% {
        transform: translateY(5px) scale(1.1);
        opacity: 1;
    }
    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* Different linear animation variants */
.celebration-container.slide-in .celebration-emoji {
    animation: slideInFromLeft 0.6s ease-out;
}

.celebration-container.fade-up .celebration-emoji {
    animation: fadeUpLinear 0.6s ease-out;
}

.celebration-container.slide-down .celebration-emoji {
    animation: slideDownLinear 0.6s ease-out;
}

.celebration-container.slide-right .celebration-emoji {
    animation: slideInFromRight 0.6s ease-out;
}

.celebration-container.zoom-in .celebration-emoji {
    animation: zoomInLinear 0.6s ease-out;
}

/* Linear animation keyframes */
@keyframes slideInFromLeft {
    0% {
        transform: translateX(-150px);
        opacity: 0;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeUpLinear {
    0% {
        transform: translateY(80px);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideDownLinear {
    0% {
        transform: translateY(-80px);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideInFromRight {
    0% {
        transform: translateX(150px);
        opacity: 0;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes zoomInLinear {
    0% {
        transform: scale(0.1);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@media (max-width: 480px) {
    .celebration-emoji {
        font-size: 3rem;
    }
    
    .celebration-text {
        font-size: 1rem;
    }
}