:root {
    --bg: #05070a;
    --panel: rgba(26, 31, 58, 0.6);
    --accent: #00f2ff;
    --danger: #ff2d55;
    --text: #ffffff;
    --muted: #8892b0;
    --glass-border: rgba(255, 255, 255, 0.1);
}

* { box-sizing: border-box; }
body {
    background: radial-gradient(circle at center, #111827 0%, #05070a 100%);
    overflow-x: hidden;
}

.container {
    min-width: 0;
    overflow: hidden;
    margin-top: 65px;
    margin-bottom: 30px;
    width: 100%;
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 10px 5vw;
    transition: all 0.4s ease;
}

.arena-wrapper {
    display: flex;
    flex-direction: row;
    flex: 1;
    height: 100%;
    width: 100%;
    gap: 0;
    overflow: hidden;
}

.game-content-area {
    flex: 1; 
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: all 0.4s ease;
    min-width: 0;
}

.chat-content-area {
    display: flex;
    flex-direction: column;
    width: 0;
    opacity: 0;
    visibility: hidden;
    overflow: hidden;
    flex-shrink: 0;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease, margin-left 0.5s ease;
}

.chat-content-area.active {
    display: flex;
    opacity: 1;
    visibility: visible;
    width: 400px;
    margin-left: 20px;
}

.chat-drawer {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    width: 400px;
    height: 100%;
    min-height: 550px;
    border-radius: 20px 0 0 20px;
    border-left: 1px solid var(--glass-border);
    background: rgba(10, 12, 20, 0.6);
    backdrop-filter: blur(10px);
}

#chat-frame {
    width: 100%;
    height: 100%;
    border-radius: 15px;
    clip-path: inset(65px 0 0 0); 
    margin-top: -50px; 
    border: none;
    background: transparent;
    opacity: 0;
    transition: opacity 0.5s ease;
    will-change: transform;
}
.chat-content-area.active #chat-frame { opacity: 1; }

.glass-panel {
    background: var(--panel);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 20px 10px 5px 10px;
}

.responsive-text {
    display: inline;
}

#arenaMessage {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    padding: 30px;
    border: 1px solid var(--accent);
    color: var(--accent);
    text-align: center;
    font-family: 'Share Tech Mono', monospace;
    opacity: 0;
    pointer-events: none;
    transition: 0.6s;
    z-index: 999;
}

#arenaMessage.show {
    opacity: 1;
}

.offline-badge {
    background: #ff3e3e;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    border: 1px solid rgba(255, 62, 62, 0.5);
    animation: blink 4s infinite step-end;
    will-change: opacity;
}

.game-meta {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 20;
    pointer-events: none;
}
.game-meta button, .game-meta .btn-skip {
    pointer-events: auto;
}

.meta-badge {
    background: rgba(255,255,255,0.1);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    text-align: center;
    margin-top: 5px;
    border: 1px solid var(--glass-border);
}

.btn-skip {
    background: rgba(255, 62, 62, 0.1);
    backdrop-filter: blur(5px);
    border: 1px solid #ff3e3e;
    color: #ff3e3e;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 12px;
    cursor: pointer;
    text-shadow: 0 0 5px #ff3e3e;
    box-shadow: 0 0 15px rgba(255, 62, 62, 0.2);
    transition: 0.3s;
    max-width: 80% !important;
    text-align: center;
    margin: 8px auto;
}

.btn-skip:hover {
    background: #ff3e3e;
    color: white;
    box-shadow: 0 0 25px rgba(255, 62, 62, 0.6);
}

.opp-hand-row {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 10px 5px 5px 5px;
    height: 65px;
    gap: 5px;
    overflow: visible;
}

.opp-group {
    display: flex;
    gap: 15px;
    flex-shrink: 0;
    align-items: center;
    padding: 0 10px; 
    box-sizing: border-box;
}
.opp-group .playing-card {
    width: 50px !important;
    height: 75px !important;
}
.opp-group .card-center { font-size: 18px; }
.opp-group .card-corner { font-size: 9px; }

.opp-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    justify-content: center;
    padding: 5px;
    background: rgba(255, 255, 255, 0.03);
    min-width: 150px;
    transition: all 0.3s ease;
}

.active-glow {
    border-color: var(--accent) !important;
    box-shadow: 0 0 15px rgba(0, 242, 255, 0.3);
}

.btn-primary {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
    padding: 12px 24px;
    border-radius: 10px;
    font-weight: bold;
    font-size: small;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center; 
    cursor: pointer;
    box-shadow: inset 0 0 10px rgba(0, 242, 255, 0.2);
    transition: 0.3s;
}

.leave-style {
    border-color: #ff3e3e !important;
    color: #ff3e3e !important;
    box-shadow: 0 0 15px rgba(255, 62, 62, 0.3) !important;
}

.leave-style:hover {
    background: #ff3e3e !important;
    color: white !important;
}

.btn-primary:hover {
    background: var(--accent);
    color: #000;
    box-shadow: 0 0 20px var(--accent);
}

