/* ============ SPLASH OVERLAY ============ */
#splash-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: auto;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.8s ease-out;
}

#splash-overlay.fade-out {
    opacity: 0;
}

#splash-overlay.hidden {
    display: none;
}

#splash-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#splash-logo {
    position: relative;
    z-index: 1;
    max-width: 80%;
    max-height: 70%;
    object-fit: contain;
    animation: splash-logo-pulse 2s ease-in-out infinite;
}

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

/* ============ SPLASH LOADING UI ============ */
#splash-loading-container {
    position: relative;
    z-index: 1;
    margin-top: 30px;
    width: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

#splash-loading-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.85);
    text-align: center;
    min-height: 20px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#splash-loading-bar-bg {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

#splash-loading-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #4a7c4e 0%, #6bb870 50%, #4a7c4e 100%);
    background-size: 200% 100%;
    border-radius: 4px;
    transition: width 0.15s ease-out;
    animation: loading-bar-shimmer 1.5s ease-in-out infinite;
}

@keyframes loading-bar-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

#splash-loading-container.hidden {
    display: none;
}

#splash-new-game-btn {
    position: relative;
    z-index: 1;
    margin-top: 20px;
    padding: 16px 48px;
    font-family: 'Caveat', cursive;
    font-size: 28px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #4a7c4e 0%, #2d5a30 100%);
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    cursor: pointer;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out, background 0.2s ease, box-shadow 0.2s ease;
    pointer-events: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

#splash-new-game-btn.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

#splash-new-game-btn:hover {
    background: linear-gradient(135deg, #5d8a5e 0%, #3a6b3d 100%);
    box-shadow: 0 6px 30px rgba(74, 124, 78, 0.4);
    transform: translateY(-2px);
}

#splash-new-game-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.3);
}

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

body {
    overflow: hidden;
    background: #f5f0e6;
    font-family: 'Caveat', cursive, 'JetBrains Mono', monospace;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

#scene-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    /* Paper texture overlay */
    background-image: 
        url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.08'/%3E%3C/svg%3E");
}

#scene-container:active {
    cursor: grabbing;
}

/* Prevent text selection on double-click */
#scene-container {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

#debug-nav {
    margin-top: 4px;
    font-size: 11px;
}

#debug-steps {
    margin-top: 4px;
    font-size: 11px;
    font-weight: bold;
}

#debug-overlay {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    background: rgba(245, 240, 230, 0.92);
    border: 2px solid #1a1a1a;
    border-radius: 2px;
    padding: 12px 16px;
    color: #1a1a1a;
    font-size: 12px;
    line-height: 1.6;
    z-index: 100;
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.15);
    /* Ink splatter effect */
    background-image: 
        url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='85' cy='12' r='3' fill='%231a1a1a' opacity='0.1'/%3E%3Ccircle cx='88' cy='15' r='1.5' fill='%231a1a1a' opacity='0.08'/%3E%3C/svg%3E");
}

.debug-title {
    font-size: 16px;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 8px;
    letter-spacing: 1px;
    font-family: 'Caveat', cursive;
    font-size: 20px;
}

.debug-hint {
    margin-top: 10px;
    font-size: 10px;
    color: #4a4a4a;
    border-top: 1px dashed #1a1a1a;
    padding-top: 8px;
    font-style: italic;
}

.remix-link {
    display: block;
    margin-top: 8px;
    font-size: 10px;
    color: #1a1a1a;
    text-decoration: none;
    opacity: 0.7;
    transition: opacity 0.2s;
    font-style: italic;
}

.remix-link:hover {
    opacity: 1;
    text-decoration: underline;
}

#switch-character-btn {
    position: fixed;
    bottom: 30px;
    left: 30px;
    width: 60px;
    height: 60px;
    background: rgba(245, 240, 230, 0.92);
    border: 3px solid #1a1a1a;
    border-radius: 50%;
    font-size: 32px;
    font-weight: bold;
    color: #1a1a1a;
    cursor: pointer;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.2);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    user-select: none;
    -webkit-user-select: none;
    font-family: 'Caveat', cursive;
}

#switch-character-btn:hover {
    background: rgba(51, 153, 255, 0.2);
    transform: scale(1.05);
}

#switch-character-btn:active {
    transform: scale(0.95) translateY(2px);
    box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.2);
}

#switch-character-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

#turn-mode-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 100;
}

.turn-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-family: 'Caveat', cursive;
    font-size: 16px;
    color: #1a1a1a;
    background: rgba(245, 240, 230, 0.92);
    padding: 8px 14px;
    border: 2px solid #1a1a1a;
    border-radius: 20px;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.15);
    user-select: none;
    -webkit-user-select: none;
}

.turn-toggle input {
    display: none;
}

.toggle-slider {
    width: 40px;
    height: 22px;
    background: #ccc;
    border-radius: 11px;
    position: relative;
    transition: background 0.2s ease;
    border: 1px solid #1a1a1a;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.2s ease;
    border: 1px solid #1a1a1a;
}

