html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100dvh;
    scrollbar-width: none;
    color: #fff;
    font-family: sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

header {
    height: 40px;
    display: flex;
    align-items: center;
}

header h1 {
    margin: 0;
    font-size: 18px;
    letter-spacing: 1px;
}

#stage-container {
    position: relative;
    width: 100vw;
    height: calc(100dvh - 45px);
    max-width: 1000px;
    max-height: 750px;
    background: #18151e;
    border: 2px solid #2a2438;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.9);
    overflow: hidden;
    touch-action: none;
}

#border-frame {
    position: absolute;
    top: 1.6%;
    left: 5%;
    width: 90%;
    height: 43.3%;
    background: #120e18;
    border: 3px solid #3c324d;
    box-shadow: inset 0 0 15px #000;
    z-index: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
}

#theatre-screen {
    width: 83.3%;
    height: 84.6%;
    background: #000;
    border: 4px solid #5c4b75;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.8);
    box-sizing: border-box;
}

#theatre-screen video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#stage-platform {
    position: absolute;
    top: 45.8%;
    left: 2.5%;
    width: 95%;
    height: 5.8%;
    background: linear-gradient(180deg, #4a3b32 0%, #2b211b 100%);
    border: 2px solid #6e574a;
    border-radius: 4px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    z-index: 2;
    box-sizing: border-box;
}

#pixi-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    z-index: 3;
    pointer-events: auto;
}

#pixi-canvas, #stage-container {
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

#chat-container {
    position: absolute;
    bottom: 10px;
    left: 10px;
    z-index: 4;
    width: 280px;
    max-width: 42vw;
    background: rgba(18, 14, 24, 0.88);
    border: 1px solid #3c324d;
    border-radius: 6px;
    padding: 8px;
    box-sizing: border-box;
}

#action-container {
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 4;
    width: 280px;
    max-width: 42vw;
    background: rgba(18, 14, 24, 0.88);
    border: 1px solid #3c324d;
    border-radius: 6px;
    padding: 8px;
    box-sizing: border-box;
}

#chat-wrapper {
    display: flex;
    flex-direction: column;
    margin-bottom: 6px;
    background: rgba(10, 8, 15, 0.6);
    border: 1px solid #3c324d;
    border-radius: 4px;
    overflow: hidden;
    transition: all 0.25s ease-in-out;
}

#chat-toggle-btn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    height: 16px;
    background: #2a2438;
    color: #9d8ec0;
    border: none;
    padding: 4px 8px;
    font-size: 10px;
    font-weight: bold;
    cursor: pointer;
    outline: none;
}

#chat-toggle-btn:hover {
    background: #352d47;
    color: #ffffff;
}

#chat-box {
    height: 90px;
    overflow-y: auto;
    font-size: 12px;
    padding: 4px 6px;
    box-sizing: border-box;
    transition: height 0.25s ease-in-out, opacity 0.2s ease-in-out;
    opacity: 1;
}

#chat-wrapper.collapsed #chat-box {
    height: 0px;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
    overflow: hidden;
}

#chat-wrapper.collapsed #chat-toggle-icon {
    transform: rotate(180deg);
}

#chat-input {
    width: 100%;
    padding: 5px;
    background: #0a080f;
    border: 1px solid #3c324d;
    border-radius: 4px;
    color: white;
    outline: none;
    margin-bottom: 6px;
    box-sizing: border-box;
}

.chat-entry {
    margin-bottom: 3px;
    line-height: 1.3;
}

.chat-timestamp {
    color: #716982;
    font-size: 10px;
    margin-right: 4px;
}

.chat-sender {
    color: #9d8ec0;
    font-weight: 600;
    margin-right: 4px;
}

.chat-sender-whisper {
    color: #d96b00;
    font-weight: 600;
    margin-right: 4px;
}

.chat-text {
    color: #e2e2e2;
}

.chat-text-whisper {
    color: #ff8c00;
}

#action-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

#action-bar label {
    font-size: 11px;
    align-self: center;
}

#action-bar select, #action-bar button {
    background: #2a2438;
    color: white;
    border: 1px solid #5c4b75;
    padding: 4px 6px;
    border-radius: 3px;
    font-size: 11px;
    cursor: pointer;
}

#action-bar button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#touch-dpad {
    position: absolute;
    bottom: 70px;
    left: 15px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