.tiny-btn  {
    background: rgba(0, 242, 255, 0.1);
    border: 1px solid var(--accent);
    color: var(--accent);
    border-radius: 8px;
    width: 35px;
    height: 35px;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tiny-btn:active { transform: scale(0.9); }
.tiny-btn.success { background: #39ff14; color: black; border-color: #39ff14; }

.custom-scrollbar::-webkit-scrollbar { height: 4px; }
.custom-scrollbar::-webkit-scrollbar-thumb { background: var(--accent); }

/* ===== PLAYING CARDS ===== */
.playing-card {
    width: 70px;
    height: 100px;
    background: #fefefe;
    border-radius: 6px;
    position: relative;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    color: #1a1a1a;
    font-weight: bold;
}

.playing-card.red-suit { color: #ff260e; }
.playing-card.black-suit { color: #202327; }
.card-corner { position: absolute; font-size: 12px; display: flex; flex-direction: column; align-items: center; line-height: 1; }
.card-corner.top { top: 5px; left: 5px; }
.card-corner.bottom { bottom: 5px; right: 5px; transform: rotate(180deg); }
.card-center { font-size: 30px; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); opacity: 0.3; }
.playing-card.hidden-back { background: linear-gradient(135deg, #0a0c14, #1a1a1a); border: 1px solid var(--accent); }

.playing-card.back-style {
    position: relative;
    background: #0a0c14;
    border: 2px solid var(--accent);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px rgba(0, 242, 255, 0.3), inset 0 0 20px rgba(0, 0, 0, 0.8);
}

.card-pattern {
    position: absolute;
    inset: 0;
    opacity: 0.2;
    background-image: linear-gradient(var(--accent) 1px, transparent 1px), linear-gradient(90deg, var(--accent) 1px, transparent 1px);
    background-size: 10px 10px;
}

.card-middle {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-z {
    font-family: 'Orbitron', sans-serif;
    font-size: 28px;
    font-weight: 900;
    color: var(--accent);
    text-shadow: 0 0 10px var(--accent);
    z-index: 3;
}

.logo-ring {
    position: absolute;
    width: 45px;
    height: 45px;
    border: 2px solid var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 15px var(--accent);
    animation: ring-pulse 2s infinite ease-in-out;
}

.corner-tech {
    position: absolute;
    width: 15px;
    height: 15px;
    border: 2px solid var(--accent);
    opacity: 0.6;
}

.top-left { top: 5px; left: 5px; border-right: none; border-bottom: none; }
.bottom-right { bottom: 5px; right: 5px; border-left: none; border-top: none; }

.playing-card.back-style::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.05), transparent);
    transform: rotate(45deg);
}

.opp-hand-row .playing-card {
    width: 45px !important;
    height: 65px !important;
    font-size: 8px;
}
.opp-hand-row .card-center { font-size: 16px; }
.opp-hand-row .card-corner { font-size: 8px; }

.playing-mini-card {
    width: 40px !important;
    height: 60px !important;
    background: white;
    border-radius: 4px;
    margin-left: -12px;
    box-shadow: 2px 0 5px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border: 1px solid #ddd;
    color: #1a1a1a;
}
.playing-mini-card:first-child { margin-left: 0 !important; }

.playing-mini-card.red { color: #d40000; }
.playing-mini-card.black { color: #1a1a1a; }

.mini-corner {
    position: absolute;
    top: 2px;
    left: 3px;
    font-size: 10px;
}

.mini-suit {
    font-size: 18px;
    opacity: 0.8;
}

.playing-mini-card.back-style {
    background: linear-gradient(135deg, #1a1a1a, #333);
    color: var(--accent);
    border: 1px solid var(--accent);
}

@keyframes ring-pulse {
    0% { transform: scale(0.9); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.5; }
}

/* ===== TUTORIAL ===== */
.hud-btn-container {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
    cursor: pointer;
}

.hud-btn-inner {
    background: rgba(15, 25, 35, 0.6);
    border: 1px solid rgba(0, 242, 255, 0.3);
    padding: 8px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--accent);
    font-size: 11px;
    letter-spacing: 2px;
    font-weight: 900;
    clip-path: polygon(0 0, 100% 0, 100% 70%, 85% 100%, 0 100%);
    transition: all 0.3s;
}

.hud-btn-inner:hover {
    background: var(--accent);
    color: #000;
    box-shadow: 0 0 15px var(--accent);
}

.game-over-overlay.tutorial {
    background: rgba(0, 0, 0, 0.85);
}

#tutorial-game-title {
    font-size: 14px;
    letter-spacing: 5px;
    color: var(--accent);
    opacity: 0.8;
    margin-bottom: 8px;
    text-align: center;
}

.tutorial-card {
    max-width: 500px;
    width: 90%;
    padding: 30px;
    border: 1px solid var(--accent);
}

.tutorial-body {
    text-align: left;
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.tutorial-step {
    display: flex;
    gap: 15px;
    align-items: flex-start;
    padding: 12px;
    background: rgba(0, 242, 255, 0.03);
    border-left: 2px solid var(--accent);
    border-radius: 4px;
    transition: transform 0.2s;
}

.tutorial-step:hover {
    transform: translateX(5px);
    background: rgba(0, 242, 255, 0.08);
}

.step-text b {
    color: var(--accent);
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 1px;
}

.tutorial-body {
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 10px;
}

.tutorial-body::-webkit-scrollbar { width: 4px; }
.tutorial-body::-webkit-scrollbar-track { background: rgba(255,255,255,0.05); }
.tutorial-body::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 10px; }

.step-bullet { color: var(--accent); font-size: 12px; margin-top: 3px; }
.step-text { color: rgba(255, 255, 255, 0.8); font-size: 14px; line-height: 1.5; }

.fan-table-container {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px dashed rgba(0, 242, 255, 0.2);
}

.table-header {
    font-size: 10px;
    letter-spacing: 3px;
    color: var(--accent);
    margin-bottom: 10px;
    font-weight: bold;
}

.fan-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.fan-entry {
    background: rgba(255, 255, 255, 0.03);
    border-left: 2px solid rgba(0, 242, 255, 0.2);
    padding: 8px 12px;
    border-radius: 0 4px 4px 0;
}

.fan-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.fan-row .patt {
    color: var(--accent);
    font-weight: 800;
    font-size: 12px;
    letter-spacing: 0.5px;
}

.fan-row .val {
    font-size: 10px;
    background: var(--accent);
    color: #000;
    padding: 2px 6px;
    font-weight: 900;
    border-radius: 2px;
}

.fan-desc {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    line-height: 1.4;
    font-style: italic;
}

.close-x {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    color: #fff;
    opacity: 0.5;
    cursor: pointer;
}
.close-x:hover { opacity: 1; color: #ff4655; }

/* ===== ARENA HEADER ===== */
.arena-header {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.brand {
    font-size: 32px;
    letter-spacing: 4px;
    font-weight: 900;
}
.accent-text { color: var(--accent); text-shadow: 0 0 15px var(--accent); text-decoration: none; }

.user-tools {
    display: flex;
    flex-direction: row;
    gap: 10px;
}

/* ===== ARENA LOBBY ===== */
.arena-lobby {
    flex: 1;
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 20px;
    min-height: 550px;
    width: 100%;
}

.sidebar {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.room-list {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    overflow-y: auto;
}

.room-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-left: 3px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.room-item:hover {
    background: rgba(0, 242, 255, 0.1);
    border-left: 3px solid var(--accent);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.room-item.active-room {
    background: rgba(0, 242, 255, 0.2);
    border-left: 3px solid var(--accent);
    box-shadow: inset 0 0 15px rgba(0, 242, 255, 0.1);
}

.sidebar-footer {
    padding: 15px;
    flex-shrink: 0;
}

.join-id-wrapper {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 4px;
    transition: 0.3s;
}

.join-id-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(0, 242, 255, 0.2);
}

#direct-join-input {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    padding: 8px 12px;
    font-size: 12px;
    font-family: 'Orbitron', sans-serif;
    outline: none;
}

#direct-join-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.btn-join-arrow {
    background: var(--accent);
    color: black;
    border: none;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-weight: bold;
    transition: 0.2s;
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(0px);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.mobile-sidebar-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 65px;
    z-index: 999;
    background: var(--accent);
    color: black;
    border: none;
    padding: 12px 20px;
    border-radius: 50px;
    font-weight: bold;
    font-size: small;
    box-shadow: 0 0 20px rgba(0, 242, 255, 0.4);
}
.mobile-close-btn { display: none; }

#chat-mobile-btn {
    display: none;
    position: fixed;
    left: 20px;
    bottom: 20px;
    z-index: 999;
    background: var(--accent);
    color: black;
    border: none;
    width: 39px;
    height: 39px;
    border-radius: 50%;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px rgba(0, 242, 255, 0.4);
}

.chat-blur-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9990; 
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, backdrop-filter 0.4s ease;
    pointer-events: none;
}

.game-name {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text);
}

.player-count {
    font-size: 0.85rem;
    color: var(--accent);
    font-family: monospace;
    background: rgba(0, 242, 255, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
}

.main-view-header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1.17em;
    font-weight: bold;
    padding: 5px 0;
    letter-spacing: 1px;
    color: var(--text);
    text-align: center;
}

.header-left {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.panel-header.code {
    font-family: 'Orbitron', 'Courier New', monospace;
    letter-spacing: 2px;
    color: var(--accent);
    text-shadow: 0 0 8px rgba(0, 242, 255, 0.4);
    background: rgba(0, 242, 255, 0.05);
    padding: 4px 12px;
    border-radius: 4px;
    border: 1px solid rgba(0, 242, 255, 0.2);
}

.status-msg {
    font-family: 'Orbitron', 'Courier New', monospace;
    letter-spacing: 2px;
    color: var(--accent);
    text-shadow: 0 0 8px rgba(0, 242, 255, 0.4);
    font-weight: bold;
}

.header-actions-right {
    position: absolute;
    right: 15px;
    display: flex;
    gap: 10px;
}

.player-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 20px;
    padding: 20px;
}

.player-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    transition: 0.3s;
    position: relative;
    overflow: hidden;
    align-items: center;
}

.player-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent);
}

.kick-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 20px;
    height: 20px;
    background: rgba(255, 77, 77, 0.2);
    border: 1px solid rgba(255, 77, 77, 0.5);
    color: #ff4d4d;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 10;
}

.kick-btn:hover {
    background: #ff4d4d;
    color: white;
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(255, 77, 77, 0.5);
}

.player-avatar {
    width: 60px;
    height: 60px;
    background: linear-gradient(45deg, #1a1f3a, var(--accent));
    margin: 0 auto 15px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 24px;
    box-shadow: 0 0 15px rgba(0, 242, 255, 0.3);
}

.player-avatar.mini {
    width: 40px;
    height: 40px;
    margin: 5px;
}

.player-avatar.grayscale {
    filter: grayscale(1) brightness(0.6);
    border: 2px solid #ff3e3e;
}

.player-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
}

.player-name {
    display: block;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.badges {
    display: flex;
    gap: 5px;
    flex-direction: row;
}

.presence-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 70px;
  text-align: center;
  gap: 4px;
  padding: 2px 6px;
  font-size: 11px;
  background: #132892be;
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  color: #ffffff;
}

.presence-badge img {
  width: 14px;
  height: 14px;
}

.host-badge {
    font-size: 10px;
    background: #ffae00;
    color: #000;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 800;
}

.ready-badge {
    font-size: 10px;
    color: var(--muted);
    border: 1px solid var(--muted);
    padding: 3px 8px;
    border-radius: 10px;
    align-items: center;
}

.ready-badge.ready {
    color: #000;
    background: #00ff88;
    border: none;
}

.win-count {
    background: rgba(255, 215, 0, 0.1);
    color: #ffd700;
    border: 1px solid rgba(255, 215, 0, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.5);
}

.action-bar-container {
    display: flex;
    flex-direction: column;
    margin-top: auto;
    background: linear-gradient(to top, rgba(0,0,0,0.4), transparent);
    border-top: 1px solid rgba(255,255,255,0.05);
}

.action-bar {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 15px;
    padding: 15px 10px 25px 10px;
    background: linear-gradient(to top, rgba(0,0,0,0.4), transparent);
    border-top: 1px solid rgba(255,255,255,0.05);
}

.action-status {
    text-align: center;
    font-size: 11px;
    margin: 0 10px;
    letter-spacing: 3px;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
}

.action-bar-inner {
    display: flex;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    gap: 12px;
    align-items: center;
}

.action-status.all-ready {
    color: #00ff88;
}