.turn-toggle input:checked + .toggle-slider {
    background: #3399ff;
}

.turn-toggle input:checked + .toggle-slider::after {
    transform: translateX(18px);
}

.toggle-label {
    font-weight: 700;
}

/* Game Header */
#game-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: rgba(245, 240, 230, 0.95);
    border-bottom: 3px solid #1a1a1a;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#mp-btn {
    display: none;
    position: absolute;
    left: 180px;
    width: 44px;
    height: 44px;
    background: rgba(245, 240, 230, 0.92);
    border: 2px solid #1a1a1a;
    border-radius: 8px;
    font-size: 22px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 2px 3px 0 rgba(0, 0, 0, 0.2);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    user-select: none;
    -webkit-user-select: none;
    z-index: 10;
}

#mp-btn:hover {
    background: rgba(51, 153, 255, 0.2);
    transform: scale(1.05);
}

#mp-btn:active {
    transform: scale(0.95);
    box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.15);
}

#mp-btn.active {
    background: rgba(51, 153, 255, 0.4);
    border-color: #3399ff;
}

#mp-status {
    display: none;
    position: absolute;
    left: 234px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: #666;
    white-space: nowrap;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
}

#menu-btn {
    position: absolute;
    left: 16px;
    width: 44px;
    height: 44px;
    background: rgba(245, 240, 230, 0.92);
    border: 2px solid #1a1a1a;
    border-radius: 8px;
    font-size: 24px;
    font-weight: bold;
    color: #1a1a1a;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.15);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    user-select: none;
    -webkit-user-select: none;
}

#menu-btn:hover {
    background: rgba(51, 153, 255, 0.2);
    transform: scale(1.05);
}

#menu-btn:active {
    transform: scale(0.95);
    box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.15);
}

#fullscreen-btn {
    position: absolute;
    left: 68px;
    width: 44px;
    height: 44px;
    background: rgba(245, 240, 230, 0.92);
    border: 2px solid #1a1a1a;
    border-radius: 8px;
    font-size: 24px;
    font-weight: bold;
    color: #1a1a1a;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.15);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    user-select: none;
    -webkit-user-select: none;
}

#fullscreen-btn:hover {
    background: rgba(51, 153, 255, 0.2);
    transform: scale(1.05);
}

#fullscreen-btn:active {
    transform: scale(0.95);
    box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.15);
}

#level-display {
    font-family: 'Caveat', cursive;
    font-size: 28px;
    font-weight: 700;
    color: #1a1a1a;
}

#context-menu {
    position: absolute;
    top: 54px;
    left: 16px;
    background: rgba(245, 240, 230, 0.98);
    border: 2px solid #1a1a1a;
    border-radius: 8px;
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.2);
    overflow: hidden;
    z-index: 101;
}

#context-menu.hidden {
    display: none;
}

.menu-item {
    display: block;
    width: 100%;
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(26, 26, 26, 0.2);
    font-family: 'Caveat', cursive;
    font-size: 18px;
    font-weight: 700;
    color: #1a1a1a;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease;
}

.menu-item:last-child {
    border-bottom: none;
}

.menu-item:hover {
    background: rgba(51, 153, 255, 0.2);
}

/* Custom Level Dialog */
#custom-level-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

#custom-level-dialog.hidden {
    display: none;
}

.custom-level-content {
    background: rgba(245, 240, 230, 0.98);
    border: 3px solid #1a1a1a;
    border-radius: 12px;
    padding: 24px 32px;
    box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.25);
    text-align: center;
    min-width: 280px;
}

.custom-level-content h2 {
    font-family: 'Caveat', cursive;
    font-size: 32px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 20px 0;
}

.custom-level-inputs {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
}

.dimension-input {
    width: 60px;
    height: 48px;
    border: 2px solid #1a1a1a;
    border-radius: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    background: rgba(255, 255, 255, 0.9);
    color: #1a1a1a;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.dimension-input:focus {
    border-color: #3399ff;
    box-shadow: 0 0 0 3px rgba(51, 153, 255, 0.3);
}

.dimension-input::-webkit-inner-spin-button,
.dimension-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.dimension-input[type=number] {
    -moz-appearance: textfield;
}

.dimension-separator {
    font-family: 'JetBrains Mono', monospace;
    font-size: 24px;
    font-weight: 700;
    color: #1a1a1a;
}

.custom-level-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.custom-btn {
    padding: 12px 28px;
    border: 2px solid #1a1a1a;
    border-radius: 8px;
    font-family: 'Caveat', cursive;
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.2);
}

.custom-btn:hover {
    transform: translateY(-2px);
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.25);
}

.custom-btn:active {
    transform: translateY(1px);
    box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.15);
}

.start-btn {
    background: rgba(51, 153, 255, 0.3);
    color: #1a1a1a;
}

.start-btn:hover {
    background: rgba(51, 153, 255, 0.5);
}

.cancel-btn {
    background: rgba(245, 240, 230, 0.9);
    color: #1a1a1a;
}

.cancel-btn:hover {
    background: rgba(200, 195, 185, 0.9);
}