.dpad-row {
    display: flex;
    gap: 20px;
}

.dpad-btn {
    width: 36px;
    height: 36px;
    background: rgba(42, 36, 56, 0.85);
    color: #ffffff;
    border: 1px solid #5c4b75;
    border-radius: 6px;
    font-size: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    touch-action: none;
}

.dpad-btn:active {
    background: #5c4b75;
}

#theatre-video {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform;
}

#start-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    color: #ffffff;
}

#start-overlay h2 {
    margin-bottom: 15px;
    font-family: inherit;
}

.start-btn {
    padding: 15px 30px;
    font-size: 18px;
    font-weight: bold;
    background-color: #e74c3c;
    color: #ffffff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.start-btn:hover {
    background-color: #c0392b;
}

.start-btn:active {
    transform: scale(0.98);
}

.center-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80dvh;
}

.card-container {
    width: 100%;
    max-width: 360px;
    padding: 24px;
    background: #18151e;
    border: 2px solid #3c324d;
    border-radius: 8px;
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.7);
    box-sizing: border-box;
}

.text-center {
    text-align: center;
}

.login-header h2, .creator-header h2 {
    font-size: 20px;
    margin: 0 0 6px 0;
    color: #ffffff;
}

.login-header p, .creator-header p {
    font-size: 12px;
    color: #9d8ec0;
    margin-bottom: 18px;
}

fieldset {
    border: 1px solid #ffffff;
    border-radius: 4px;
    padding: 12px 16px;
    margin-bottom: 16px;
    background: #0d0d1150;
    box-sizing: border-box;
}

legend {
    font-size: 1.1rem;
    font-weight: bold;
    color: #ffffff;
    padding: 0 6px;
}

.color-section {
    margin-bottom: 16px;
}

.field-group {
    margin-bottom: 12px;
}

.field-group:last-child {
    margin-bottom: 0;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label,
.field-group label,
.color-section label {
    display: block;
    font-size: 12px;
    color: #9d8ec0;
    margin: 5px auto;
}

.form-group input,
fieldset select,
fieldset input[type="range"] {
    width: 100%;
    padding: 6px 8px;
    background: #ffffff;
    border: 1px solid #ccc;
    border-radius: 2px;
    color: #000000;
    font-size: 14px;
    outline: none;
    box-sizing: border-box;
}

fieldset select {
    height: 28px;
}

fieldset input[type="range"] {
    appearance: auto;
    padding: 0;
    height: 18px;
    cursor: pointer;
}

.form-group input:focus {
    border-color: #5c4b75;
}

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 18px;
}

.btn-primary, .btn-secondary {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary {
    background: #5c4b75;
    color: #ffffff;
}

.btn-primary:hover {
    background: #6e574a;
}

.btn-secondary {
    background: #2a2438;
    color: #9d8ec0;
    border: 1px solid #3c324d;
}

.btn-secondary:hover {
    background: #352d47;
    color: #ffffff;
}

.link-btn {
    display: inline-block;
    text-decoration: none;
    margin-top: 15px;
}

.palette-container, 
.color-palette, 
.color-swatch-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
    margin-bottom: 8px;
}

.swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    outline: none;
    box-sizing: border-box;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.swatch:hover {
    transform: scale(1.1);
}

.swatch.selected {
    border-color: #ffffff;
    box-shadow: 0 0 0 2px #5c4b75, 0 0 8px rgba(255, 255, 255, 0.6);
    transform: scale(1.15);
}

#enter-theatre-btn {
    width: auto;
    padding: 6px 14px;
    font-size: 0.95rem;
    background-color: #ffffff;
    color: #000000;
    border: 1px solid #767676;
    border-radius: 2px;
    cursor: pointer;
    margin-top: 8px;
}

#enter-theatre-btn:hover {
    background-color: #e5e5e5;
}

.error-banner {
    background: rgba(217, 83, 79, 0.2);
    border: 1px solid #d9534f;
    color: #ff6b6b;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    margin-bottom: 14px;
    text-align: center;
}

.hidden {
    display: none;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

.shake {
    animation: shake 0.4s ease-in-out;
}

@media (pointer: fine) {
    #touch-dpad {
        display: none;
    }
}

.avatar-creator-h2 {
    margin-top: 40dvh;
}

@media screen and (max-width: 768px) {
    .avatar-creator-h2 {
        margin-top: 70dvh;
    }
}