.btn-action {
    flex: 1;
    height: 48px;
    font-family: 'Outfit', sans-serif;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 2px;
    border: none;
    cursor: pointer;
    position: relative;
    clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
    transition: all 0.3s cubic-bezier(0.2, 1, 0.3, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    gap: 5px;
}

.btn-action::after {
    content: '';
    position: absolute;
    inset: 1px;
    background: inherit;
    clip-path: inherit;
    z-index: -1;
    opacity: 0.8;
}

.btn-action:hover {
    transform: translateY(-2px);
    filter: brightness(1.2);
}

.btn-action:active {
    transform: translateY(1px) scale(0.98);
}

.btn-action.locked {
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: rgba(255, 255, 255, 0.2) !important;
    cursor: not-allowed;
    clip-path: polygon(0 0, 95% 0, 100% 30%, 100% 100%, 5% 100%, 0 70%);
}

.btn-action.start {
    background: #00ff88;
    color: #050a0e;
    box-shadow: 0 4px 0px #00a85a;
}

.btn-action.start:hover {
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.4), 0 6px 0px #00a85a;
}

.btn-action.join {
    background: #00fbff;
    color: #050a0e;
    box-shadow: 0 4px 0px #00b8bd;
}

.btn-action.join:hover {
    box-shadow: 0 0 20px rgba(0, 251, 255, 0.4), 0 6px 0px #00b8bd;
}

.btn-action.leave-minimal {
    flex: 1;
    clip-path: none;
    background: rgba(255, 70, 85, 0.1);
    border: 1px solid rgba(255, 70, 85, 0.5);
    color: #ff4655;
}

.btn-action.leave-minimal:hover {
    background: #ff4655;
    color: #fff;
    box-shadow: 0 0 15px rgba(255, 70, 85, 0.5);
}

.dot { flex-shrink: 0; }
.pulse {
    width: 8px;
    height: 8px;
    background: #00ff88;
    border-radius: 50%;
    display: inline-block;
    margin-right: 10px;
    box-shadow: 0 0 4px #00ff88;
    animation: pulse 2s infinite ease-in-out;
    will-change: transform;
}

.pulse::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: 50%;
    box-shadow: 0 0 6px #00ff88;
    opacity: 0.6;
}

@keyframes pulse {
    0%, 100% { transform: scale(0.85); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 1; }
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ===== CREATE ROOM MODAL ===== */
#create-room-modal {
    position: fixed;
    inset: 0;
    background: rgba(10, 12, 20, 0.95); 
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

#create-room-modal.show {
    display: flex;
    opacity: 1;
    pointer-events: auto;
}

.setup-group {
    text-align: left;
    margin-bottom: 20px;
}
.setup-group label {
    display: block;
    font-size: 10px;
    letter-spacing: 2px;
    margin-bottom: 8px;
    color: rgba(255,255,255,0.5);
}

.custom-select {
    position: relative;
    width: 100%;
    user-select: none;
}
.select-trigger {
    background: rgba(26, 29, 41, 0.6);
    border: 1px solid rgba(0, 242, 255, 0.3);
    color: white;
    padding: 12px 15px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 1px;
}
.select-trigger:hover {
    border-color: var(--accent);
    background: rgba(0, 242, 255, 0.05);
}
.select-options {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    width: 100%;
    background: #0f121a;
    border: 1px solid var(--accent);
    border-radius: 8px;
    overflow: hidden;
    z-index: 1000;
    display: none;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.custom-select.active .select-options {
    display: block;
}

.option {
    padding: 12px 15px;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 12px;
}
.option:hover {
    background: var(--accent);
    color: #000;
    font-weight: bold;
}

.counter-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.05);
    padding: 10px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.setup-actions {
    width: 100%;
    display: flex;
    gap: 30px;
    align-items: center;
    justify-content: center;
}

.btn-counter {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: var(--accent);
    color: black;
    border: none;
    font-weight: bold;
    font-size: 20px;
    cursor: pointer;
}
.btn-counter:active { transform: scale(0.9); }

#max-player-val {
    font-size: 24px;
    font-weight: 900;
    color: var(--accent);
    text-shadow: 0 0 10px var(--accent);
}

.toggle-group, .wind-toggle-group {
    display: flex;
    gap: 10px;
}
.toggle-group button, .wind-toggle-group button {
    flex: 1;
    background: transparent;
    border: 1px solid var(--glass-border);
    color: white;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
}
.toggle-group button.active, .wind-toggle-group button.active {
    background: var(--accent);
    color: black;
    border-color: var(--accent);
}

/* ===== GAME RESULT ===== */
.game-over-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: none !important;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    will-change: opacity, visibility;
    backface-visibility: hidden;
    visibility: hidden;
    transition: opacity 0.4s ease;
}

.game-over-overlay.show {
    opacity: 1;
    visibility: visible;
    backdrop-filter: blur(4px);
}

.result-card {
    background: rgba(15, 20, 30, 0.85);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(0, 242, 255, 0.3);
    border-radius: 24px;
    padding: 30px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5), inset 0 0 20px rgba(0, 242, 255, 0.1);
    will-change: transform;
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.game-over-overlay.show .result-card {
    transform: translate3d(0, 0, 0) scale(1);
}

#result-title {
    font-size: 14px;
    letter-spacing: 5px;
    color: var(--accent);
    opacity: 0.8;
    margin-bottom: 5px;
}

.header-line {
    width: 60px;
    height: 2px;
    background: var(--accent);
    margin: 0 auto 20px auto;
    box-shadow: 0 0 10px var(--accent);
}

.winner-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    margin-bottom: 20px;
}

.avatar-crown {
    filter: drop-shadow(0 0 10px gold);
}

.result-avatar {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    border: 3px solid var(--accent);
    box-shadow: 0 0 20px rgba(0, 242, 255, 0.4);
    margin-bottom: 10px;
}

#result-winner-name {
    font-size: 24px;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 10px rgba(255,255,255,0.3);
}

.result-description {
    background: rgba(255, 255, 255, 0.05);
    padding: 10px;
    border-radius: 12px;
    font-size: 16px;
    color: var(--accent);
    margin-bottom: 25px;
    border: 1px dashed rgba(0, 242, 255, 0.2);
}

.controls-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.glow-effect:hover {
    box-shadow: 0 0 20px var(--accent);
    transform: translateY(-2px);
}

.draw-text {
    font-size: 28px;
    font-weight: bold;
    color: #aaa;
    letter-spacing: 2px;
}

.waiting-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 8px;
}

.dot-pulse {
    width: 8px;
    height: 8px;
    background: #00ff88;
    border-radius: 50%;
    display: inline-block;
    margin-right: 10px;
    box-shadow: 0 0 10px #00ff88;
    animation: blink 1.5s infinite ease-in-out;
    will-change: transform, opacity;
}

/* ===== PROMPT INPUT ===== */
.prompt {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.25s ease;
  z-index: 9999;
}

.prompt-container {
  padding: 20px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  min-width: 350px;
  max-width: 420px;
  background: #111;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 20px rgba(21, 94, 204, 0.1);
}

.prompt-header {
  text-align: center;
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 24px;
  letter-spacing: -0.5px;
  background: linear-gradient(165deg, #fff 0%, #888 50%, #fff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

.prompt-title {
  color: #ececec;
  font-size: 17px;
  font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
}

.prompt-description {
  color: #888;
  font-size: 13px;
  line-height: 1.5;
  font-family: 'Inter', sans-serif;
}

.prompt-container input {
  width: 100%;
  box-sizing: border-box;
  background: #1a1a1a;
  margin-top: 8px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid #333;
  color: white;
  font-size: 15px;
  transition: all 0.2s ease;
}

.prompt-container input:focus {
  outline: none;
  border-color: #155ecc;
  background: #222;
  box-shadow: 0 0 0 4px rgba(21, 94, 204, 0.15);
}

.prompt-container button {
  display: flex;
  justify-content: center;
  margin: auto;
  border: none;
  border-radius: 8px;
  color: #000;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.25s ease;
}

.joinBtn {
  background: #fffbad;
  padding: 10px 15px;
  color: #000;
  font-weight: 600;
  margin-top: 5px;
  letter-spacing: 0.3px;
}

.joinBtn:hover {
  background: #fff260;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(204, 201, 21, 0.45);
}

.prompt-section {
  margin-bottom: 16px;
}

.prompt-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 24px 0;
  color: #444;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.prompt-divider::before,
.prompt-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid #222;
}

.prompt-divider span {
  padding: 0 8px;
}

.prompt-error {
  color: #FF2900;
  font-size: 12px;
  margin: 5px 0;
  text-align: center;
}

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

.prompt-google {
  background: #ffffff;
  color: #404040 !important;
  margin: 5px 0;
  padding: 8px;
  width: 100%;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
  gap: 8px;
  transition: 0.25s ease;
  align-items: center;
}

.prompt-google:hover {
  background: #f1f1f1;
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(255,255,255,0.15);
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

/* ===== SETTINGS MODAL ===== */
.settings-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 1;
  transition: opacity 0.3s ease;
}

.settings-modal.hidden {
  pointer-events: none;
  opacity: 0;
}

.settings-modal-content {
  width: 90vw;
  max-width: 440px;
  max-height: 550px;
  background: #1c1c1c;
  color: #e6e6e6;
  padding: 30px;
  border-radius: 28px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  animation: popIn .25s ease;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}
.settings-modal-content::-webkit-scrollbar { display: none; }

.settings-modal-content h3 {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 16px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.setting-item {
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  border-bottom: 1px solid #333;
}

.setting-item > span:first-child {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 14px;
  color: #e6e6e6;
}

.account-setting {
  flex-direction: column;
  align-items: stretch;
}

.account-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.account-title {
  color: #e6e6e6;
  font-size: 15px;
  font-weight: 500;
}

.account-text {
  color: #c2c2c2;
  font-size: 12px;
  text-align: right;
  font-weight: 600;
}

.badge-selector {
  position: relative;
}

.badge-button {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #e6e6e6;
  padding: 6px 14px;
  border-radius: 10px;
  transition: all 0.2s;
}

.badge-button:hover {
  background: rgba(255, 255, 255, 0.1);
}

.badge-icon {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  object-fit: contain;
}

.badge-button span {
  font-size: 12px;
}

.badge-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: #333;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  min-width: 180px;
  max-height: 250px;
  overflow-y: auto;
  z-index: 100;
  padding: 6px;
  transform-origin: top right;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: block;
}

.badge-dropdown::-webkit-scrollbar { width: 4px; }
.badge-dropdown::-webkit-scrollbar-thumb { 
  background: rgba(255,255,255,0.1); 
  border-radius: 10px; 
}

.badge-dropdown.hidden {
  opacity: 0;
  transform: scale(0.9) translateY(-10px);
  pointer-events: none;
}

.badge-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  gap: 10px;
  border-radius: 10px;
  color: #c2c2c2;
  transition: all 0.15s ease;
}