#end-turn-btn {
    position: absolute;
    right: 16px;
    padding: 10px 20px;
    background: rgba(51, 153, 255, 0.15);
    border: 2px solid #1a1a1a;
    border-radius: 6px;
    font-family: 'Caveat', cursive;
    font-size: 20px;
    font-weight: 700;
    color: #1a1a1a;
    cursor: pointer;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.15);
    transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.15s ease;
    user-select: none;
    -webkit-user-select: none;
}

#end-turn-btn:hover {
    background: rgba(51, 153, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 3px 4px 0 rgba(0, 0, 0, 0.2);
}

#end-turn-btn:active {
    transform: translateY(1px);
    box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.15);
}

#end-turn-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Unit Footer */
#unit-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 110px;
    background: rgba(235, 230, 220, 0.95);
    border-top: 3px solid #1a1a1a;
    z-index: 90;
    overflow: hidden;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: row;
    align-items: stretch;
}

#resources-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 700;
    border-radius: 6px;
    padding: 4px 6px;
    margin: 10px 0 10px 8px;
    min-width: auto;
    flex-shrink: 0;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.15);
    color: #1a1a1a;
    background: rgba(245, 240, 230, 0.9);
    border: 2px solid #1a1a1a;
    margin-left: 8px;
    line-height: 1.2;
}

#resources-display .resource-line {
    white-space: nowrap;
}

/* Book inventory chips container */
#book-inventory {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    padding: 4px 8px;
    margin: 10px 0;
    flex-shrink: 0;
}

/* Individual book chip */
.book-chip {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    min-width: 36px;
    height: 36px;
    padding: 4px 8px;
    background: rgba(245, 240, 230, 0.9);
    border: 2px solid #1a1a1a;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
    user-select: none;
    -webkit-user-select: none;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.15);
    position: relative;
}

.book-chip:hover {
    transform: scale(1.08);
    background: rgba(255, 230, 150, 0.95);
}

.book-chip.selected {
    background: rgba(255, 200, 80, 0.95);
    border-color: #ff8800;
    box-shadow: 0 0 8px rgba(255, 136, 0, 0.6), 2px 2px 0 rgba(0, 0, 0, 0.15);
    transform: scale(1.05);
}

.book-chip.selected:hover {
    background: rgba(255, 180, 50, 0.95);
}

.book-chip-count {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 700;
    color: #1a1a1a;
    margin-left: 2px;
}

#multi-select-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Caveat', cursive;
    font-size: 18px;
    font-weight: 700;
    border-radius: 8px;
    padding: 6px 12px;
    min-width: auto;
    flex-shrink: 0;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.15);
    color: #1a1a1a;
    background: rgba(245, 240, 230, 0.92);
    border: 2px solid #1a1a1a;
    margin-right: 12px;
    margin-left: 6px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    user-select: none;
    -webkit-user-select: none;
}

#multi-select-btn:hover {
    background: rgba(51, 153, 255, 0.15);
    transform: scale(1.05);
}

#multi-select-btn.active {
    background: rgba(51, 153, 255, 0.15);
    color: #2266cc;
    border-color: #2266cc;
    box-shadow: inset 2px 2px 4px rgba(0, 0, 0, 0.15);
    transform: scale(0.98);
}

#multi-select-btn.active:hover {
    background: rgba(51, 153, 255, 0.25);
}

#unit-cards-container {
    display: flex;
    gap: 12px;
    padding: 10px 16px;
    overflow-x: auto;
    overflow-y: hidden;
    height: 100%;
    align-items: flex-end;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    min-width: 0;
}

#unit-cards-container::-webkit-scrollbar {
    height: 6px;
}

#unit-cards-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

#unit-cards-container::-webkit-scrollbar-thumb {
    background: rgba(51, 153, 255, 0.6);
    border-radius: 3px;
}

#unit-cards-container::-webkit-scrollbar-thumb:hover {
    background: rgba(51, 153, 255, 0.8);
}

.unit-card {
    flex-shrink: 0;
    width: 80px;
    height: 85px;
    background: linear-gradient(135deg, #6db3f2 0%, #4a9de0 100%);
    border: 2px solid #1a1a1a;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 6px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, margin-bottom 0.2s ease;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.2);
    position: relative;
    user-select: none;
    -webkit-user-select: none;
}

.unit-card:hover {
    transform: scale(1.05);
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.25);
}

.unit-card.selected {
    margin-bottom: 15px;
    border-color: #ffd700;
    border-width: 3px;
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.6), 3px 3px 0 rgba(0, 0, 0, 0.2);
    animation: selectedPulse 1.5s ease-in-out infinite;
}

@keyframes selectedPulse {
    0%, 100% { box-shadow: 0 0 12px rgba(255, 215, 0, 0.6), 3px 3px 0 rgba(0, 0, 0, 0.2); }
    50% { box-shadow: 0 0 20px rgba(255, 215, 0, 0.9), 3px 3px 0 rgba(0, 0, 0, 0.2); }
}

