@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800&display=swap');

:root {
    --bg-color: #0f172a;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --primary: #3b82f6;
    --secondary: #8b5cf6;
    --accent: #ec4899;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --win: #22c55e;
    --lose: #ef4444;
    --draw: #eab308;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    color: white;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    cursor: url('assets/default.svg'), auto;
    /* Default Body Cursor */
}

/* Explicit Interactive Elements -> Hand Cursor */
button,
a,
.switch-toggle,
.close-btn,
.icon,
input[type="checkbox"],
.slider,
.option-btn,
label,
select,
summary {
    cursor: url('assets/handpointing.svg'), pointer !important;
}

/* Prevent flickering: Children of interactive elements inherit cursor */
button *,
a *,
.switch-toggle *,
label *,
.option-btn * {
    cursor: inherit !important;
}

/* Text Inputs and Code -> Text Cursor */
input[type="text"],
input[type="number"],
textarea,
code,
pre,
.selectable-text {
    cursor: url('assets/textcursor.svg'), text !important;
}

/* Ensure tokens inside pre/code inherit the custom cursor */
pre *,
code * {
    cursor: inherit !important;
}

/* Background Blobs */
.background-blobs {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.6;
    animation: drift 20s infinite alternate;
}

.blob-1 {
    width: 400px;
    height: 400px;
    background: var(--primary);
    top: -10%;
    left: -10%;
}

.blob-2 {
    width: 500px;
    height: 500px;
    background: var(--secondary);
    bottom: -10%;
    right: -10%;
    animation-delay: -5s;
}

.blob-3 {
    width: 300px;
    height: 300px;
    background: var(--accent);
    bottom: 20%;
    left: 20%;
    animation-delay: -10s;
}

@keyframes drift {
    0% {
        transform: translate(0, 0);
    }

    100% {
        transform: translate(30px, 50px);
    }
}

/* Glass Container */
.glass-container {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2rem;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    /* Reduced from 2rem */
    text-align: center;
}

header {
    margin-bottom: 0.5rem;
    /* Reduced from 2.5rem */
    position: relative;
    padding: 10px 0;
}

h1 {
    font-size: 1.5rem;
    font-weight: 800;
    margin: 0;
    /* Remove margin-bottom for center-alignment */
    background: linear-gradient(to right, #fff, #a29bfe);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-align: center;
}

/* Emoji Switch */
.emoji-toggle-container {
    position: absolute;
    top: 50%;
    /* Center vertically relative to header */
    transform: translateY(-50%);
    right: 1rem;
}

/* Score Board */
.score-board {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 0.5rem;
    /* Reduced from 2rem */
    margin-top: 0.5rem;
    /* Reduced from 1rem */
    /* Reduced from 4rem */
}

.score-card {
    background: rgba(0, 0, 0, 0.2);
    padding: 0.8rem 1.5rem;
    /* Reduced from 1.5rem 2.5rem */
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 90px;
    /* Reduced from 120px */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.score-card .label {
    font-size: 0.8rem;
    /* Reduced from 1rem */
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 1.2px;
    margin-bottom: 0.25rem;
}

.score-card span[id$="-score"] {
    font-size: 1.8rem;
    /* Reduced from 2.5rem */
    font-weight: 800;
    line-height: 1;
}

/* Game Area */
.game-area {
    min-height: 120px;
    /* Reduced from 200px */
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.hand-container {
    font-size: 4rem;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.player-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.hand-emoji {
    display: inline-block;
}

#user-hand {
    transform: scaleX(-1);
    /* Mirror user hand */
}

.result-display .message-container {
    flex: 1;
    padding: 0 1rem;
}

#result-message {
    font-size: 1rem;
    /* Reduced to 1rem per feedback */
    font-weight: 800;
    /* Made slightly bolder to compensate for size */
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Controls */
.controls {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.option-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-main);
}

.option-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-5px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.3);
}

.option-btn:active {
    transform: translateY(0);
}

/* Keyboard Key Style */
.key-icon {
    font-size: 1.5rem;
    font-weight: 700;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-bottom: 4px solid rgba(0, 0, 0, 0.5);
    /* 3D key effect */
    border-radius: 8px;
    width: 60px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-muted);
    transition: all 0.1s;
}

.option-btn:active .key-icon,
.option-btn.pressed .key-icon {
    border-bottom-width: 1px;
    transform: translateY(3px);
    color: var(--primary);
    border-color: var(--primary);
}

.option-btn span {
    font-size: 0.9rem;
    font-weight: 500;
}

/* Animations */
.shaking {
    animation: shake-comp 0.5s ease-in-out infinite;
    display: inline-block;
}

@keyframes shake-comp {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-30px);
    }

    30% {
        transform: translateY(0);
    }

    45% {
        transform: translateY(-30px);
    }

    60% {
        transform: translateY(0);
    }

    75% {
        transform: translateY(-30px);
    }

    100% {
        transform: translateY(0);
    }
}