.badge-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #e6e6e6;
  transform: translateX(4px);
}

.badge-item img {
  width: 20px;
  height: 20px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.badge-item.equipped {
  color: #155ecc;
  background: rgba(21, 94, 204, 0.1);
}

.badge-item.unequip {
  color: #ff5252;
  margin-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0 0 10px 10px;
}

.badge-item.unequip:hover {
  background: rgba(255, 82, 82, 0.1);
  color: #ff3333;
}

#winText {
    color: var(--accent);
    font-weight: 800;
    text-shadow: 0 0 10px rgba(0, 255, 251, 0.5);
}

.icon-setting {
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.icon-carousel {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 6px;
}

.icon-viewport {
  width: 100%;
  overflow: hidden;
}

.icon-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 48px;
  gap: 8px;
  justify-content: center; 
  justify-items: center; 
}

.profile-icon-option {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border .15s ease, transform .15s ease;
}

.profile-icon-option:hover {
  transform: scale(1.05);
}

.profile-icon-option.selected {
  border-color: #155ecc;
  box-shadow: 0 0 15px rgba(21, 94, 204, 0.3);
}

.google-icon-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.google-avatar.standalone {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  cursor: pointer;
  display: block;
}

.carousel-arrow {
  background: transparent;
  border: none;
  color: #888;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}

.carousel-arrow:hover {
  background: rgba(255,255,255,0.08);
}

.google-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px !important;
  border-radius: 14px;
  cursor: pointer;
  pointer-events: none;
  background: #595959;
  color: #e6e6e6;
  width: 100%;
  margin: 5px 0;
  font-size: 12px;
  font-weight: 700;
  transition: all 0.25s ease;
}

.google-btn.connected {
  background: #41ffa6;
  color: #5f6368;
  cursor: default;
  border: 1px solid #0f531f;
}

.google-status {
  text-align: center;
  font-size: 13px;
  opacity: 0.8;
  display: block;
}

.close-settings-btn {
  display: block;
  margin-left: auto;
  margin-right: auto; 
  width: 50%;
  padding: 10px;
  background: #595959;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #e6e6e6;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.google-btn:hover,
.close-settings-btn:hover {
  background: #1f70ee;
}

@keyframes popIn {
  from { transform: scale(.9); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* ===== GAME SHU ===== */
#shu-table {
    position: relative;
    overflow-y: auto; 
    overflow-x: hidden;
    border-radius: 20px;
    height: 100%;
    width: 100%;
    min-height: 550px;
    border: 1px solid var(--glass-border);
    background: radial-gradient(circle at center, #2d3663 0%, #0f0a1a 100%);
    overflow-y: auto;
    overflow-x: hidden;
    display: none;
    flex-direction: column;
}

.table-surface {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 50px;
    flex: 1; 
    padding: 20px 0;
    z-index: 5;
}

.shu-card {
    position: relative;
    width: 70px;
    height: 105px;
    border-radius: 8px;
    background: #0a0c14;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-family: 'Orbitron', 'Segoe UI', sans-serif;
    font-weight: 900;
    transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
    user-select: none;
    flex-shrink: 0;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.shu-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(255,255,255,0.1) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.1) 1px, transparent 1px);
    background-size: 10px 10px;
    z-index: 0;
    opacity: 0.5;
}

.shu-card::after {
    content: '';
    position: absolute;
    inset: 6px;
    background: 
        linear-gradient(currentColor, currentColor) no-repeat 0 0 / 12px 2px,
        linear-gradient(currentColor, currentColor) no-repeat 0 0 / 2px 12px,
        linear-gradient(currentColor, currentColor) no-repeat 100% 100% / 12px 2px,
        linear-gradient(currentColor, currentColor) no-repeat 100% 100% / 2px 12px;
    z-index: 1;
    pointer-events: none;
    opacity: 0.8;
}

.shu-card span {
    position: relative;
    z-index: 2;
    font-family: 'Orbitron', sans-serif;
    font-size: 25px;
    text-shadow: 0 0 10px currentColor; 
}
.shu-card span.small-text, .small-text {
    font-size: 10px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    display: block;
    width: 90%;
    text-align: center;
    line-height: 1;
    white-space: nowrap; 
    overflow: hidden;
    text-overflow: ellipsis;
}

.shu-card.red { 
    color: #ff3e3e;
    box-shadow: inset 0 0 15px rgba(255, 62, 62, 0.3), 0 5px 15px rgba(0,0,0,0.5);
    border-color: rgba(255, 62, 62, 0.5);
}
.shu-card.blue { 
    color: #00d2ff;
    box-shadow: inset 0 0 15px rgba(0, 210, 255, 0.3), 0 5px 15px rgba(0,0,0,0.5);
    border-color: rgba(0, 210, 255, 0.5);
}
.shu-card.green { 
    color: #39ff14;
    box-shadow: inset 0 0 15px rgba(57, 255, 20, 0.3), 0 5px 15px rgba(0,0,0,0.5);
    border-color: rgba(57, 255, 20, 0.5);
}
.shu-card.yellow { 
    color: #fff01f;
    box-shadow: inset 0 0 15px rgba(255, 240, 31, 0.3), 0 5px 15px rgba(0,0,0,0.5);
    border-color: rgba(255, 240, 31, 0.5);
}
.shu-card.black { 
    color: #ffffff;
    background: linear-gradient(145deg, #1a1a1a, #000000);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
}

.hand-scroll .shu-card:hover {
    transform: translateY(-10px) scale(1.1) !important;
    z-index: 100;
    box-shadow: 0 15px 30px rgba(0,0,0,0.6), 0 0 20px currentColor;
    cursor: pointer;
}

.table-surface .shu-card:hover {
    transform: inherit !important;
    box-shadow: none !important;
    cursor: default;
}

.deck-back {
    background: #0f172a !important;
    border: 1px solid var(--accent) !important;
    color: var(--accent) !important;
}
.deck-back::before {
    background-image: radial-gradient(var(--accent) 1px, transparent 1px);
    background-size: 5px 5px;
}

.card-stack, .discard-slot {
    position: relative;
    width: 70px;
    height: 105px;
    display: block;
    margin: 0 auto;
}

.deck-back, .messy-card, .discard-slot .shu-card {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    margin: 0 !important;
    width: 70px;
    height: 105px;
}

.deck-area, .discard-area {
    position: relative;
    width: 70px;
    height: 105px;
}

.deck-label {
    text-align: center;
    margin-top: 15px;
    font-size: 13px;
    font-weight: 600;
}

.layer-3 { transform: translate(6px, 6px); opacity: 0.3; z-index: 1; }
.layer-2 { transform: translate(3px, 3px); opacity: 0.6; z-index: 2; }
.layer-1 { transform: translate(0, 0); z-index: 3; opacity: 1 !important; }

.messy-1 { transform: rotate(-8deg) translate(-2px, 3px); opacity: 0.8; }
.messy-2 { transform: rotate(12deg) translate(4px, -2px); opacity: 0.6; }
.messy-3 { transform: rotate(-22deg) translate(1px, -4px); opacity: 0.4; }

.shu-shout-btn {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: #0a0c14;
    color: #ffaa00;
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
    font-size: 16px;
    cursor: pointer;
    border: 2px solid rgba(255, 170, 0, 0.3);
    box-shadow:  inset 0 0 15px rgba(255, 170, 0, 0.2),  0 0 20px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow: hidden;
}

.shu-shout-btn::before {
    content: '';
    position: absolute;
    inset: 4px;
    border-radius: 50%;
    border: 1px solid rgba(255, 170, 0, 0.5);
    background: radial-gradient(circle, rgba(255, 170, 0, 0.1) 0%, transparent 70%);
    animation: reactorPulse 2s infinite ease-in-out;
}

.shu-shout-btn:hover {
    transform: scale(1.1);
    color: #fff;
    border-color: #ffaa00;
    box-shadow: 0 0 30px rgba(255, 170, 0, 0.6), inset 0 0 20px rgba(255, 170, 0, 0.4);
    text-shadow: 0 0 10px #ffaa00;
}

.shu-shout-btn:active {
    transform: scale(0.9) rotate(5deg);
    filter: brightness(1.5);
}

.shu-shout-btn.danger-glow {
    border-color: #ff3e3e;
    box-shadow: 0 0 20px #ff3e3e, inset 0 0 10px #ff3e3e;
    animation: pulse-red 1s infinite;
}

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

.my-shu-area {
    width: 100%;
    margin-top: auto;
    background: linear-gradient(to top, rgba(0,0,0,0.5), transparent);
    z-index: 10;
    overflow: visible;
}

.hand-scroll {
    display: flex;
    justify-content: safe center; 
    gap: 5px;
    padding: 40px 40px 10px 40px; 
    margin-top: -30px; 
    overflow-x: auto;
    overflow-y: visible;
    width: 100%;
    min-height: 160px;
    scroll-padding: 0 40px;
    scroll-behavior: smooth;
}

#my-shu-hand > div:first-child {
    margin-left: auto;
}
#my-shu-hand > div:last-child {
    margin-right: auto;
}