.unit-card.selected::before {
    content: '';
    position: absolute;
    top: -4px;
    right: -4px;
    width: 12px;
    height: 12px;
    background: #ffd700;
    border-radius: 50%;
    border: 2px solid #1a1a1a;
}

.unit-card-image {
    width: 48px;
    height: 48px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    image-rendering: pixelated;
    margin-bottom: 4px;
}

.unit-card-name {
    font-family: 'Caveat', cursive;
    font-size: 11px;
    font-weight: 700;
    color: #1a1a1a;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    line-height: 1.1;
}

.unit-card-hp {
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 4px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 2px;
    overflow: hidden;
}

.unit-card-hp-fill {
    height: 100%;
    background: linear-gradient(90deg, #4ade80, #22c55e);
    transition: width 0.3s ease;
}

.unit-card-hp-fill.low {
    background: linear-gradient(90deg, #f87171, #ef4444);
}

.unit-card-hp-fill.medium {
    background: linear-gradient(90deg, #fbbf24, #f59e0b);
}

/* ===============================================
   LANDSCAPE MODE LAYOUT
   - Header hidden, sidebar on right with inventory
   - Floating menu button top-left
   - End Turn at top of sidebar
   =============================================== */
@media (orientation: landscape) {
    /* Hide the header entirely in landscape */
    #game-header {
        display: none !important;
    }
    
    /* Floating menu button - top left of game view */
    #menu-btn-floating {
        display: flex !important;
        position: fixed;
        top: 12px;
        left: 12px;
        width: 44px;
        height: 44px;
        background: rgba(245, 240, 230, 0.92);
        border: 2px solid #1a1a1a;
        border-radius: 8px;
        font-size: 22px;
        cursor: pointer;
        align-items: center;
        justify-content: center;
        box-shadow: 2px 3px 0 rgba(0, 0, 0, 0.2);
        transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
        user-select: none;
        -webkit-user-select: none;
        z-index: 150;
    }
    
    #menu-btn-floating:hover {
        background: rgba(51, 153, 255, 0.2);
        transform: scale(1.05);
    }
    
    #menu-btn-floating:active {
        transform: scale(0.95);
        box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.15);
    }
    
    /* Floating fullscreen button - next to menu button in landscape */
    #fullscreen-btn-floating {
        display: flex !important;
        position: fixed;
        top: 12px;
        left: 64px;
        width: 44px;
        height: 44px;
        background: rgba(245, 240, 230, 0.92);
        border: 2px solid #1a1a1a;
        border-radius: 8px;
        font-size: 22px;
        cursor: pointer;
        align-items: center;
        justify-content: center;
        box-shadow: 2px 3px 0 rgba(0, 0, 0, 0.2);
        transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
        user-select: none;
        -webkit-user-select: none;
        z-index: 150;
    }
    
    #fullscreen-btn-floating:hover {
        background: rgba(51, 153, 255, 0.2);
        transform: scale(1.05);
    }
    
    #fullscreen-btn-floating:active {
        transform: scale(0.95);
        box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.15);
    }
    
    /* Context menu repositioned for floating button */
    #context-menu.landscape-menu {
        position: fixed;
        top: 60px;
        left: 12px;
    }
    
    /* Transform footer into right sidebar */
    #unit-footer {
        position: fixed;
        bottom: 0;
        top: 0;
        left: auto;
        right: 0;
        width: 110px;
        height: 100vh;
        flex-direction: column;
        align-items: stretch;
        border-top: none;
        border-left: 3px solid #1a1a1a;
        box-shadow: -4px 0 12px rgba(0, 0, 0, 0.15);
        padding-top: 8px;
    }
    
    /* End Turn button at top of sidebar */
    #end-turn-btn-sidebar {
        display: flex !important;
        justify-content: center;
        align-items: center;
        padding: 10px 8px;
        margin: 0 8px 8px 8px;
        background: rgba(51, 153, 255, 0.15);
        border: 2px solid #1a1a1a;
        border-radius: 8px;
        font-family: 'Caveat', cursive;
        font-size: 16px;
        font-weight: 700;
        color: #1a1a1a;
        cursor: pointer;
        box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.15);
        transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.15s ease;
        user-select: none;
        -webkit-user-select: none;
        flex-shrink: 0;
        order: 1;
    }
    
    #end-turn-btn-sidebar:hover {
        background: rgba(51, 153, 255, 0.3);
        transform: translateY(-2px);
        box-shadow: 3px 4px 0 rgba(0, 0, 0, 0.2);
    }
    
    #end-turn-btn-sidebar:active {
        transform: translateY(1px);
        box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.15);
    }
    
    #end-turn-btn-sidebar.disabled {
        opacity: 0.5;
        cursor: not-allowed;
        pointer-events: none;
    }
    
    /* Resources display at bottom of sidebar - use order to position after cards */
    #resources-display {
        flex-direction: column;
        margin: 8px;
        margin-top: auto;
        padding: 8px 6px;
        gap: 4px;
        order: 10;
        flex-shrink: 0;
    }
    
    /* Unit cards container - vertical scroll */
    #unit-cards-container {
        flex-direction: column;
        overflow-x: hidden;
        overflow-y: auto;
        padding: 8px;
        gap: 10px;
        flex: 1;
        min-height: 0;
        align-items: center;
        order: 2;
    }
    
    #unit-cards-container::-webkit-scrollbar {
        width: 6px;
        height: auto;
    }
    
    #unit-cards-container::-webkit-scrollbar-track {
        background: rgba(0, 0, 0, 0.1);
        border-radius: 3px;
    }
    
    #unit-cards-container::-webkit-scrollbar-thumb {
        background: rgba(51, 153, 255, 0.6);
        border-radius: 3px;
    }
    
    /* Unit cards sized for sidebar */
    .unit-card {
        width: 75px;
        height: 80px;
        flex-shrink: 0;
    }
    
    .unit-card-image {
        width: 42px;
        height: 42px;
    }
    
    .unit-card-name {
        font-size: 10px;
    }
    
    .unit-card.selected {
        margin-bottom: 0;
        margin-right: 8px;
    }
    
    /* Multi-select button at bottom of sidebar - after resources */
    #multi-select-btn {
        margin: 8px;
        margin-top: 0;
        flex-shrink: 0;
        order: 11;
    }
    
    /* Adjust switch character and turn mode buttons for landscape */
    #switch-character-btn {
        bottom: 20px;
        left: 20px;
    }
    
    #turn-mode-container {
        bottom: 20px;
        right: 130px;
    }
    
    /* Debug overlay adjustments */
    #debug-overlay {
        top: 60px;
    }
}

