body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    background-color: #1a1a2e;
    color: #fff;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: grab;
}

canvas:active {
    cursor: grabbing;
}

#loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 26, 46, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 1;
    transition: opacity 0.5s ease;
}

#loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#loading-canvas {
    width: 400px;
    height: 400px;
    max-width: 80vw;
    max-height: 50vh;
}

.loading-text {
    margin-top: 20px;
    color: white;
    font-size: 1.2rem;
    letter-spacing: 2px;
    animation: textPulse 2s ease-in-out infinite;
}

@keyframes textPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    padding: 20px;
    pointer-events: none;
    width: 300px;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
}

#guess-container, #history-container, h1, #status-bar {
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.7);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    backdrop-filter: blur(5px);
}

h1 {
    margin: 0 0 10px 0;
    font-size: 1.5rem;
    text-align: center;
    color: #e94560;
}

#status-bar {
    font-size: 0.9rem;
    text-align: center;
    color: #ccc;
}

#guess-form {
    display: flex;
    gap: 5px;
}

input {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: 4px;
    background: #fff;
    color: #000;
}

button {
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    background: #e94560;
    color: white;
    cursor: pointer;
    font-weight: bold;
}

button:hover {
    background: #d63d56;
}

#history-container {
    flex: 1;
    overflow-y: auto;
    max-height: 60vh;
}

#history-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.guess-item {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px solid #444;
}

.guess-word {
    font-weight: bold;
}

.guess-score {
    font-family: monospace;
}

.mode-btn {
    font-size: 0.8rem;
    padding: 4px 8px;
    background: #444;
    margin: 0 2px;
}

.mode-btn.active {
    background: #e94560;
    cursor: default;
}

#toast-container {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.95rem;
    backdrop-filter: blur(10px);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
    border-left: 4px solid #e94560;
}

.toast.error {
    border-left-color: #ff4444;
}

.toast.success {
    border-left-color: #44ff44;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

#settings-modal {
    position: fixed;
    z-index: 9999 !important;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background-color: rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
}

#settings-modal.hidden {
    display: none !important;
}

.modal-content {
    background-color: #2a2a40;
    margin: 0;
    padding: 20px;
    border: 1px solid #888;
    width: 300px;
    border-radius: 10px;
    color: white;
    position: absolute;
    top: 60px;
    right: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: white;
    text-decoration: none;
    cursor: pointer;
}

.setting-group {
    margin-bottom: 20px;
}

.setting-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: bold;
    color: #e94560;
}

.toggle-group {
    display: flex;
    background: #1a1a2e;
    border-radius: 5px;
    padding: 2px;
}

.toggle-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    color: #888;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.toggle-btn.active {
    background: #e94560;
    color: white;
}

#settings-btn:hover {
    background: rgba(255,255,255,0.1) !important;
}