.shu-opponents {
    justify-content: space-around;
    display: flex;
    padding: 20px;
    width: 100%;
    height: 100%;
    min-height: 120px;
    z-index: 10;
    pointer-events: none;
}

.shu-opp-slot, .bj-opp-slot {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    gap: 5px;
    color: #eee;
    font-size: 14px;
}
#shu-opp-top { top: 20px; left: 50%; transform: translateX(-50%); }
#shu-opp-left { left: 40px; top: 50%; transform: translateY(-50%) rotate(90deg); }
#shu-opp-right { right: 40px; top: 50%; transform: translateY(-50%) rotate(-90deg); }

.shu-mini-card {
    position: relative;
    width: 22px;
    height: 34px;
    background: #0a0c14;
    border: 1px solid var(--accent);
    border-radius: 4px;
    margin-left: -8px;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.5);
    flex-shrink: 0;
    transition: transform 0.2s ease;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.shu-mini-card:first-child {
    margin-left: 20px;
}

.shu-mini-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(255, 255, 255, 0.1) 0.5px, transparent 0.5px);
    background-size: 4px 4px;
    opacity: 0.6;
}

.shu-mini-card::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 4px;
    height: 4px;
    border-top: 1px solid rgba(0, 210, 255, 0.5);
    border-left: 1px solid rgba(0, 210, 255, 0.5);
}

.shu-opp-details {
    display: flex;
    flex-direction: column;
    overflow: visible;
    align-items: center;
    justify-content: center;
}

.count-pill {
    background: rgba(0, 0, 0, 0.4);
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 10px;
    color: #eee;
    border: 1px solid rgba(255,255,255,0.1);
}

.card-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

#current-turn-name {
    font-size: 24px;
    font-weight: bold;
}

#color-picker-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 10000 !important;
    display: none;
    align-items: center;
    justify-content: center;
}

.color-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 20px auto auto auto;
}

.color-opt {
    width: 80px;
    height: 80px;
    border-radius: 12px;
    cursor: pointer;
    border: 3px solid rgba(255,255,255,0.2);
    transition: 0.3s;
}

.color-opt:hover { transform: scale(1.1); border-color: white; }
.color-opt.red { background: #ea3223; box-shadow: 0 0 15px #ea3223; }
.color-opt.blue { background: #0055af; box-shadow: 0 0 15px #0055af; }
.color-opt.green { background: #33a852; box-shadow: 0 0 15px #33a852; }
.color-opt.yellow { background: #ffbc03; box-shadow: 0 0 15px #ffbc03; }

.shu-leaderboard {
    width: 100%;
    margin-top: 15px;
    background: rgba(20, 20, 30, 0.5);
    border-radius: 12px;
    padding: 12px;
    border: 1px solid rgba(0, 255, 136, 0.2);
}

.shu-cards {
    font-size: 20px;
    font-weight: 900;
    color: #fff;
}

.result-row.winner-row .shu-cards {
    color: #00ff88;
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
}

@keyframes reactorPulse {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.05); }
}

/* ===== GAME BLACKJACK ===== */
#blackjack-table {
    position: relative;
    border-radius: 20px;
    height: 100%;
    width: 100%;
    min-height: 550px;
    border: 1px solid var(--glass-border);
    background: radial-gradient(circle at center, #1a4a1a 0%, #050a05 100%);
    overflow-y: auto;
    overflow-x: hidden;
    display: none;
    flex-direction: column;
    padding: 20px;
    align-items: center;
}

.blackjack .game-meta {
    top: 20px;
    left: 20px;
    text-align: left;
    z-index: 100;
}

.bj-hand-row {
    display: flex;
    gap: 5px;
    justify-content: center;
    min-height: 100px;
}

.bj-badge, .bj-score {
    background: rgba(0, 0, 0, 0.5);
    padding: 5px 15px;
    border-radius: 20px;
    border: 1px solid var(--accent);
    color: var(--accent);
    font-size: 14px;
    font-weight: bold;
    text-align: center;
}

.glitch-text {
    font-family: 'Orbitron', sans-serif;
    color: var(--accent);
    letter-spacing: 2px;
    text-align: center;
}

.bj-dealer-area {
    margin-top: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.my-bj-area {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 22px;
    margin: 0 auto;
    z-index: 10;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    order: 2;
}

.bj-players-row {
    display: flex;
    align-items: center;
    justify-content: safe center; 
    width: 100%;
    padding: 20px 50px; 
    margin-top: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-shrink: 0;
}
.bj-players-row::-webkit-scrollbar { display: none; }

#blackjack-table .bj-opp-slot {
    position: relative !important;
    transform: none !important;
}

#bj-opponents-left, #bj-opponents-right {
    flex: 1;
    display: flex;
    gap: 15px;
    align-items: center;
    min-width: fit-content; 
}

#bj-opponents-left {
    order: 1;
    justify-content: flex-end;
    padding-right: 30px;
}

#bj-opponents-right {
    order: 3;
    justify-content: flex-start;
    padding-left: 30px;
}

.bj-points {
    font-size: large;
    gap: 2px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.bj-score-badge {
    background: rgba(0,0,0,0.5);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
}

.bj-btn-group {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.btn-bj {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 900;
    font-size: small;
}

.btn-bj.hit {
    background: #39ff14;
    box-shadow: 0 0 10px #39ff14;
}

.btn-bj.stand {
    background: #ff3e3e;
    color: white;
    box-shadow: 0 0 10px #ff3e3e;
}

.btn-mj {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 900;
    font-size: small;
    align-items: center;
}

.btn-mj.chow, .btn-mj.pong, .btn-mj.kong {
    background: #14ffff;
    box-shadow: 0 0 10px #14ffff;
}

.btn-mj.mahjong {
    color: white;
    background: #8d14ff;
    box-shadow: 0 0 10px #8d14ff;
}

.btn-mj.discard {
    color: white;
    background: #ff3e3e;
    box-shadow: 0 0 10px #ff3e3e;
}

.bj-leaderboard {
    width: 100%;
    margin-top: 15px;
    background: rgba(15, 15, 20, 0.4);
    border-radius: 12px;
    padding: 12px;
    border: 1px solid rgba(255, 70, 85, 0.2);
}

.bj-lb-points {
    font-size: 22px;
    font-weight: 900;
    color: #ff4655;
    text-shadow: 0 0 10px rgba(255, 70, 85, 0.3);
}

.result-row.winner-row .bj-lb-points {
    color: #00ff88;
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.4);
}

/* ===== GAME POKER ===== */
#poker-table {
    position: relative;
    overflow-y: auto; 
    overflow-x: hidden;
    border: 1px solid var(--glass-border);
    background: radial-gradient(circle at center, #0a192f 0%, #020617 100%);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    height: 100%;
    width: 100%;
    min-height: 550px;
    border-radius: 20px;
}

.poker .game-meta {
    top: 20px;
    left: 20px;
    text-align: left;
    z-index: 100;
}

#poker-table .opp-slot {
    position: relative !important;
    transform: none !important;
    flex-shrink: 0;
}

.poker-board {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-top: 40px;
}

.poker-stats {
    margin-top: 8px;
    align-items: center;
    justify-content: center;
    display: flex;
    flex-direction: row;
    gap: 15px;
}