/* Desktop landscape (wider screens) */
@media (orientation: landscape) and (min-width: 1024px) {
    #unit-footer {
        width: 130px;
    }
    
    .unit-card {
        width: 90px;
        height: 90px;
    }
    
    .unit-card-image {
        width: 48px;
        height: 48px;
    }
    
    .unit-card-name {
        font-size: 11px;
    }
    
    #end-turn-btn-sidebar {
        padding: 12px 10px;
        font-size: 18px;
    }
    
    #turn-mode-container {
        right: 150px;
    }
}

/* Hide landscape-only elements in portrait */
@media (orientation: portrait) {
    #menu-btn-floating {
        display: none !important;
    }
    
    #fullscreen-btn-floating {
        display: none !important;
    }
    
    #end-turn-btn-sidebar {
        display: none !important;
    }
}

@media (max-width: 768px) {
    #debug-overlay {
        top: 10px;
        left: 10px;
        padding: 8px 12px;
        font-size: 10px;
    }
    
    .debug-title {
        font-size: 14px;
    }
    
    .debug-hint {
        font-size: 9px;
    }
    
    #turn-mode-container {
        bottom: 20px;
        right: 20px;
    }
    
    .turn-toggle {
        font-size: 14px;
        padding: 6px 10px;
    }
    
    .toggle-slider {
        width: 34px;
        height: 18px;
    }
    
    .toggle-slider::after {
        width: 12px;
        height: 12px;
        top: 2px;
        left: 2px;
    }
    
    .turn-toggle input:checked + .toggle-slider::after {
        transform: translateX(16px);
    }
    
    #game-header {
        height: 50px;
        padding: 0 12px;
    }
    
    #mp-btn {
        left: 130px;
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
    
    #mp-status {
        left: 172px;
        font-size: 9px;
        max-width: 70px;
    }
    
    #menu-btn {
        left: 8px;
        width: 38px;
        height: 38px;
        font-size: 20px;
    }
    
    #fullscreen-btn {
        left: 52px;
        width: 38px;
        height: 38px;
        font-size: 20px;
    }
    
    #level-display {
        font-size: 22px;
    }
    
    #context-menu {
        left: 12px;
        top: 46px;
    }
    
    .menu-item {
        padding: 10px 16px;
        font-size: 16px;
    }
    
    #end-turn-btn {
        right: 12px;
        padding: 8px 14px;
        font-size: 16px;
    }
    
    #unit-footer {
        height: 95px;
    }
    
    .unit-card {
        width: 70px;
        height: 75px;
    }
    
    .unit-card-image {
        width: 40px;
        height: 40px;
    }
    
    .unit-card-name {
        font-size: 10px;
    }
    
    .unit-card.selected {
        margin-bottom: 12px;
    }
    
    #switch-character-btn {
        bottom: 115px;
    }
    
    #turn-mode-container {
        bottom: 115px;
    }
}

@media (min-width: 769px) {
    #switch-character-btn {
        bottom: 130px;
    }
    
    #turn-mode-container {
        bottom: 130px;
    }
}

/* Level transition animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Game Mode Selection Dialog */
#game-mode-dialog {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: slideUpIn 0.4s ease-out;
}

#game-mode-dialog.hidden {
    display: none;
}

@keyframes slideUpIn {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.game-mode-content {
    background: rgba(245, 240, 230, 0.98);
    border: 4px solid #1a1a1a;
    border-radius: 16px;
    padding: 24px 40px;
    text-align: center;
    box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.3);
}

