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

        html, body {
            overflow: hidden;
            overscroll-behavior: none;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: url('/table-1.jpg') repeat fixed;
            background-size: 256px 256px;
            color: white;
            min-height: 100vh;
        }

        .container {
            max-width: 1400px;
            margin: 0 auto;
            padding: 20px;
        }

        .header {
            text-align: center;
            margin-bottom: 20px;
            padding: 30px;
        }

        .logo {
            font-size: 3rem;
            font-weight: bold;
            margin-bottom: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 15px;
        }

        .logo-text {
            background: linear-gradient(45deg, #ff6b6b, #4ecdc4, #45b7d1);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }

        .sconce {
            position: relative;
            width: 40px;
            height: 90px;
            transform: translateY(-20px);
            filter: drop-shadow(0 4px 6px rgba(0,0,0,0.8));
        }

        .sconce::before {
            content: "";
            position: absolute;
            top: 10px;
            left: 50%;
            transform: translateX(-50%);
            width: 90px;
            height: 90px;
            background: radial-gradient(circle, rgba(255,180,0,0.5), rgba(255,150,0,0) 70%);
            z-index: 0;
            filter: blur(15px);
        }

        .sconce .holder {
            position: absolute;
            bottom: 0;
            left: 50%;
            transform: translateX(-50%);
            width: 30px;
            height: 25px;
            background: linear-gradient(#8d6e63, #5d4037);
            border-radius: 0 0 15px 15px;
            box-shadow: inset 0 2px 4px rgba(255,255,255,0.2), inset 0 -4px 6px rgba(0,0,0,0.7), 0 3px 6px rgba(0,0,0,0.6);
            z-index: 2;
        }

        .sconce .flame {
            position: absolute;
            bottom: 20px;
            left: 50%;
            transform: translateX(-50%);
            width: 20px;
            height: 30px;
            background: radial-gradient(circle at 50% 80%, #fffadd 0%, #ff9800 60%, rgba(255,152,0,0) 70%);
            border-radius: 50%;
            animation: flicker 0.6s infinite alternate;
            filter: blur(1px);
            box-shadow: 0 0 10px 3px rgba(255,150,0,0.8), 0 0 25px 10px rgba(255,120,0,0.6);
            z-index: 1;
        }

        .sconce span {
            position: absolute;
            bottom: 30px;
            left: 50%;
            width: 8px;
            height: 8px;
            background: rgba(255, 235, 59, 0.9);
            border-radius: 50%;
            animation: rise 1s infinite ease-out;
        }

        .sconce span:nth-of-type(2) { animation-delay: 0.3s; }
        .sconce span:nth-of-type(3) { animation-delay: 0.6s; }

        @keyframes flicker {
            0% { transform: translateX(-50%) scale(1); }
            50% { transform: translateX(-50%) scale(1.2); }
            100% { transform: translateX(-50%) scale(1); }
        }

        @keyframes rise {
            0% { transform: translate(-50%, 0) scale(1); opacity: 1; }
            100% { transform: translate(-50%, -40px) scale(0); opacity: 0; }
        }

        .setup-section {
            background: rgba(255,255,255,0.05);
            padding: 30px;
            border-radius: 15px;
            margin-bottom: 30px;
            border: 1px solid rgba(255,255,255,0.1);
        }

        .input-group {
            margin-bottom: 20px;
        }

        .input-group label {
            display: block;
            margin-bottom: 8px;
            font-weight: 600;
            color: #4ecdc4;
        }

        .input-group input {
            width: 100%;
            padding: 12px;
            border: 2px solid rgba(255,255,255,0.2);
            border-radius: 8px;
            background: rgba(255,255,255,0.1);
            color: white;
            font-size: 16px;
            transition: all 0.3s ease;
        }

        .input-group input:focus {
            outline: none;
            border-color: #4ecdc4;
            box-shadow: 0 0 20px rgba(78, 205, 196, 0.3);
        }

        .btn {
            background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
            border: none;
            color: white;
            padding: 12px 24px;
            border-radius: 8px;
            cursor: pointer;
            font-size: 16px;
            font-weight: 600;
            transition: all 0.3s ease;
            text-transform: uppercase;
            letter-spacing: 1px;
            margin: 5px;
        }

        .btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 25px rgba(0,0,0,0.3);
        }

        .btn:disabled {
            background: #666;
            cursor: not-allowed;
            transform: none;
        }

        .tab-bar {
            display: flex;
            border-bottom: 1px solid rgba(255,255,255,0.1);
            margin-bottom: 10px;
        }

        .tab-btn {
            background: #1a1a1a;
            border: 1px solid rgba(255,255,255,0.1);
            border-bottom: none;
            color: #ccc;
            padding: 8px 16px;
            cursor: pointer;
            margin-right: 4px;
            border-top-left-radius: 6px;
            border-top-right-radius: 6px;
            transition: background 0.3s, color 0.3s;
        }

        .tab-btn:hover {
            background: #333;
            color: #fff;
        }

        .tab-btn.active {
            background: #000;
            color: #4ecdc4;
            border-color: #4ecdc4;
        }

        .status-box {
            position: fixed;
            top: 20px;
            left: 50%;
            transform: translateX(-50%);
            background: rgba(0,0,0,0.8);
            padding: 10px 20px;
            border-radius: 8px;
            color: #fff;
            z-index: 2000;
            display: none;
            max-width: 90%;
            text-align: center;
        }

        .status-box.success { border: 2px solid #4ecdc4; }
        .status-box.error { border: 2px solid #ff6b6b; }
        .status-box.loading { border: 2px solid #aaa; }

        /* Keep End Turn button fixed; raise it on mobile */
        #endTurnBtn {
            position: fixed;
            bottom: 20px;
            left: 50%;
            transform: translateX(-50%);
            z-index: 1000;
        }


        .connect-section {
            margin-top: 5px;
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        .user-row {
            display: flex;
            align-items: center;
            margin-top: 0;
        }

        .dropdown-content {
            display: none;
            position: absolute;
            right: 0;
            background: rgba(0,0,0,0.9);
            border: 2px solid #4ecdc4;
            border-radius: 8px;
            min-width: 150px;
            z-index: 100;
        }

        .dropdown-item {
            width: 100%;
            padding: 8px 12px;
            background: none;
            border: none;
            color: white;
            text-align: left;
            cursor: pointer;
        }

        .dropdown-item:hover {
            background: rgba(255,255,255,0.1);
        }

        .quest-menu {
            position: fixed;
            top: 0;
            left: 50%;
            transform: translate(-50%, -120%);
            transition: transform 0.3s ease-out;
            z-index: 1000;
        }

        .quest-menu.open {
            transform: translate(-50%, 0);
        }

        .quest-menu.closing {
            animation: quest-close 0.5s ease forwards;
        }

        @keyframes quest-close {
            0% { transform: translate(-50%, 0); }
            20% { transform: translate(-50%, 10%); }
            100% { transform: translate(-50%, -120%); }
        }

        .quest-menu .dropdown-content {
            display: block;
            position: relative;
            right: auto;
            background: url('/menu1.png') no-repeat center/contain;
            border: none;
            border-radius: 0;
            padding: 100px 20px 140px;
            width: min(300px, 90vw);
            text-align: center;
            min-width: auto;
            background-size: contain;
        }

        .button-empty,
        .quest-menu .dropdown-item {
            background: url('/button_empty.png') no-repeat center/100% 100%;
            border: none;
            color: #fff;
            cursor: pointer;
            width: 200px;
            height: 50px;
            margin: 8px;
            font-weight: 600;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .user-btn {
            background: rgba(255,255,255,0.1);
            border: 2px solid #4ecdc4;
            color: white;
            padding: 6px 12px;
            border-radius: 8px;
            cursor: pointer;
            font-size: 14px;
            font-weight: 600;
            margin: 5px;
        }

        .quest-menu .dropdown-item {
            margin: 8px auto;
        }

        .quest-button {
            width: 240px;
            height: 60px;
        }

        #connectBtn {
            font-size: 20px;
        }

        #faqBtn,
        #deckBtn {
            width: 160px;
            height: 40px;
            font-size: 12px;
        }

        .quest-menu::before,
        .quest-menu::after {
            content: '';
            position: absolute;
            top: -100vh;
            width: 4px;
            height: 0;
            background: #b5895a;
            transition: height 0.3s ease-out;
        }

        .quest-menu::before {
            left: 30px;
        }

        .quest-menu::after {
            right: 30px;
        }

        .quest-menu.open::before,
        .quest-menu.open::after {
            height: 100vh;
        }


        #faqDeckLink {
            color: #4ecdc4;
            text-decoration: underline;
        }

        .online-user {
            cursor: pointer;
        }

        .online-user.stale {
            color: yellow;
        }

        .online-user:hover {
            background: rgba(78,205,196,0.1);
        }

        .buy-links {
            margin-top: 10px;
            text-align: center;
        }

        .buy-links a {
            color: #4ecdc4;
            margin: 0 8px;
            text-decoration: underline;
        }

        .faq-list {
            margin-left: 20px;
            line-height: 1.4;
        }

        .chat-tab-content {
            background: rgba(255,255,255,0.05);
            border: 1px solid rgba(255,255,255,0.1);
            border-radius: 12px;
            max-height: calc(min(180px, 25vh) + 60px);
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }

        .chat-section {
            flex: 1;
            max-height: min(180px, 25vh);
            overflow-y: auto;
            padding: 15px 15px 10px;
        }

        .chat-message {
            margin-bottom: 8px;
        }

        .chat-user {
            font-weight: bold;
            cursor: pointer;
            color: #4ecdc4;
        }

        .chat-input {
            display: flex;
            border-top: 1px solid rgba(255,255,255,0.2);
        }

        .chat-input input {
            flex: 1;
            padding: 8px;
            border: 1px solid rgba(255,255,255,0.4);
            border-top: none;
            border-right: none;
            background: rgba(255,255,255,0.15);
            color: white;
        }

        .chat-input input::placeholder {
            color: rgba(255,255,255,0.6);
        }

        .chat-input button {
            margin: 0;
            border: none;
            padding: 0 16px;
            background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
            color: white;
            font-weight: 600;
            cursor: pointer;
            display: flex;
            align-items: center;
            transition: transform 0.3s ease, box-shadow 0.3s ease;
        }

        .chat-input button:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 25px rgba(0,0,0,0.3);
        }

        #lobbySection {
            margin-top: -30px;
        }

        .deck-modal {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0,0,0,0.8);
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 1000;
        }
        .deck-content {
            background: #16213e;
            padding: 20px;
            border-radius: 10px;
            max-width: 500px;
            width: 90%;
            max-height: 80vh;
            overflow-y: auto;
        }

        #dialogModal {
            z-index: 2000;
        }

        #botDiffs {
            margin: 10px 0;
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        #botDiffs .user-btn {
            width: 100%;
        }


        #deckCards, #freebieCards {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
            gap: 10px;
        }

        .deck-slot-row {
            display: flex;
            justify-content: center;
            gap: 10px;
            margin-top: 10px;
        }

        .card-item {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 5px;
            width: 80px;
        }

        .deck-card-art {
            width: 80px;
            height: 120px;
            object-fit: cover;
            border-radius: 8px;
        }

        .card-art-wrapper {
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .card-item label {
            text-align: center;
        }

        .battle-container {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100vh;
            display: none;
            flex-direction: column;
            justify-content: space-between;
            z-index: 50;
            background: url('/table-1.jpg') repeat;
            background-size: 256px 256px;
            overflow: hidden;
        }

        .battle-arena {
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            align-items: stretch;
            height: 60vh;
            margin: 0;
            gap: 0;
            position: relative;
        }

        .card-display {
            background: rgba(255,255,255,0.05);
            border-radius: 15px;
            padding: 10px;
            text-align: center;
            border: 2px solid rgba(255,255,255,0.1);
            flex: 1;
            min-height: 0;
            width: 100%;
            display: flex;
            flex-direction: column;
            justify-content: center;
            position: relative;
            z-index: 10;
        }

        .card-display.player2 {
            justify-content: flex-end;
        }

        .card-display.player1 {
            justify-content: flex-start;
        }

        @media (min-width: 769px) {
            .card-display.player2 {
                padding-top: 40px;
            }
            .card-display.player1 {
                padding-bottom: 40px;
            }
        }

        .card-row {
            display: flex;
            gap: 15px;
            justify-content: center;
        }

        .card-slot {
            flex: 0 0 auto;
            width: 25vw;
            height: 37.5vw;
            max-width: 100px;
            max-height: 150px;
            border: 2px dashed rgba(255,255,255,0.2);
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            position: relative;
            overflow: visible;
            touch-action: none;
        }

        .card-slot.selected {
            z-index: 2;
        }

        @media (hover: hover) {
            .card-slot:hover {
                overflow: visible;
            }

            .card-slot.empty:hover {
                border-color: #4ecdc4;
            }
        }

        .card-slot:not(.empty) {
            border: none;
        }

        .card-slot.empty::after {
            content: '+';
            font-size: 2rem;
            color: rgba(255,255,255,0.3);
        }

        .card-slot.empty.highlight-slot {
            border-color: #4ecdc4;
            box-shadow: 0 0 10px rgba(78,205,196,0.7);
        }

        .card-slot.empty.flash-slot {
            border-color: #4ecdc4;
            box-shadow: 0 0 10px rgba(78,205,196,0.7);
            animation: slot-flash 1s ease-in-out 3;
        }

        @keyframes slot-flash {
            0%, 100% {
                border-color: #4ecdc4;
                box-shadow: 0 0 10px rgba(78,205,196,0.7);
            }
            50% {
                border-color: rgba(255,255,255,0.2);
                box-shadow: none;
            }
        }

        .card-slot img {
            width: 100%;
            height: 100%;
            object-fit: contain;
            border-radius: 8px;
        }

        .block-shields {
            position: absolute;
            top: 4px;
            left: 4px;
            display: flex;
            gap: 2px;
        }

        .block-shields .shield-icon img {
            width: 16px;
            height: 16px;
        }

        .card-container {
            position: relative;
            width: 100%;
            height: 100%;
            cursor: pointer;
            transition: transform 0.15s ease, box-shadow 0.3s ease;
        }

        @media (hover: hover) {
            #card1 .card-container:hover {
                transform: translateY(-5px);
                box-shadow: 0 10px 15px rgba(0,0,0,0.3);
            }

            #card1 .card-slot:not(.empty):hover .card-container {
                transform: scale(1.1);
            }
        }

        .card-slot.selected .card-container,
        .card-slot.dragging .card-container {
            transform: scale(1.15);
        }

        .card-slot.selected .hp-top,
        .card-slot.selected .attack,
        .card-slot.dragging .hp-top,
        .card-slot.dragging .attack {
            transform: scale(1.25);
        }

        @media (hover: hover) {
            #card1 .card-slot:not(.empty):hover .hp-top,
            #card1 .card-slot:not(.empty):hover .attack {
                transform: scale(1.25);
            }
        }

        #attackArrow {
            position: fixed;
            top: 0;
            left: 0;
            width: 100vw;
            height: 100vh;
            pointer-events: none;
            z-index: 2002;
            display: none;
        }

        #attackArrowPath {
            stroke-width: 4;
            fill: none;
            stroke-dasharray: 8 8;
            animation: dash 1s linear infinite;
            stroke-linecap: round;
        }

        @keyframes dash {
            to {
                stroke-dashoffset: -16;
            }
        }

        .bot-placeholder {
            border: 2px dashed rgba(255,255,255,0.5);
            border-radius: 8px;
            background: rgba(0,0,0,0.3);
            box-sizing: border-box;
        }

        .bot-placeholder .placeholder-text {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            color: rgba(255,255,255,0.7);
            font-size: 0.8rem;
            text-align: center;
            pointer-events: none;
        }

        .hp-top,
        .card-overlay {
            z-index: 2;
        }

        .hp-top {
            position: relative;
            width: 28px;
            height: 28px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.6rem;
            font-weight: bold;
            opacity: 0.8;
            transition: transform 0.15s ease;
        }

        .hp-top::before {
            content: '❤️';
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
            font-size: 16px;
            z-index: -1;
            opacity: 0.7;
        }

        .damage-number {
            position: absolute;
            top: 40%;
            left: 50%;
            transform: translate(-50%, -50%);
            display: flex;
            pointer-events: none;
            z-index: 3000;
            filter: drop-shadow(0 0 2px #000);
        }

        .damage-number img {
            width: 28px;
            height: 28px;
            image-rendering: pixelated;
        }

        .defeat-fade {
            animation: cardFadeOut 0.5s forwards;
        }

        @keyframes cardFadeOut {
            to { opacity: 0; }
        }

        @keyframes cardLanding {
            0% { transform: translateY(-20px) scale(1.1); opacity: 0; }
            100% { transform: translateY(0) scale(1); opacity: 1; }
        }

        .card-container.landing {
            animation: cardLanding 0.3s ease-out;
        }

        .card-overlay {
            position: absolute;
            bottom: -2px;
            left: 0;
            right: 0;
            color: white;
            font-size: 0.6rem;
            display: flex;
            flex-direction: column;
            padding: 2px 4px;
        }

        .overlay-row {
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 24px;
            text-shadow: 0 1px 2px rgba(0,0,0,0.8);
        }

        .effect-icons {
            position: absolute;
            top: 2px;
            left: 2px;
            display: flex;
            flex-direction: column;
            gap: 2px;
        }

        .effect-row {
            display: flex;
            gap: 2px;
        }

        .effect-icon {
            position: relative;
            width: 16px;
            height: 16px;
        }

        .effect-icon img {
            width: 100%;
            height: 100%;
        }

        .attack {
            position: relative;
            width: 28px;
            height: 28px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.6rem;
            font-weight: bold;
            opacity: 0.8;
            transition: transform 0.15s ease;
        }

        .attack::before {
            content: '⚔️';
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
            font-size: 16px;
            z-index: -1;
            opacity: 0.7;
        }

        .hp-value,
        .attack-value {
            position: relative;
            z-index: 1;
        }

        .wear-below {
            text-align: center;
            font-size: 0.6rem;
            margin-top: 2px;
            opacity: 0.8;
        }

        .hand {
            display: flex;
            gap: 10px;
            justify-content: center;
            margin-top: 20px;
        }

        .hand-card {
            width: 100px;
            height: 150px;
            cursor: pointer;
            border-radius: 8px;
            touch-action: none;
            transition: transform 0.15s ease, box-shadow 0.3s ease;
            position: relative;
        }

        .hand-card .card-art {
            width: 100%;
            height: 100%;
            object-fit: contain;
            border-radius: 8px;
        }

        .hand-card.selected {
            outline: 2px solid #4ecdc4;
        }

        @media (hover: hover) {
            .hand-card:hover {
                transform: scale(1.1);
                box-shadow: 0 10px 15px rgba(0,0,0,0.3);
                z-index: 2;
            }
        }

        .card-container.selected {
            outline: 2px solid #4ecdc4;
            border-radius: 8px;
        }

        .card-display.player1 {
            border-color: #4ecdc4;
            box-shadow: 0 0 30px rgba(78, 205, 196, 0.2);
        }

        .card-display.player2 {
            border-color: #ff6b6b;
            box-shadow: 0 0 30px rgba(255, 107, 107, 0.2);
        }

        .vs-section {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            display: flex;
            justify-content: center;
            align-items: center;
            text-align: center;
            z-index: 50;
            pointer-events: none;
        }

        .vs-text {
            font-size: 3rem;
            font-weight: bold;
            background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            text-shadow: 0 0 30px rgba(255,255,255,0.5);
        }

        .card-info {
            text-align: center;
        }

        .card-info h3 {
            font-size: 1.5rem;
            margin-bottom: 15px;
            color: #4ecdc4;
        }

        #playerLabel,
        #opponentLabel {
            display: inline-block;
        }

        #playerLabel {
            margin-top: 25px;
        }

        #opponentLabel {
            margin-top: 35px;
            margin-bottom: 5px;
        }



        .health-bar {
            width: 100%;
            height: 20px;
            background: rgba(0,0,0,0.3);
            border-radius: 10px;
            overflow: hidden;
            margin: 10px 0;
        }

        .health-fill {
            height: 100%;
            transition: width 0.5s ease;
            border-radius: 10px;
        }

        .health-fill.player1 { background: linear-gradient(90deg, #4ecdc4, #45b7d1); }
        .health-fill.player2 { background: linear-gradient(90deg, #ff6b6b, #ff8e53); }

        .battle-log {
            background: rgba(0,0,0,0.5);
            border-radius: 15px;
            padding: 20px;
            margin: 0;
            flex: 0 0 40%;
            overflow-y: auto;
            max-height: 200px;
            border: 1px solid rgba(255,255,255,0.1);
        }

        .hand-log-container {
            display: flex;
            justify-content: center;
            align-items: flex-start;
            gap: 20px;
            margin-top: 20px;
        }

        .hand-ready-container {
            flex: 0 0 60%;
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        .hand-log-container .hand {
            width: 100%;
            margin-top: 0;
        }

        .hand-log-container .battle-log {
            flex: 0 0 40%;
        }

        .ready-btn {
            margin-top: 10px;
        }

        .log-entry {
            margin: 8px 0;
            padding: 8px;
            border-left: 3px solid #4ecdc4;
            background: rgba(255,255,255,0.05);
            border-radius: 0 8px 8px 0;
        }

        .winner-announcement {
            background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
            padding: 30px;
            border-radius: 15px;
            text-align: center;
            margin: 30px 0;
            font-size: 1.5rem;
            font-weight: bold;
            animation: pulse 2s infinite;
        }

        .end-screen {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0,0,0,0.9);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: flex-start;
            padding-top: 50px;
            box-sizing: border-box;
            color: #fff;
            text-align: center;
            z-index: 100;
        }

        .vs-splash {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0,0,0,0.85);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            color: #fff;
            font-size: 2rem;
            z-index: 100;
            text-align: center;
            perspective: 800px;
        }

        .loading-screen {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0,0,0,0.9);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: flex-start;
            color: #fff;
            text-align: center;
            z-index: 100;
            padding: 50px 20px 20px;
            box-sizing: border-box;
        }

        #loadingScreen {
            justify-content: center;
            padding: 20px;
            background: #000;
            opacity: 0;
            transition: opacity 0.5s ease;
        }

        #loadingText,
        #bootText {
            font-size: 1.5rem;
            margin-top: 20px;
        }

        #enterBtn {
            margin-top: 20px;
        }

        #vsScreen {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            display: none;
            overflow: hidden;
            z-index: 150;
            background: transparent;
        }

        #vsScreen.closed {
            background: radial-gradient(circle at center, rgba(0,0,0,0.8) 0%, #000 80%);
        }

        .vs-side {
            position: absolute;
            top: 0;
            width: 100%;
            height: 100%;
            display: flex;
            font-size: 3rem;
            font-weight: 900;
            text-transform: uppercase;
            letter-spacing: 2px;
            color: #fff;
            text-shadow: 0 0 15px rgba(255,255,255,0.8);
            transition: transform 0.8s ease-in-out;
            background-size: 300% 300%;
            animation: side-glow 4s ease infinite;
            overflow: hidden;
        }

        .vs-side > span {
            position: relative;
            z-index: 2;
        }

        .vs-side::after {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: radial-gradient(circle, rgba(255,255,255,0.2), transparent 70%);
            pointer-events: none;
        }

        .vs-left {
            left: 0;
            background: linear-gradient(135deg, #002244, #0055ff, #00e0ff, #002244);
            box-shadow: inset -10px 0 30px rgba(0,0,0,0.6), 0 0 30px rgba(0,224,255,0.4);
            transform: translateX(-100%);
            clip-path: polygon(0 0, 100% 0, 0 100%);
            justify-content: flex-start;
            align-items: flex-start;
            padding: 10% 0 0 10%;
        }

        .vs-right {
            right: 0;
            background: linear-gradient(-135deg, #440000, #ff0044, #ff7700, #440000);
            box-shadow: inset 10px 0 30px rgba(0,0,0,0.6), 0 0 30px rgba(255,0,0,0.4);
            transform: translateX(100%);
            clip-path: polygon(100% 0, 100% 100%, 0 100%);
            justify-content: flex-end;
            align-items: flex-end;
            padding: 0 10% 10% 0;
        }

        #vsScreen.closed #vsLeft {
            transform: translateX(0);
        }

        #vsScreen.closed #vsRight {
            transform: translateX(0);
        }

        .vs-divider {
            display: none;
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            z-index: 5;
        }

        .vs-divider canvas {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
        }

        #vsScreen.closed .vs-divider {
            display: block;
        }


        #vsScreen .vs-text {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%) scale(0.5);
            font-size: 6rem;
            font-weight: 900;
            background: linear-gradient(45deg, #ffffff, #ffd700, #ff00ff);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            text-shadow: 0 0 30px #fff, 0 0 60px #ff0;
            z-index: 10;
            opacity: 0;
            pointer-events: none;
        }

        #vsScreen .vs-text.show {
            animation: vs-flash-in 0.4s forwards;
        }

        #vsScreen .vs-text.explode {
            animation: vs-flash-out 0.4s forwards;
        }

        #vsScreen.explode .vs-burst {
            display: block;
        }

        .vs-burst {
            position: absolute;
            top: 50%;
            left: 50%;
            width: 0;
            height: 0;
            pointer-events: none;
            display: none;
            z-index: 20;
            perspective: 600px;
        }

        .vs-burst span {
            position: absolute;
            top: 0;
            left: 0;
            width: var(--size, 10px);
            height: var(--size, 10px);
            background: radial-gradient(circle, #fff, #ffd700 40%, rgba(255,255,255,0) 70%);
            border-radius: 50%;
            box-shadow: 0 0 8px #fff, 0 0 16px #ffd700;
            opacity: 0;
            filter: blur(var(--blur, 0));
        }

        .vs-burst span::before,
        .vs-burst span::after {
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            width: 200%;
            height: 2px;
            background: linear-gradient(to right, transparent, #fff, transparent);
            transform: translate(-50%, -50%);
        }

        .vs-burst span::after {
            transform: translate(-50%, -50%) rotate(90deg);
        }

        #vsScreen.explode .vs-burst span {
            animation: burst 1s forwards, twinkle 1s ease-in-out forwards;
            animation-delay: calc(0.02s * var(--i)), calc(0.02s * var(--i));
            opacity: 1;
        }

        .vs-burst span:nth-child(1)  { --x: -80px; --y: -40px; --i: 1; }
        .vs-burst span:nth-child(2)  { --x: -60px; --y: 40px;  --i: 2; }
        .vs-burst span:nth-child(3)  { --x: 0px;   --y: -80px; --i: 3; }
        .vs-burst span:nth-child(4)  { --x: 80px;  --y: 30px;  --i: 4; }
        .vs-burst span:nth-child(5)  { --x: 50px;  --y: -50px; --i: 5; }
        .vs-burst span:nth-child(6)  { --x: -40px; --y: -70px; --i: 6; }
        .vs-burst span:nth-child(7)  { --x: 70px;  --y: 60px;  --i: 7; }
        .vs-burst span:nth-child(8)  { --x: -90px; --y: 50px;  --i: 8; }
        .vs-burst span:nth-child(9)  { --x: 20px;  --y: 80px;  --i: 9; }
        .vs-burst span:nth-child(10) { --x: -20px; --y: 90px;  --i: 10; }
        .vs-burst span:nth-child(11) { --x: 95px;  --y: -20px; --i: 11; }
        .vs-burst span:nth-child(12) { --x: -70px; --y: 80px;  --i: 12; }
        .vs-burst span:nth-child(13) { --x: 60px;  --y: -80px; --i: 13; }
        .vs-burst span:nth-child(14) { --x: -100px; --y: -10px; --i: 14; }
        .vs-burst span:nth-child(15) { --x: 100px; --y: 10px;  --i: 15; }
        .vs-burst span:nth-child(16) { --x: -50px; --y: 60px;  --i: 16; }
        .vs-burst span:nth-child(17) { --x: 40px;  --y: -60px; --i: 17; }
        .vs-burst span:nth-child(18) { --x: -30px; --y: -90px; --i: 18; }
        .vs-burst span:nth-child(19) { --x: 90px;  --y: -70px; --i: 19; }
        .vs-burst span:nth-child(20) { --x: -90px; --y: 30px;  --i: 20; }

        .vs-burst span:nth-child(odd) { --size: 12px; }
        .vs-burst span:nth-child(even) { --size: 8px; --blur: 1px; }
        .vs-burst span:nth-child(4n+1) { --rot: 0deg; }
        .vs-burst span:nth-child(4n+2) { --rot: 45deg; }
        .vs-burst span:nth-child(4n+3) { --rot: 90deg; }
        .vs-burst span:nth-child(4n)   { --rot: 135deg; }

        @keyframes vs-flash-in {
            0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
            60% { opacity: 1; transform: translate(-50%, -50%) scale(1.3); text-shadow: 0 0 60px #fff, 0 0 90px #ff0; }
            100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
        }

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

        @keyframes burst {
            0% {
                transform: translate(-50%, -50%) translate(0, 0) rotate(var(--rot)) scale(0);
                opacity: 0;
            }
            40% {
                transform: translate(-50%, -50%) translate(var(--x), var(--y)) rotate(var(--rot)) scale(1);
                opacity: 1;
            }
            100% {
                transform: translate(-50%, -50%) translate(calc(var(--x) * 1.3), calc(var(--y) * 1.3)) rotate(var(--rot)) scale(0);
                opacity: 0;
            }
        }

        @keyframes twinkle {
            0%, 100% { filter: blur(var(--blur, 0)) brightness(1); }
            50% { filter: blur(var(--blur, 0)) brightness(1.6); }
        }

        @keyframes side-glow {
            0% { background-position: 0% 50%; }
            50% { background-position: 100% 50%; }
            100% { background-position: 0% 50%; }
        }

        .vs-particles {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            overflow: hidden;
            pointer-events: none;
            z-index: 1;
        }

        .vs-particles span {
            position: absolute;
            width: 30px;
            height: 3px;
            box-shadow: 0 0 10px #fff, 0 0 20px #ff0;
            opacity: 0.9;
            animation-duration: 1s;
            animation-timing-function: linear;
            animation-iteration-count: infinite;
            animation-delay: calc(-0.05s * var(--i));
        }

        .vs-left .vs-particles span {
            background: linear-gradient(to left, rgba(255,255,255,0), #fff);
            animation-name: particle-left;
        }

        .vs-right .vs-particles span {
            background: linear-gradient(to right, rgba(255,255,255,0), #fff);
            animation-name: particle-right;
        }

        .vs-particles span:nth-child(1) { top: 10%; left: 20%; --i: 1; }
        .vs-particles span:nth-child(2) { top: 30%; left: 70%; --i: 2; }
        .vs-particles span:nth-child(3) { top: 60%; left: 40%; --i: 3; }
        .vs-particles span:nth-child(4) { top: 80%; left: 10%; --i: 4; }
        .vs-particles span:nth-child(5) { top: 20%; left: 80%; --i: 5; }
        .vs-particles span:nth-child(6) { top: 40%; left: 15%; --i: 6; }
        .vs-particles span:nth-child(7) { top: 75%; left: 55%; --i: 7; }
        .vs-particles span:nth-child(8) { top: 50%; left: 90%; --i: 8; }
        .vs-particles span:nth-child(9) { top: 15%; left: 50%; --i: 9; }
        .vs-particles span:nth-child(10) { top: 65%; left: 25%; --i: 10; }
        .vs-particles span:nth-child(11) { top: 35%; left: 60%; --i: 11; }
        .vs-particles span:nth-child(12) { top: 85%; left: 80%; --i: 12; }
        .vs-particles span:nth-child(13) { top: 5%; left: 30%; --i: 13; }
        .vs-particles span:nth-child(14) { top: 55%; left: 5%; --i: 14; }
        .vs-particles span:nth-child(15) { top: 25%; left: 95%; --i: 15; }
        .vs-particles span:nth-child(16) { top: 30%; left: 10%; --i: 16; }
        .vs-particles span:nth-child(17) { top: 70%; left: 45%; --i: 17; }
        .vs-particles span:nth-child(18) { top: 25%; left: 60%; --i: 18; }
        .vs-particles span:nth-child(19) { top: 85%; left: 20%; --i: 19; }
        .vs-particles span:nth-child(20) { top: 40%; left: 85%; --i: 20; }
        .vs-particles span:nth-child(21) { top: 5%; left: 65%; --i: 21; }
        .vs-particles span:nth-child(22) { top: 55%; left: 35%; --i: 22; }
        .vs-particles span:nth-child(23) { top: 15%; left: 5%; --i: 23; }
        .vs-particles span:nth-child(24) { top: 95%; left: 50%; --i: 24; }
        .vs-particles span:nth-child(25) { top: 45%; left: 75%; --i: 25; }
        .vs-particles span:nth-child(26) { top: 65%; left: 15%; --i: 26; }
        .vs-particles span:nth-child(27) { top: 10%; left: 90%; --i: 27; }
        .vs-particles span:nth-child(28) { top: 35%; left: 30%; --i: 28; }
        .vs-particles span:nth-child(29) { top: 80%; left: 60%; --i: 29; }
        .vs-particles span:nth-child(30) { top: 50%; left: 5%; --i: 30; }

        @keyframes particle-left {
            0% { transform: translateX(0); opacity: 1; }
            100% { transform: translateX(-200px); opacity: 0; }
        }

        @keyframes particle-right {
            0% { transform: translateX(0); opacity: 1; }
            100% { transform: translateX(200px); opacity: 0; }
        }

        .coin {
            width: 60px;
            height: 60px;
            margin-top: 20px;
            position: relative;
            border-radius: 50%;
            transform-style: preserve-3d;
            box-shadow: 0 4px 6px rgba(0,0,0,0.3);
        }

        .coin .side {
            position: absolute;
            width: 100%;
            height: 100%;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 30px;
            font-weight: bold;
            line-height: 60px;
            color: #6b4f1d;
            text-shadow: 0 1px 0 #ffd700, 0 -1px 0 #b8860b;
            background: radial-gradient(circle at 30% 30%, #fff8d6 0%, #ffd700 30%, #b8860b 70%);
            backface-visibility: hidden;
            transform: translateZ(3px);
        }

        .coin::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            border-radius: 50%;
            background: #b8860b;
            transform: translateZ(-3px);
        }

        .coin .mark {
            display: inline-block;
            transform: translateY(-2px);
        }

        .coin .tails {
            transform: rotateY(180deg);
        }

        .coin.flip-heads {
            animation: flip-heads 1s ease-in-out forwards;
        }

        .coin.flip-tails {
            animation: flip-tails 1s ease-in-out forwards;
        }

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

        @keyframes flip-heads {
            from { transform: rotateY(0); }
            to { transform: rotateY(720deg); }
        }

        @keyframes flip-tails {
            from { transform: rotateY(0); }
            to { transform: rotateY(900deg); }
        }

        .instructions {
            background: rgba(255,255,255,0.05);
            padding: 20px;
            border-radius: 10px;
            margin: 20px 0;
            border-left: 4px solid #4ecdc4;
        }

        .grid-2 {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 20px;
        }



        .foil-effect {
            position: relative;
            overflow: hidden;
        }

        .foil-effect::before,
        .foil-effect::after {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
        }

        /* fine reflective texture */
        .foil-effect::before {
            background: repeating-linear-gradient(45deg,
                    rgba(255,255,255,0.4) 0px,
                    rgba(255,255,255,0) 4px);
            mix-blend-mode: overlay;
            opacity: 0.3;
        }

        /* moving rainbow sheen */
        .foil-effect::after {
            background: linear-gradient(115deg,
                    rgba(255,0,0,0.4),
                    rgba(255,255,0,0.4),
                    rgba(0,255,0,0.4),
                    rgba(0,255,255,0.4),
                    rgba(0,0,255,0.4),
                    rgba(255,0,255,0.4),
                    rgba(255,0,0,0.4));
            background-size: 400% 400%;
            mix-blend-mode: color-dodge;
            animation: foil-shine 6s linear infinite;
            opacity: 0.6;
        }

        @keyframes foil-shine {
            0% { background-position: 0% 0%; }
            50% { background-position: 100% 100%; }
            100% { background-position: 0% 0%; }
        }

        @keyframes power-glow-offense {
            0% { box-shadow: 0 0 0 0 rgba(255, 0, 0, 0); }
            50% { box-shadow: 0 0 20px 6px rgba(255, 0, 0, 0.8); }
            100% { box-shadow: 0 0 0 0 rgba(255, 0, 0, 0); }
        }

        @keyframes power-glow-defense {
            0% { box-shadow: 0 0 0 0 rgba(0, 0, 255, 0); }
            50% { box-shadow: 0 0 20px 6px rgba(0, 0, 255, 0.8); }
            100% { box-shadow: 0 0 0 0 rgba(0, 0, 255, 0); }
        }

        @keyframes power-particle {
            from { transform: translateY(0) scale(1); opacity: 1; }
            to { transform: translateY(-20px) scale(0); opacity: 0; }
        }

        .card-container.powerup-offense {
            animation: power-glow-offense 0.8s ease-out;
            position: relative;
        }

        .card-container.powerup-defense {
            animation: power-glow-defense 0.8s ease-out;
            position: relative;
        }

        .powerup-particles {
            position: absolute;
            inset: 0;
            pointer-events: none;
            overflow: visible;
        }

        .powerup-particles span {
            position: absolute;
            width: 6px;
            height: 6px;
            border-radius: 50%;
            animation: power-particle 0.8s ease-out forwards;
        }

        .powerup-particles.offense span {
            background: rgba(255, 0, 0, 0.9);
        }

        .powerup-particles.defense span {
            background: rgba(0, 0, 255, 0.9);
        }

        @media (max-width: 768px) {
            #endTurnBtn {
                bottom: 160px;
            }
            .battle-arena {
                height: 50vh;
                gap: 0;
            }

            .hand-log-container {
                flex-direction: column;
                align-items: stretch;
            }

            .vs-section {
                order: -1;
            }

            #vsScreen .vs-side {
                font-size: 6vw;
            }

            #vsPlayer,
            #vsOpponent {
                position: absolute;
                max-width: 45%;
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
            }

            #vsPlayer {
                top: 25%;
                left: 5%;
            }

            #vsOpponent {
                bottom: 25%;
                right: 5%;
                text-align: right;
            }

            #vsScreen .vs-left,
            #vsScreen .vs-right {
                padding: 0;
            }

            .grid-2 {
                grid-template-columns: 1fr;
            }

            .logo {
                font-size: 2rem;
            }

            .card-display {
                padding: 5px;
            }

            .card-display.player1,
            .card-display.player2 {
                justify-content: center;
            }

            #playerLabel,
            #opponentLabel {
                display: none;
            }

        .card-row {
            gap: 5px;
        }

        .card-slot {
            width: 24vw;
            height: 36vw;
            max-width: 96px;
            max-height: 144px;
        }
        }

        .tutorial-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            z-index: 2000;
        }

        .tutorial-bubble {
            position: absolute;
            bottom: 20px;
            left: 50%;
            transform: translateX(-50%);
            background: rgba(0, 0, 0, 0.8);
            color: #fff;
            padding: 15px 20px;
            border-radius: 10px;
            max-width: 420px;
            font-size: 1.25rem;
            line-height: 1.4;
            pointer-events: auto;
        }

        .tutorial-bubble p {
            white-space: pre-line;
            margin: 0;
        }

        .tutorial-next-btn {
            margin-top: 10px;
            background: #4ecdc4;
            border: none;
            border-radius: 5px;
            padding: 5px 12px;
            color: #000;
            font-weight: bold;
            cursor: pointer;
        }

        .tutorial-glow {
            animation: tutorial-glow 1s ease-in-out infinite;
        }

        @keyframes tutorial-glow {
            0%, 100% { box-shadow: 0 0 5px 2px #ff0; }
            50% { box-shadow: 0 0 15px 5px #ff0; }
        }

        .tutorial-flash {
            animation: tutorial-flash 0.3s ease-in-out 2;
        }

        @keyframes tutorial-flash {
            0%, 100% { box-shadow: 0 0 0 0 rgba(255,255,0,0); }
            50% { box-shadow: 0 0 10px 5px rgba(255,255,0,0.8); }
        }