.poker-community-row {
    display: flex;
    gap: 10px;
    min-height: 110px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.poker-pot {
    background: linear-gradient(135deg, #ffd700, #b8860b);
    color: black;
    padding: 8px 20px;
    border-radius: 50px;
    font-weight: 900;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
}

.poker-players-row {
    display: flex;
    align-items: center; 
    justify-content: safe center;
    width: 100%;
    padding: 20px 50px;
    margin-top: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-shrink: 0;
    gap: 30px;
}
.poker-players-row::-webkit-scrollbar { display: none; }

#poker-opps-left, #poker-opps-right {
    flex: 1;
    display: flex;
    gap: 15px;
    align-items: center;
    min-width: fit-content; 
    flex-shrink: 0;
}

#poker-opps-left {
    order: 1;
    justify-content: flex-end;
    padding-right: 30px;
}

#poker-opps-right {
    order: 3;
    justify-content: flex-start;
    padding-left: 30px;
}

.my-poker-seat {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 22px;
    margin: 0 auto;
    z-index: 10;
    min-width: 320px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    order: 2;
}

.poker-hand, .opp-cards {
    display: flex;
    flex-direction: row;
    gap: 8px;
}

.poker-btn-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    width: 100%;
    margin-top: 10px;
}

.poker-btn {
    padding: 10px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.05);
    color: white;
    font-weight: bold;
    font-size: small;
    text-align: center;
    cursor: pointer;
}

.poker-btn.fold { color: #ef4444; border-color: #ef4444; }
.poker-btn.raise { color: #10b981; border-color: #10b981; }
.poker-btn.raise-confirm { padding: 2px 10px; font-size: 12px; }

.poker-raise-container {
    display: none;
    margin-top: 10px;
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 8px;
}

.poker-raise-slider {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.chip-badge {
    font-size: 11px;
    color: #ffd700;
    margin-top: 5px;
}

.poker-leaderboard {
    width: 100%;
    margin-top: 15px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 12px;
    border: 1px solid rgba(255, 215, 0, 0.1);
}

.result-row.winner-row {
    background: rgba(255, 215, 0, 0.1) !important;
    border-left: 3px solid gold !important;
}

.result-row.winner-row .chip-count {
    color: gold;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.result-row.bankrupt-row {
    opacity: 0.6;
    filter: grayscale(0.5);
    border-left: 3px solid #555;
}

.chip-count {
    font-size: 18px;
    font-weight: 800;
    color: var(--accent);
}

/* ===== GAME BIG 2 ===== */
#big2-table {
    position: relative;
    overflow-y: auto; 
    overflow-x: hidden;
    border: 1px solid var(--glass-border);
    background: radial-gradient(circle, #4a0000 0%, #1a0000 100%);
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    min-height: 550px;
    border-radius: 20px;
}

.pres-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 0;
}

.pile-container {
    padding: 20px 40px;
    border-radius: 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.pile-badge {
    margin-top: 10px;
    color: #ffd700;
    font-size: 14px;
    font-weight: bold;
}

.card-placeholder {
    width: 70px;
    height: 100px;
    border: 2px dashed rgba(255,255,255,0.3);
    border-radius: 6px;
    display: flex;
    align-items: center;
    font-family: 'Share Tech Mono', monospace;
}

.hand-display {
    display: flex;
    align-items: center;
    flex-direction: row;
    gap: 8px;
}

.pres-card-wrapper {
    margin-left: -30px;
    transition: transform 0.2s;
    cursor: pointer;
    flex-shrink: 0;
}

.pres-card-wrapper:first-child {
    margin-left: 0;
}

.pres-card-wrapper:hover {
    transform: translateY(-10px);
    z-index: 100;
}

.pres-card-wrapper.selected {
    transform: translateY(-35px);
    filter: drop-shadow(0 0 10px var(--danger));
}

.pres-players-row {
    display: flex;
    align-items: center; 
    justify-content: safe center;
    width: 100%;
    padding: 20px 50px;
    margin-top: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-shrink: 0;
    gap: 30px;
}
.pres-players-row::-webkit-scrollbar { display: none; }

#pres-opps-left, #pres-opps-right {
    flex: 1;
    display: flex;
    gap: 15px;
    align-items: center;
    min-width: fit-content; 
    flex-shrink: 0;
}

#pres-opps-left {
    order: 1;
    justify-content: flex-end;
    padding-right: 30px;
}

#pres-opps-right {
    order: 3;
    justify-content: flex-start;
    padding-left: 30px;
}

.pres-opp-hand {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 10px;
    gap: 20px;
}

.visual-card-stack {
    position: relative;
    height: 40px;
    margin-bottom: 5px;
}

.visual-card-stack .playing-mini-card.back-style {
    position: absolute;
    top: 0;
    width: 25px;
    height: 35px;
    border: 1px solid rgba(0,0,0,0.3);
    box-shadow: 1px 0 3px rgba(0,0,0,0.2);
}

.card-count-badge {
    background: #ffd700;
    color: #000;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: bold;
}

.pres-penalty-score {
    color: #eee;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
}

.my-pres-area {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 22px;
    margin: 0 auto;
    z-index: 10;
    min-width: 320px;
    min-height: 190px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    order: 2; 
}

.my-pres-area .playing-card.selected {
    transform: translateY(-20px);
    border: 2px solid var(--accent);
    box-shadow: 0 0 20px var(--accent);
}

.pres-score {
    padding: 5px 15px;
    border-radius: 20px;
    border: 1px solid #ffd700;
    color: #ffd700;
    font-size: 14px;
    font-weight: bold;
    text-align: center;
}

.pres-btn-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
    margin-top: 10px;
}

.pres-hand {
    display: flex;
    flex-direction: row;
    gap: 8px;
}

.big2-leaderboard {
    width: 100%;
    margin-top: 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 10px;
}

.leaderboard-header {
    font-size: 10px;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 10px;
    text-transform: uppercase;
}

.result-row {
    display: flex;
    align-items: center;
    padding: 10px;
    margin-bottom: 5px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border-left: 3px solid transparent;
}

.result-row.winner-row {
    background: rgba(0, 255, 136, 0.1);
    border-left-color: #00ff88;
}

.result-row .rank { width: 30px; font-weight: 900; opacity: 0.5; font-size: 12px; }
.result-row .name { flex: 1; text-align: left; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.result-row .score { display: flex; align-items: center; gap: 8px; font-size: 18px; color: var(--accent); font-weight: bold; }

/* ===== GAME MAHJONG ===== */
#mahjong-table {
    display: none;
    grid-template-areas: 
        "top-corner    top       top-corner-2"
        "left         center     right"
        "bot-corner    bottom    bot-corner-2";
    grid-template-columns: 100px 1fr 100px;
    grid-template-rows: 100px 1fr 150px;
    background: radial-gradient(circle, #1a4a3a 0%, #051a14 100%);
    aspect-ratio: 1 / 1 !important;
    width: 95%;
    max-width: 800px;
    margin: 20px auto;
    padding: 10px;
    align-self: center;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--glass-border);
    border-radius: 20px;
}

.mj-center {
    grid-area: center;
    background: rgba(0,0,0,0.2);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 15px;
}

.mj-discard-pit {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
}

#mj-status-msg {
    font-family: "Microsoft JhengHei", "Heiti TC", sans-serif;
    color: var(--accent);
    font-weight: 900;
    letter-spacing: 4px;
    text-shadow: 0 0 10px rgba(0, 242, 255, 0.5);
    background: rgba(0, 0, 0, 0.3);
    padding: 4px 12px;
    border-radius: 4px;
    border-left: 2px solid var(--accent);
}