.game-mode-title {
    font-family: 'Caveat', cursive;
    font-size: 28px;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 20px;
    letter-spacing: 2px;
}

.game-mode-buttons {
    display: flex;
    gap: 16px;
    justify-content: center;
}

.game-mode-btn {
    width: 140px;
    height: 160px;
    padding: 12px 16px;
    border: 3px solid #1a1a1a;
    border-radius: 10px;
    font-family: 'Caveat', cursive;
    font-size: 24px;
    font-weight: 700;
    color: #1a1a1a;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.mode-btn-img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    image-rendering: pixelated;
    pointer-events: none;
}

.mode-btn-label {
    display: block;
    line-height: 1;
}

.game-mode-btn:hover {
    transform: translateY(-3px);
    box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.25);
}

.game-mode-btn:active {
    transform: translateY(1px);
    box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.15);
}

.rts-btn {
    background: linear-gradient(135deg, #ff9966 0%, #ff6b35 100%);
}

.rts-btn:hover {
    background: linear-gradient(135deg, #ffad80 0%, #ff8555 100%);
}

.turnbased-btn {
    background: linear-gradient(135deg, #6db3f2 0%, #4a9de0 100%);
}

.turnbased-btn:hover {
    background: linear-gradient(135deg, #8ec5f6 0%, #5aa8e8 100%);
}

@media (max-width: 768px) {
    #game-mode-dialog {
        padding: 16px;
    }
    
    .game-mode-content {
        padding: 20px 24px;
    }
    
    .game-mode-title {
        font-size: 22px;
        margin-bottom: 16px;
    }
    
    .game-mode-btn {
        width: 120px;
        height: 140px;
        padding: 10px 12px;
        font-size: 20px;
    }
    
    .mode-btn-img {
        width: 64px;
        height: 64px;
    }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

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

/* Merchant Dialog */
#merchant-dialog {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(26, 26, 26, 0.9);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.merchant-dialog-content {
    background: rgba(245, 240, 230, 0.98);
    border: 4px solid #1a1a1a;
    border-radius: 12px;
    padding: 24px 32px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.3);
}

.merchant-title {
    font-family: 'Caveat', cursive;
    font-size: 32px;
    color: #1a1a1a;
    margin: 0 0 8px 0;
    font-weight: 700;
}

.merchant-emoji {
    font-size: 48px;
    margin: 8px 0;
}

.merchant-image {
    width: 80px;
    height: 80px;
    image-rendering: pixelated;
    margin: 12px 0;
}

.merchant-text {
    font-family: 'Caveat', cursive;
    font-size: 20px;
    color: #1a1a1a;
    margin: 12px 0;
    line-height: 1.4;
}

.merchant-coins {
    font-family: 'JetBrains Mono', monospace;
    font-size: 16px;
    color: #b8860b;
    font-weight: 700;
    margin: 16px 0 8px 0;
}

.merchant-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
}

.merchant-btn {
    font-family: 'Caveat', cursive;
    font-size: 18px;
    font-weight: 700;
    padding: 12px 20px;
    background: linear-gradient(135deg, #6db3f2 0%, #4a9de0 100%);
    border: 3px solid #1a1a1a;
    border-radius: 8px;
    cursor: pointer;
    color: #1a1a1a;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.2);
}

.merchant-btn:hover:not(.disabled) {
    transform: translateY(-2px);
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.25);
    background: linear-gradient(135deg, #8ec5f6 0%, #5aa8e8 100%);
}

.merchant-btn:active:not(.disabled) {
    transform: translateY(1px);
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.2);
}

.merchant-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #aaa;
}

.merchant-btn-close {
    background: rgba(200, 200, 200, 0.8);
    margin-top: 8px;
}

.merchant-btn-close:hover {
    background: rgba(180, 180, 180, 0.9);
}

/* Nai-specific dialog styles */
.nai-dialog .merchant-title {
    color: #9966cc;
}

.nai-btn {
    background: linear-gradient(135deg, #cc99ff 0%, #9966cc 100%) !important;
}

.nai-btn:hover:not(.disabled) {
    background: linear-gradient(135deg, #dd99ff 0%, #aa77dd 100%) !important;
}

.merchant-no-books {
    font-family: 'Caveat', cursive;
    font-size: 18px;
    color: #666;
    font-style: italic;
    margin: 12px 0;
    padding: 10px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
}

/* QR Code Modal */
#qr-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
    animation: fadeIn 0.3s ease;
}

.qr-modal-content {
    background: rgba(245, 240, 230, 0.98);
    border: 4px solid #1a1a1a;
    border-radius: 16px;
    padding: 28px 36px;
    text-align: center;
    max-width: 340px;
    width: 90%;
    box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.25);
    animation: bounceIn 0.4s ease-out;
}

.qr-title {
    font-family: 'Caveat', cursive;
    font-size: 32px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 8px 0;
}