@keyframes shake-comp {
    0% {
        transform: translateY(0);
    }

    15% {
        transform: translateY(-30px);
    }

    30% {
        transform: translateY(0);
    }

    45% {
        transform: translateY(-30px);
    }

    60% {
        transform: translateY(0);
    }

    75% {
        transform: translateY(-30px);
    }

    100% {
        transform: translateY(0);
    }
}


/* Results Colors */
.text-win {
    color: var(--win);
    text-shadow: 0 0 20px rgba(34, 197, 94, 0.5);
}

.text-lose {
    color: var(--lose);
    text-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
}

.text-draw {
    color: var(--draw);
    text-shadow: 0 0 20px rgba(234, 179, 8, 0.5);
}

/* Reset Btn */
.reset-btn {
    background: var(--primary);
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 50px;
    color: white;
    font-weight: 700;
    cursor: pointer;
    align-self: center;
    transition: all 0.3s ease;
    margin-top: -1rem;
}

.reset-btn.hidden {
    display: none;
}

.reset-btn:hover {
    box-shadow: 0 0 20px var(--primary);
    transform: scale(1.05);
}

/* Code Icon */
.code-icon-container {
    position: absolute;
    top: 2rem;
    right: 2rem;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    border: 1px solid var(--glass-border);
    transition: all 0.3s ease;
    z-index: 100;
}

.code-icon-container:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.2);
}

.code-icon-container .icon {
    font-family: monospace;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--text-main);
}

/* Main Game Container Transition */
.glass-container {
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

body.code-active .glass-container {
    transform: translateX(-40%);
    /* Increased shift */
}

/* Code Panel (Premium Glass Style) */
.code-panel {
    position: fixed;
    top: 50%;
    right: 5%;
    transform: translateY(-50%) scale(0.8);
    width: 600px;
    height: 80vh;
    background: rgba(22, 22, 24, 0.85);
    /* Translucent dark */
    backdrop-filter: blur(20px);
    /* Heavy blur */
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 1000;
    transform-origin: center right;
}

body.code-active .code-panel {
    opacity: 1;
    pointer-events: all;
    transform: translateY(-50%) scale(1);
    right: 5%;
}

.code-panel.hidden {
    display: flex;
}

/* Panel Header */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    min-height: 50px;
}

/* Spacer */
.spacer {
    flex: 1;
}

/* Toggle Button */
.toggle-btn {
    background: transparent;
    border: 1px solid #555;
    color: #ccc;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Outfit', sans-serif;
}

.toggle-btn:hover {
    background: #333;
    color: white;
}

.toggle-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* Emoji Switch */
.emoji-toggle-container {
    position: absolute;
    top: 1rem;
    right: 1rem;
}

.switch-toggle {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 30px;
}

.switch-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border-radius: 34px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.slider:before {
    position: absolute;
    content: "🤜";
    /* Hands Default */
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 24px;
    width: 24px;
    left: 3px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--primary);
    border-color: var(--primary);
}

input:checked+.slider:before {
    transform: translateX(28px);
    content: "✂️";
    /* Objects Active: Scissors */
}

/* Close Button Improved */
.close-btn {
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin-left: 10px;
}

.close-btn:hover {
    background: #ff5f56;
    border-color: #ff5f56;
    transform: rotate(90deg);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Code Body Container */
.code-body-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
    height: 100%;
}

/* Sidebar Gutter */
.gutter {
    width: 3.8rem;
    background: #1e1e1e;
    border-right: 1px solid rgba(255, 255, 255, 0.15);
    overflow: hidden;
    /* Programmatic Scroll */
    padding-top: 1.5rem;
    text-align: right;
    padding-right: 0.8rem;
    box-sizing: border-box;
    flex-shrink: 0;

    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.95rem;
    line-height: 1.6;
    color: #858585;
    user-select: none;
    z-index: 20;
}

.gutter span {
    display: block;
}

/* Scroll Area */
.code-scroll-area {
    flex: 1;
    overflow: auto;
    padding: 0;
}

/* Prism Overrides */
pre[class*="language-"] {
    margin: 0 !important;
    padding: 1.5rem !important;
    /* Standard padding */
    background: transparent !important;
    text-shadow: none !important;
    font-family: 'Consolas', 'Monaco', monospace !important;
    font-size: 0.95rem !important;
    line-height: 1.6 !important;
    white-space: pre !important;

    /* Ensure code expands if needed */
    width: fit-content;
    min-width: 100%;
}

/* Hide Prism's line numbers if present */
pre[class*="language-"].line-numbers {
    padding-left: 1.5rem !important;
    /* Reset padding */
}

.line-numbers .line-numbers-rows {
    display: none !important;
}

.line-numbers-rows>span:before {
    content: counter(linenumber);
    color: #858585;
    display: block;
    padding-right: 0.8em;
    text-align: right;
}

/* VS Code Dark+ Custom Theme */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
    color: #397A55 !important;
    /* User requested green */
    font-style: italic;
    opacity: 1 !important;
}

.token.punctuation {
    color: #d4d4d4;
}

.token.selector,
.token.tag,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
    color: #ce9178;
    /* Strings - Orange */
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
    color: #d4d4d4;
}

.token.atrule,
.token.attr-value,
.token.keyword {
    color: #569cd6;
    /* Keywords - Blue */
}