.mj-tile {
    width: 30px;
    height: 42px;
    background: linear-gradient(to bottom, #fdfaf0 0%, #e5e0d0 100%);
    border-radius: 4px;
    border-bottom: 4px solid #1a5a4a;
    padding-bottom: 4px;
    text-shadow: 1px 1px 0px rgba(255,255,255,0.5), -1px -1px 1px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    overflow: visible; 
    line-height: 1;
    text-align: center;
    color: #1a5a4a;
    cursor: pointer;
    box-shadow: 2px 3px 5px rgba(0,0,0,0.4);
    transition: transform 0.2s;
    user-select: none;
    flex-shrink: 0;
}

.mj-tile span {
    transform: scale(1.3);
    display: block;
}

.mj-tile.bamboo { color: #289d4d !important; }
.mj-tile.dots { color: #2954cd !important; }
.mj-tile.chars { color: #c31919 !important; }
.mj-tile.winds { color: #0d1e4b !important; }
.mj-tile.dragon { color: #1a5a4a; }
.mj-tile.chong { color: #8d0808 !important; }
.mj-tile.unique { color: #b45309 !important; }

.mj-tile:hover { transform: translateY(-5px); }
.mj-tile.selected { 
    transform: translateY(-20px); 
    border-color: var(--accent); 
    box-shadow: 0 0 15px var(--accent);
}

.mj-opp-side {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.mj-opp-side.top { 
    grid-area: top; 
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    margin-top: 15px;
}

.mj-opp-side.left { 
    grid-area: left; 
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transform: rotate(90deg);
}

.mj-opp-side.right { 
    grid-area: right; 
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transform: rotate(-90deg);
}

.mj-player-row.bottom { 
    grid-area: bottom; 
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.mj-opp-row {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 30px;
}

.mj-opp-info {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 8px;
    line-height: 1;
}

.left .mj-hand, .right .mj-hand {
    flex-direction: column;
    height: auto;
}

.bottom .mj-tile {
    width: 36px;
    height: 50px;
    font-size: 24px;
}

.mj-opp-side.left .mj-hand, 
.mj-opp-side.right .mj-hand {
    flex-direction: row; 
    max-width: 250px;
}
.mj-opp-side.top .mj-hand {
    flex-direction: row-reverse;
}

.mj-opp-side.left .mj-tile, 
.mj-opp-side.right .mj-tile {
    width: 28px;
    height: 40px;
    font-size: 18px;
}

.mj-opp-name {
    white-space: nowrap;
    color: var(--accent);
    font-weight: bold;
    text-shadow: 0 0 5px rgba(0,0,0,0.5);
    font-size: 12px;
}

.mj-hand {
    display: flex;
    gap: 2px;
    justify-content: center;
    white-space: nowrap;
    flex-wrap: nowrap !important;
}

.mj-tile.sideways {
    width: 50px;
    height: 35px;
    border-bottom: 0;
    border-right: 4px solid #1a5a4a;
}

.mj-tile.back-style {
    background: #1a5a4a;
    border-bottom: 2px solid #0e3027;
    color: transparent;
}

.mj-tile.discarded {
    width: 24px;
    height: 32px;
    font-size: 18px;
    border-bottom: 2px solid #1a5a4a;
}

.mj-revealed-row {
    display: flex;
    gap: 8px;
}

.mj-meld-group {
    display: flex;
    gap: 2px;
    padding: 4px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.mj-meld-group .mj-tile {
    width: 24px;
    height: 32px;
    font-size: 18px;
    border-bottom: 2px solid #1a5a4a;
}

.mj-opp-side .mj-meld-group .mj-tile {
    width: 20px;
    height: 28px;
    font-size: 14px;
}

.mj-wall-container {
    position: relative;
    width: 90%;
    height: 90%;
    display: grid;
    grid-template-areas: 
        "w-top w-top w-top"
        "w-left pit w-right"
        "w-bot w-bot w-bot";
    grid-template-columns: 40px 1fr 40px;
    grid-template-rows: 40px 1fr 40px;
}

.mj-inner-pit {
    grid-area: pit;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 15px;
    box-sizing: border-box;
    position: relative;
}

.wall-label {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    font-weight: bold;
    font-size: medium;
    letter-spacing: 1px;
    opacity: 0.8;
}

.mj-wall-side { display: flex; gap: 2px; justify-content: center; align-items: center; }
.mj-wall-side.top { grid-area: w-top; flex-direction: row; }
.mj-wall-side.bottom { grid-area: w-bot; flex-direction: row; }
.mj-wall-side.left { grid-area: w-left; flex-direction: column; }
.mj-wall-side.right { grid-area: w-right; flex-direction: column; }
.mj-wall-side.bottom, .mj-wall-side.top { width: 100%; gap: 1px; }
.mj-wall-side.left, .mj-wall-side.right { height: 100%; gap: 1px; }

.mj-wall-brick {
    width: 20px;
    height: 26px;
    background: #fdfaf0;
    border: 1px solid #ccc;
    border-bottom: 6px solid #1a5a4a; 
    border-right: 2px solid #144438;
    position: relative;
    border-radius: 2px;
    flex-shrink: 0;
    margin: 0;
}

.mj-wall-brick::after {
    content: '';
    position: absolute;
    top: 48%;
    left: 0;
    width: 100%;
    height: 1px;
    background: rgba(0,0,0,0.2);
    box-shadow: 0 1px 0 rgba(255,255,255,0.5);
}

.mj-wall-brick.highlight-draw {
    background: #fff;
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent), 0 5px 0 #1a5a4a;
    transform: translateY(-5px);
    z-index: 50;
    cursor: pointer;
}

.mj-wall-brick.highlight-draw::after {
    background: rgba(255,255,255,0.5);
}

.left .mj-wall-brick, .right .mj-wall-brick {
    width: 26px;
    height: 20px;
    border-bottom: 2px solid #ccc;
    border-right: 6px solid #1a5a4a;
}
.left .mj-wall-brick::after, .right .mj-wall-brick::after {
    top: 0; left: 48%; width: 1px; height: 100%;
}

.mj-controls {
    display: flex;
    flex-direction: row;
    gap: 10px;
    margin-top: 10px;
}

.mj-selection-overlay {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(10, 12, 20, 0.95);
    border: 1px solid var(--accent);
    border-radius: 15px;
    padding: 15px;
    z-index: 500;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.overlay-header {
    font-size: 10px;
    letter-spacing: 2px;
    color: var(--accent);
    font-weight: bold;
}

.options-scroll {
    display: flex;
    gap: 12px;
}

.chow-option-group {
    display: flex;
    gap: 2px;
    cursor: pointer;
    padding: 8px;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    transition: background 0.2s;
}

.chow-option-group:hover {
    background: rgba(0, 242, 255, 0.2);
}

.chow-option-group .mj-tile {
    width: 26px;
    height: 36px;
    font-size: 18px;
    pointer-events: none;
}

.mj-discard-pit .mj-tile:last-child {
    position: relative;
    border-color: #00ff51 !important;
    box-shadow: 0 0 5px #00ff51;
    z-index: 10;
}

.mj-discard-pit .mj-tile:last-child::after {
    content: '▼';
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: #00ff51;
    text-shadow: 0 0 5px black;
}

.mj-mobile-opp-row {
    display: none;
}

.mj-wind-badge {
    background: var(--panel);
    color: var(--accent);
    font-size: 10px;
    font-weight: 900;
    padding: 3px 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    flex-shrink: 0;
    border: 1px solid var(--glass-border);
}

.win-stats {
    display: flex;
    justify-content: center;
    align-items: baseline;
    gap: 10px;
    width: 100%;
}

.win-pattern {
    font-size: 18px;
    font-weight: bold;
    color: #fff;
    padding: 0 15px;
}

.win-fan {
    color: var(--accent);
    font-weight: 900;
    text-shadow: 0 0 10px var(--accent);
}

.result-tiles-container {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    padding: 10px;
    border-radius: 8px;
    overflow-x: scroll;
}

.result-tiles-container::-webkit-scrollbar {
    display: none;
}

.result-meld-row, .result-hand-row {
    display: flex;
    justify-content: center;
    gap: 4px;
}

.result-tiles-container .mj-tile {
    width: 20px !important;
    height: 28px !important;
    font-size: 14px !important;
    border-bottom: 2px solid #1a5a4a !important;
    cursor: default;
}

.mj-meld-group.mini {
    padding: 2px;
    background: rgba(0, 242, 255, 0.1);
    border-radius: 4px;
}

.mj-announcement-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid var(--accent);
    padding: 20px 40px;
    z-index: 2000;
    min-width: 300px;
    text-align: center;
    pointer-events: none;
    clip-path: polygon(10% 0, 100% 0, 90% 100%, 0 100%);
    animation: popupIn 0.5s forwards cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.ann-top { font-size: 10px; color: var(--accent); letter-spacing: 4px; }
.ann-mid { font-size: 32px; font-weight: 900; color: #fff; margin: 10px 0; }
.ann-bot { font-size: 12px; color: #ff4655; font-weight: bold; }

.mj-deal-target {
    position: absolute;
    width: 100px;
    height: 40px;
    pointer-events: none;
    z-index: 5;
}
.target-bottom { bottom: 80px; left: 50%; transform: translateX(-50%); }
.target-top    { top: 80px; left: 50%; transform: translateX(-50%); }
.target-left   { left: 80px; top: 50%; transform: translateY(-50%) rotate(90deg); }
.target-right  { right: 80px; top: 50%; transform: translateY(-50%) rotate(-90deg); }

.flying-tile {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 5000;
    opacity: 1 !important;
    transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.6s ease;
    transform: translate(-50%, -50%) scale(0.3);
    box-shadow: 0 0 15px var(--accent);
    pointer-events: none;
}
.flying-tile.animate {
    opacity: 0.8;
}
.to-bottom.animate { transform: translate(-50%, 300px) scale(1); }
.to-top.animate    { transform: translate(-50%, -300px) scale(1) rotate(180deg); }
.to-left.animate   { transform: translate(-300px, -50%) scale(1) rotate(90deg); }
.to-right.animate  { transform: translate(300px, -50%) scale(1) rotate(-90deg); }

.mj-ghost-hand {
    position: absolute;
    width: 1px;
    height: 1px;
    pointer-events: none;
    z-index: 100;
}
.ghost-tile {
    position: absolute;
    width: 20px;
    height: 28px;
    background-size: cover;
    transition: opacity 0.2s;
    top: 0; 
}
.ghost-bottom { bottom: 100px; left: 50%; }
.ghost-top    { top: 50px; left: 50%; transform: rotate(180deg); }
.ghost-left   { left: 60px; top: 50%; transform: rotate(90deg); }
.ghost-right  { right: 60px; top: 50%; transform: rotate(-90deg); }

@keyframes popupIn {
    to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

@media (max-width: 850px) {
    .container { display: block !important; }

    .arena-header .accent-text {
        font-size: 25px;
    }

    .responsive-text {
        display: none !important;
    }

    .main-view-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .header-actions-right {
        width: 100%;
        justify-content: flex-start;
        gap: 8px;
    }

    .chat-content-area {
        position: fixed;
        top: 0;
        right: -100%;
        width: 85% !important;
        height: 100vh;
        max-width: 100% !important;
        margin-left: 0 !important;
        z-index: 100000;
        background: rgba(10, 12, 20, 0.98);
        box-shadow: -10px 0 30px rgba(0, 0, 0, 0.8);
        transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        visibility: visible;
        opacity: 1;
        display: flex !important;
        border-radius: 20px 0 0 20px;
    }
    .chat-content-area.active { right: 0 !important; }

    .chat-blur-overlay.active {
        opacity: 1;
        visibility: visible;
        backdrop-filter: blur(8px);
        pointer-events: auto;
    }

    .chat-drawer {
        width: 100% !important; 
        border-radius: 0;
        border-left: 1px solid var(--glass-border);
    }

    #chat-frame {
        height: calc(100% + 65px);
        margin-top: -65px;
    }

    .arena-lobby {
        display: flex;
        grid-template-columns: none;
        flex-direction: column;
        width: 100%;
        margin: 0;
        padding: 0;
    }

    .panel-header.code {
        margin: auto;
    }

    .header-actions-right {
        position: static;
        width: auto;
        justify-content: center;
        gap: 8px;
        margin-top: 5px;
        margin: auto;
    }

    .header-left {
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .main-view {
        width: 100% !important;
        flex: 1;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: -300px;
        width: 280px;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        padding: 20px 15px !important;
    }

    .sidebar.active {
        left: 0;
        padding-bottom: env(safe-area-inset-bottom);
    }

    .sidebar-header {
        padding: 0 10px 15px 10px !important;
        justify-content: space-between !important;
        width: 100%;
    }
    
    #lobby-sidebar { padding-bottom: 20px; }

    .mobile-sidebar-toggle {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .mobile-close-btn {
        display: block;
        background: transparent;
        border: none;
        color: white;
        font-size: 20px;
        margin-left: auto;
    }

    #chat-mobile-btn { display: flex ; z-index: 9999 !important; }
    #chat-desktop-btn { display: none; }

    .sidebar.active ~ .sidebar-overlay {
        opacity: 1;
        visibility: visible;
        backdrop-filter: blur(4px);
    }

    #shu-table {
        display: flex;
        flex-direction: column;
        overflow-y: auto;
    }

    .table-surface {
        position: relative;
        transform: none;
        top: 0;
        left: 0;
        margin: 40px auto;
        flex: none;
    }

    #blackjack-table, #poker-table, #big2-table {
        display: flex;
        flex-direction: column;
        justify-content: flex-start !important; 
        align-items: center;
        padding: 0;
    }

    .game-meta {
        position: relative;
        order: -5; 
        width: 100%;
        min-height: 60px;
        padding: 15px;
        background: rgba(0, 0, 0, 0.6);
        border-bottom: 1px solid var(--glass-border);
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: 15px !important;
        top: 0 !important;
        left: 0 !important;
    }

    #bj-turn-name,
    #current-turn-name,
    #pres-turn-name,
    #poker-turn-name {
        font-size: 1.2rem;
        margin: 0;
    }

    .meta-badge,
    .btn-skip {
        margin: 0;
    }

    .shu-opp-slot, .bj-opp-slot {
        position: relative !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        transform: none !important;
        min-width: 150px;
        scroll-snap-align: center;
        flex-shrink: 0;
    }

    .shu-opponents {
        position: relative;
        display: flex;
        flex-direction: row;
        justify-content: flex-start;
        align-items: center;
        overflow-x: auto;
        overflow-y: visible;
        width: 100%;
        height: auto;
        min-height: 140px;
        padding: 10px 20px;
        gap: 20px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        scroll-snap-type: x mandatory;
        scrollbar-width: none;
    }

    .shu-opponents::-webkit-scrollbar {
        display: none;
    }

    .bj-players-row {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: flex-start; 
        width: 100%;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        padding: 20px 40vw; 
        gap: 20px;
    }

    #bj-opponents-left, #bj-opponents-right {
        flex: none;
        width: auto;
        min-width: fit-content;
        justify-content: center;
        padding: 0;
        margin: 0;
    }

    .my-bj-area {
        scroll-snap-align: center;
        flex-shrink: 0;
        min-width: 280px;
        margin: 0;
    }

    .poker-players-row, .pres-players-row {
        justify-content: safe center;
        padding: 20px 40vw;
        scroll-snap-type: x mandatory;
    }

    .my-poker-seat, .opp-slot, .my-pres-area {
        scroll-snap-align: center;
    }

    #poker-opps-left, #poker-opps-right,  #pres-opps-left, #pres-opps-right {
        flex: none;
        padding: 0;
    }

    #mahjong-table {
        display: none;
        flex-direction: column !important;
        height: 100dvh !important;
        width: 100% !important;
        padding: 0 0 10px 0 !important;
        overflow: hidden;
        position: relative;
    }

    #mj-opp-top, #mj-opp-left, #mj-opp-right {
        display: inline-flex !important;
        position: static !important;
        width: auto !important;
        min-width: 200px !important;
        flex-shrink: 0 !important;
        height: 80px !important;
        margin: 0;
        padding-left: 15px;
        padding-right: 15px;
        padding-bottom: 6px;
        background: rgba(0, 0, 0, 0.4);
        border-right: 1px solid rgba(255,255,255,0.1);
        border-bottom: 1px solid rgba(255,255,255,0.1);
        align-items: center;
        justify-content: center;
        transform: none !important;
        overflow-y: hidden;
    }

    .mj-mobile-opp-row {
        display: flex !important;
        flex-direction: row !important;
        overflow-x: auto !important;
        overflow-y: hidden;
        width: 100% !important;
        -webkit-overflow-scrolling: touch;
    }

    .mj-mobile-opp-row::-webkit-scrollbar {
        display: none;
    }

    .mj-opp-info {
        display: flex !important;
        flex-direction: row !important;
        align-items: center;
        gap: 5px;
        flex-shrink: 0;
    }

    .mj-hand-count {
        margin-left: auto;
        background: rgba(0, 242, 255, 0.1);
        padding: 2px 8px;
        border-radius: 10px;
        font-size: 12px;
    }

    .mj-center {
        flex: 1 !important;
        display: flex !important;
        align-items: center;
        align-self: center;
        justify-content: center;
        width: 95% !important;
    }

   .mj-wall-container {
        position: relative;
        margin: 0 auto !important; 
        transform: scale(0.68);
        transform-origin: center center;
        width: 350px !important; 
        height: 350px !important;
        flex-shrink: 0;
    }

    .mj-player-row.bottom {
        margin-top: auto;
        width: 100% !important;
        z-index: 110;
    }

    .mj-revealed-row {
        width: 100%;
        overflow-x: auto;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        padding: 0 10px;
    }

    .mj-hand {
        display: flex !important;
        flex-direction: row !important;
        overflow-x: auto !important;
        margin-top: -30px !important;
        padding-top: 30px !important;
        padding-bottom: 10px !important;
        overflow-y: visible !important;
        align-items: flex-end !important;
        width: 100% !important;
        gap: 8px;
        -webkit-overflow-scrolling: touch;
    }

    .mj-hand::before,
    .mj-hand::after {
        content: '';
        flex: 0 0 25px;
        height: 1px;
    }

    .mj-hand::-webkit-scrollbar {
        display: none;
    }

    .mj-hand .mj-tile {
        flex: 0 0 auto !important; 
        width: 32px !important;
        height: 46px !important;
        position: relative;
        margin-top: 0 !important; 
    }

    .mj-hand .mj-tile.selected {
        transform: translateY(-20px) !important;
    }

    .mj-player-row.bottom {
        overflow: visible !important;
    }

    .mj-opp-side .mj-tile {
        width: 18px !important;
        height: 26px !important;
        font-size: 14px !important;
    }

    .mj-mobile-opp-row {
        display: flex !important;
        flex-direction: row !important;
        overflow-x: auto !important;
        width: 100% !important;
        height: 60px;
        background: rgba(0,0,0,0.5);
        border-bottom: 1px solid var(--accent);
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .mj-selection-overlay {
        bottom: 60px;
    }

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