.qr-instructions {
    font-family: 'Caveat', cursive;
    font-size: 18px;
    color: #555;
    margin: 0 0 20px 0;
    line-height: 1.3;
}

.qr-code-container {
    background: white;
    border: 3px solid #1a1a1a;
    border-radius: 12px;
    padding: 16px;
    display: inline-block;
    margin-bottom: 16px;
}

.qr-code-img {
    display: block;
    width: 200px;
    height: 200px;
    image-rendering: pixelated;
}

.qr-or {
    font-family: 'Caveat', cursive;
    font-size: 16px;
    color: #888;
    margin: 0 0 12px 0;
}

.qr-url-label {
    display: block;
    font-family: 'Caveat', cursive;
    font-size: 16px;
    color: #555;
    margin-bottom: 8px;
    text-align: left;
}

.qr-url-input {
    display: block;
    width: 100%;
    padding: 10px 12px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 12px;
    background: #fff;
    border: 2px solid #1a1a1a;
    border-radius: 8px;
    color: #333;
    text-overflow: ellipsis;
    margin-bottom: 6px;
    box-sizing: border-box;
    cursor: text;
}

.qr-url-input:focus {
    outline: none;
    border-color: #4a9de0;
    box-shadow: 0 0 0 3px rgba(74, 157, 224, 0.2);
}

.qr-url-hint {
    font-family: 'Caveat', cursive;
    font-size: 14px;
    color: #999;
    margin: 0 0 16px 0;
    font-style: italic;
}

/* Legacy copy button styles (kept for backwards compatibility) */
.qr-copy-btn {
    display: none;
    width: 100%;
    padding: 12px 20px;
    background: linear-gradient(135deg, #6db3f2 0%, #4a9de0 100%);
    border: 3px solid #1a1a1a;
    border-radius: 10px;
    font-family: 'Caveat', cursive;
    font-size: 20px;
    font-weight: 700;
    color: #1a1a1a;
    cursor: pointer;
    margin-bottom: 12px;
    transition: transform 0.15s ease, background 0.15s ease;
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.2);
}

.qr-copy-btn:hover {
    background: linear-gradient(135deg, #8ec5f6 0%, #5aa8e8 100%);
    transform: translateY(-2px);
}

.qr-copy-btn:active {
    transform: translateY(1px);
    box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.15);
}

.qr-copy-btn.copied {
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
}

.qr-ok-btn {
    display: block;
    width: 100%;
    padding: 14px 20px;
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
    border: 3px solid #1a1a1a;
    border-radius: 10px;
    font-family: 'Caveat', cursive;
    font-size: 22px;
    font-weight: 700;
    color: #1a1a1a;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease;
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.2);
}

.qr-ok-btn:hover {
    background: linear-gradient(135deg, #6ee7a0 0%, #34d87c 100%);
    transform: translateY(-2px);
}

.qr-ok-btn:active {
    transform: translateY(1px);
    box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.15);
}

@media (max-width: 768px) {
    .qr-modal-content {
        padding: 20px 24px;
        max-width: 300px;
    }
    
    .qr-title {
        font-size: 28px;
    }
    
    .qr-instructions {
        font-size: 16px;
    }
    
    .qr-code-container {
        padding: 12px;
    }
    
    .qr-code-img {
        width: 160px;
        height: 160px;
    }
    
    .qr-copy-btn,
    .qr-ok-btn {
        font-size: 18px;
        padding: 10px 16px;
    }
    
    .qr-url-input {
        font-size: 11px;
        padding: 8px 10px;
    }
    
    .qr-url-label {
        font-size: 14px;
    }
    
    .qr-url-hint {
        font-size: 12px;
        margin-bottom: 12px;
    }
}

@media (max-width: 768px) {
    .merchant-dialog-content {
        padding: 16px 20px;
    }
    
    .merchant-title {
        font-size: 26px;
    }
    
    .merchant-emoji {
        font-size: 36px;
    }
    
    .merchant-image {
        width: 64px;
        height: 64px;
    }
    
    .merchant-text {
        font-size: 18px;
    }
    
    .merchant-btn {
        font-size: 16px;
        padding: 10px 16px;
    }
}

/* Dialog Balloons */
.dialog-balloon {
    position: fixed;
    transform: translate(-50%, -100%);
    background: rgba(255, 255, 255, 0.98);
    border: 3px solid #1a1a1a;
    border-radius: 16px;
    padding: 12px 16px;
    min-width: 120px;
    max-width: 220px;
    z-index: 500;
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.2);
    animation: balloonPop 0.3s ease-out;
}

.dialog-balloon::after {
    content: '';
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 15px solid #1a1a1a;
}

.dialog-balloon::before {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 12px solid white;
    z-index: 1;
}

/* ============ OVERWORLD MAP ============ */
#overworld-canvas {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* ============ UNIT CONTEXT MENU ============ */
.unit-context-menu {
    position: fixed;
    background: rgba(245, 240, 230, 0.98);
    border: 3px solid #1a1a1a;
    border-radius: 8px;
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.25);
    z-index: 500;
    min-width: 130px;
    overflow: hidden;
    animation: contextMenuPop 0.15s ease-out;
}