.token.function,
.token.class-name {
    color: #dcdcaa;
    /* Functions - Yellow */
}

.token.regex,
.token.important,
.token.variable {
    color: #9cdcfe;
    /* Variables - Light Blue */
}

.token.important,
.token.bold {
    font-weight: bold;
}

.token.italic {
    font-style: italic;
}

.token.number {
    color: #b5cea8;
    /* Numbers - Light Green */
}

.token.boolean {
    color: #569cd6;
    /* Booleans - Blue */
}



.token.atrule,
.token.attr-value,
.token.keyword {
    color: #c586c0;
    /* Pink/Purple keywords */
}

.token.function,
.token.class-name {
    color: #dcdcaa;
    /* Yellow functions */
}

.token.regex,
.token.important,
.token.variable {
    color: #9cdcfe;
    /* Light Blue variables */
}

/* Hide comments by default */
.token.comment {
    display: none;
}

/* Show comments when class attached */
.code-content.show-comments .token.comment {
    display: inline;
}

/* Adjust hand container to prevent overlap */
.result-display {
    gap: 1rem;
    /* ensure spacing */
}

/* Ensure hands are centered properly */
.hand-container {
    min-width: 80px;
    /* Reserve space */
}

/* Mobile Optimization */
@media (max-width: 600px) {
    .glass-container {
        padding: 2.25rem 0.75rem;
        /* Increased vertical padding */
        gap: 1.25rem;
        /* Increased vertical gap */
        width: 95%;
        margin: 10px auto;
        max-width: 100vw;
        overflow: hidden;
        /* Prevent edge bleed */
    }

    h1 {
        font-size: 1.1rem;
        padding-right: 40px;
        /* Make room for absolute switch */
        text-align: left;
        /* Better for tight spaces */
    }

    .emoji-toggle-container {
        right: 0.5rem;
    }

    .score-board {
        gap: 0.5rem;
        margin-top: 1.5rem;
        /* Lowered score boxes */
    }

    .score-card {
        padding: 0.8rem 0.5rem;
        /* More vertical breathing room */
        min-width: 0;
        flex: 1;
        border-radius: 12px;
        /* Equal width cards */
    }

    .score-card span[id$="-score"] {
        font-size: 1.5rem;
        /* Larger score visibility */
        margin-top: 4px;
    }

    .game-area {
        min-height: 80px;
    }

    .hand-container {
        font-size: 2.5rem;
        min-width: 50px;
        /* Reduced min-width to prevent pushing */
        align-items: flex-start;
        /* Default to start for user */
    }

    #comp-hand-container {
        align-items: flex-end;
        padding-right: 15px;
        /* Shifting comp text/hand slightly to the left */
        /* Align comp elements to the right edge */
    }

    #user-hand-container {
        align-items: flex-start;
        padding-left: 15px;
        /* Shifting user text/hand slightly to the right for symmetry */
        /* Align user elements to the left edge */
    }

    .hand-emoji {
        font-size: 2.5rem;
    }

    .player-label {
        font-size: 0.6rem;
        letter-spacing: 1px;
    }

    h2#msg {
        font-size: 0.9rem;
        white-space: nowrap;
    }

    .options {
        gap: 0.5rem;
        justify-content: center;
    }

    .option-btn {
        padding: 0.6rem;
        min-width: 0;
        flex: 1;
        max-width: 80px;
    }

    .symbol {
        font-size: 1.25rem;
    }

    .button-label {
        font-size: 0.6rem;
    }

    /* Fixed View Source Modal for Mobile */
    .code-panel {
        width: 95% !important;
        height: 90vh !important;
        right: 2.5% !important;
        left: 2.5% !important;
        top: 50% !important;
        transform: translateY(-50%) scale(0.9) !important;
        transform-origin: center !important;
    }

    body.code-active .code-panel {
        transform: translateY(-50%) scale(1) !important;
    }

    body.code-active .glass-container {
        transform: none !important;
        /* Don't shift background on mobile */
        filter: blur(4px);
        /* Just blur it instead */
    }

    .panel-header {
        padding: 10px 15px;
        flex-wrap: wrap;
        /* Allow buttons to wrap if needed */
        gap: 5px;
    }

    .panel-header .spacer {
        display: none;
        /* Hide spacer on small width */
    }

    .toggle-btn {
        font-size: 0.7rem;
        padding: 4px 8px;
    }

    .gutter {
        width: 2.5rem;
        /* Narrower gutter */
        font-size: 0.8rem;
    }

    pre[class*="language-"] {
        padding: 1rem !important;
        font-size: 0.8rem !important;
    }
}

@media (max-width: 400px) {
    .glass-container {
        padding: 1.75rem 0.4rem;
        /* Increased vertical padding for ultra-small */
    }

    .hand-container {
        font-size: 2rem;
        min-width: 45px;
    }

    .hand-emoji {
        font-size: 2rem;
    }

    .options {
        gap: 0.25rem;
    }

    .option-btn {
        padding: 0.4rem;
        min-width: 0;
    }

    .score-card span[id$="-score"] {
        font-size: 1.1rem;
    }
}