.unit-context-menu.hidden {
    display: none;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-bottom: 2px solid rgba(26, 26, 26, 0.1);
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    cursor: pointer;
    text-align: left;
    transition: background 0.1s ease, transform 0.1s ease;
}

.context-menu-item:last-child {
    border-bottom: none;
}

.context-menu-item:hover {
    background: rgba(51, 153, 255, 0.2);
}

.context-menu-item:active {
    transform: scale(0.98);
    background: rgba(51, 153, 255, 0.35);
}

.context-menu-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    color: #888;
}

.context-menu-item.disabled:hover {
    background: transparent;
}

.context-menu-item.disabled:active {
    transform: none;
    background: transparent;
}

.context-menu-icon {
    font-size: 16px;
}

@keyframes contextMenuPop {
    0% {
        opacity: 0;
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes balloonPop {
    0% {
        transform: translate(-50%, -100%) scale(0.5);
        opacity: 0;
    }
    50% {
        transform: translate(-50%, -100%) scale(1.1);
    }
    100% {
        transform: translate(-50%, -100%) scale(1);
        opacity: 1;
    }
}

.dialog-speaker {
    font-family: 'Caveat', cursive;
    font-size: 16px;
    font-weight: 700;
    color: #666;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
    border-bottom: 1px solid rgba(0,0,0,0.1);
    padding-bottom: 4px;
}

.dialog-text {
    font-family: 'Caveat', cursive;
    font-size: 22px;
    font-weight: 700;
    color: #1a1a1a;
    text-align: center;
    line-height: 1.3;
    margin-bottom: 8px;
}

.options-balloon {
    min-width: 200px;
    max-width: 280px;
}

.options-balloon .dialog-speaker {
    font-size: 12px;
    color: #888;
}

.dialog-next-btn {
    display: block;
    width: 100%;
    padding: 6px 12px;
    background: linear-gradient(135deg, #6db3f2 0%, #4a9de0 100%);
    border: 2px solid #1a1a1a;
    border-radius: 8px;
    font-family: 'Caveat', cursive;
    font-size: 16px;
    font-weight: 700;
    color: #1a1a1a;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.15);
}

.dialog-next-btn:hover {
    background: linear-gradient(135deg, #8ec5f6 0%, #5aa8e8 100%);
    transform: translateY(-1px);
}

.dialog-next-btn:active {
    transform: translateY(1px);
    box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.15);
}

.dialog-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dialog-option-btn {
    padding: 8px 12px;
    background: linear-gradient(135deg, #ffd700 0%, #ffb347 100%);
    border: 2px solid #1a1a1a;
    border-radius: 8px;
    font-family: 'Caveat', cursive;
    font-size: 16px;
    font-weight: 700;
    color: #1a1a1a;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.15);
    text-align: center;
}

.dialog-option-btn:hover {
    background: linear-gradient(135deg, #ffe033 0%, #ffca5a 100%);
    transform: translateY(-2px);
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.2);
}

.dialog-option-btn:active {
    transform: translateY(1px);
    box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.15);
}

.dialog-continue-btn {
    display: block;
    width: 100%;
    padding: 10px 20px;
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
    border: 3px solid #1a1a1a;
    border-radius: 10px;
    font-family: 'Caveat', cursive;
    font-size: 20px;
    font-weight: 700;
    color: #1a1a1a;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease;
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.2);
    animation: continuePulse 1.5s ease-in-out infinite;
}

@keyframes continuePulse {
    0%, 100% {
        box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.2), 0 0 0 0 rgba(74, 222, 128, 0.4);
    }
    50% {
        box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.2), 0 0 0 8px rgba(74, 222, 128, 0);
    }
}

.dialog-continue-btn:hover {
    background: linear-gradient(135deg, #6ee7a0 0%, #34d87c 100%);
    transform: translateY(-2px);
}

.dialog-continue-btn:active {
    transform: translateY(1px);
    box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.15);
}

.continue-balloon {
    min-width: 140px;
}

/* Skip Dialog Button */
.skip-dialog-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.6);
    color: rgba(255, 255, 255, 0.85);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    padding: 8px 16px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    z-index: 600;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
    letter-spacing: 1px;
}

.skip-dialog-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.6);
    transform: scale(1.05);
}

.skip-dialog-btn:active {
    transform: scale(0.98);
}

@media (max-width: 768px) {
    .skip-dialog-btn {
        bottom: 15px;
        right: 15px;
        padding: 6px 12px;
        font-size: 12px;
    }
}

@media (max-width: 768px) {
    .dialog-balloon {
        padding: 10px 14px;
        min-width: 100px;
        max-width: 180px;
    }
    
    .dialog-text {
        font-size: 18px;
    }
    
    .dialog-next-btn,
    .dialog-option-btn {
        font-size: 14px;
        padding: 6px 10px;
    }
    
    .dialog-continue-btn {
        font-size: 18px;
        padding: 8px 16px;
    }
}