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

@font-face {
    font-family: 'Minecraft';
    src: local('Press Start 2P'), local('Courier New');
}

body {
    background: linear-gradient(180deg, #78A7FF 0%, #1E4B8E 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    overflow: hidden;
}

#game-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#game-canvas {
    border: 4px solid #2C2C2C;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    background: #87CEEB;
}

#menu {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.85);
    border: 4px solid #555;
    padding: 40px;
    z-index: 100;
    text-align: center;
    image-rendering: pixelated;
}

#menu h1 {
    color: #55FF55;
    font-size: 24px;
    margin-bottom: 30px;
    text-shadow: 3px 3px 0 #003300;
    letter-spacing: 2px;
}

#menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#menu button,
#save-btn {
    background: #4A4A4A;
    border: 3px solid #2C2C2C;
    border-bottom-color: #1A1A1A;
    border-right-color: #1A1A1A;
    border-top-color: #6A6A6A;
    border-left-color: #6A6A6A;
    color: #FFFFFF;
    padding: 12px 24px;
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    text-shadow: 2px 2px 0 #000;
    transition: all 0.1s;
    image-rendering: pixelated;
}

#menu button:hover,
#save-btn:hover {
    background: #5A5A5A;
    color: #FFFF55;
}

#menu button:active,
#save-btn:active {
    border-top-color: #1A1A1A;
    border-left-color: #1A1A1A;
    border-bottom-color: #6A6A6A;
    border-right-color: #6A6A6A;
    transform: translateY(2px);
}

#save-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 50;
    font-size: 12px;
    padding: 8px 16px;
}

#hud {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

#hotbar {
    display: flex;
    gap: 2px;
    background: rgba(0, 0, 0, 0.6);
    padding: 4px;
    border: 2px solid #1A1A1A;
}

.hotbar-slot {
    width: 48px;
    height: 48px;
    background: #8B8B8B;
    border: 2px solid #373737;
    border-top-color: #FFFFFF;
    border-left-color: #FFFFFF;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    image-rendering: pixelated;
}

.hotbar-slot.active {
    border: 3px solid #FFFFFF;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.hotbar-slot canvas {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.hotbar-slot .quantity {
    position: absolute;
    bottom: 2px;
    right: 4px;
    color: #FFFFFF;
    font-size: 10px;
    text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
    font-family: 'Press Start 2P', 'Courier New', monospace;
}

#controls-hint {
    background: rgba(0, 0, 0, 0.6);
    color: #AAAAAA;
    padding: 6px 12px;
    font-size: 8px;
    border-radius: 2px;
}

.hidden {
    display: none !important;
}

/* Pixel art style for scrollbar */
::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-track {
    background: #2C2C2C;
}

::-webkit-scrollbar-thumb {
    background: #5A5A5A;
    border: 2px solid #2C2C2C;
}

::-webkit-scrollbar-thumb:hover {
    background: #6A6A6A;
}

/* Durability bar in hotbar */
.durability-bar {
    position: absolute;
    bottom: 4px;
    left: 4px;
    height: 3px;
    background: #4CAF50;
    border-radius: 1px;
}

/* ==================== */
/* Guide Modal Styles   */
/* ==================== */

#guide-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 200;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-y: auto;
    padding: 20px;
}

#guide-content {
    background: #2C2C2C;
    border: 4px solid #555;
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 20px;
    position: relative;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
}

#guide-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #8B0000;
    border: 2px solid #FF4444;
    color: #FFF;
    font-size: 24px;
    width: 36px;
    height: 36px;
    cursor: pointer;
    font-family: inherit;
    line-height: 1;
}

#guide-close:hover {
    background: #AA0000;
}

#guide-content h2 {
    color: #55FF55;
    font-size: 20px;
    text-align: center;
    margin-bottom: 20px;
    text-shadow: 2px 2px 0 #003300;
}

#guide-content h3 {
    color: #FFAA00;
    font-size: 14px;
    margin: 20px 0 10px 0;
    border-bottom: 2px solid #444;
    padding-bottom: 5px;
}

#guide-content h4 {
    color: #55FFFF;
    font-size: 12px;
    margin: 10px 0 8px 0;
}

/* Tabs */
#guide-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 15px;
    border-bottom: 2px solid #444;
    padding-bottom: 10px;
}

.tab-btn {
    background: #4A4A4A;
    border: 2px solid #333;
    color: #AAA;
    padding: 8px 12px;
    font-family: inherit;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn:hover {
    background: #5A5A5A;
    color: #FFF;
}

.tab-btn.active {
    background: #55AA55;
    border-color: #77CC77;
    color: #FFF;
}

/* Tab content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Tables in guide */
#guide-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 10px;
}

#guide-content th,
#guide-content td {
    border: 1px solid #444;
    padding: 8px 10px;
    text-align: left;
}

#guide-content th {
    background: #3A3A3A;
    color: #FFAA00;
}

#guide-content td {
    background: #333;
    color: #DDD;
}

#guide-content tr:nth-child(even) td {
    background: #383838;
}

/* Recipe cards */
.recipe {
    background: #383838;
    border: 2px solid #444;
    padding: 10px;
    margin: 8px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.recipe-name {
    color: #55FF55;
    font-size: 11px;
    font-weight: bold;
}

.recipe-ingredients {
    color: #AAA;
    font-size: 10px;
    text-align: right;
}

.recipe-note {
    color: #888;
    font-size: 9px;
    font-style: italic;
    margin-top: 10px;
}

/* Mob info cards */
.mob-info {
    background: #333;
    border: 2px solid #444;
    padding: 10px;
    margin: 10px 0;
    border-radius: 4px;
}

.mob-info h4 {
    margin-top: 0;
}

.mob-info table {
    margin: 5px 0 0 0;
}

/* ==================== */
/* Multiplayer Styles   */
/* ==================== */

/* Menu Panel (shared styles for multiplayer menus) */
.menu-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    border: 4px solid #555;
    padding: 30px;
    z-index: 100;
    min-width: 350px;
    max-width: 500px;
    text-align: center;
}

.menu-panel h2 {
    color: #55FF55;
    font-size: 18px;
    margin-bottom: 25px;
    text-shadow: 2px 2px 0 #003300;
}

.menu-panel h3 {
    color: #FFAA00;
    font-size: 14px;
    margin-bottom: 15px;
}

/* Menu Form */
.menu-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
    text-align: left;
}

.menu-form label {
    color: #AAAAAA;
    font-size: 10px;
    margin-bottom: -8px;
}

.menu-form input[type="text"] {
    background: #2C2C2C;
    border: 2px solid #4A4A4A;
    border-top-color: #1A1A1A;
    border-left-color: #1A1A1A;
    color: #FFFFFF;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 12px;
    width: 100%;
}

.menu-form input[type="text"]:focus {
    outline: none;
    border-color: #55FF55;
}

.menu-form input[type="text"]::placeholder {
    color: #666666;
}

.menu-form input[type="checkbox"] {
    margin-right: 8px;
}

.menu-form label:has(input[type="checkbox"]) {
    display: flex;
    align-items: center;
    color: #FFFFFF;
    font-size: 12px;
    cursor: pointer;
}

/* Menu Buttons */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.menu-panel button {
    background: #4A4A4A;
    border: 3px solid #2C2C2C;
    border-bottom-color: #1A1A1A;
    border-right-color: #1A1A1A;
    border-top-color: #6A6A6A;
    border-left-color: #6A6A6A;
    color: #FFFFFF;
    padding: 12px 24px;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    text-shadow: 2px 2px 0 #000;
    transition: all 0.1s;
    width: 100%;
}

.menu-panel button:hover {
    background: #5A5A5A;
    color: #FFFF55;
}

.menu-panel button:active {
    border-top-color: #1A1A1A;
    border-left-color: #1A1A1A;
    border-bottom-color: #6A6A6A;
    border-right-color: #6A6A6A;
    transform: translateY(2px);
}

.menu-panel button:disabled {
    background: #3A3A3A;
    color: #666666;
    cursor: not-allowed;
}

.menu-panel button.primary-btn {
    background: #2E7D32;
    border-color: #1B5E20;
    border-top-color: #4CAF50;
    border-left-color: #4CAF50;
}

.menu-panel button.primary-btn:hover {
    background: #388E3C;
}

/* Status Text */
.status-text {
    color: #AAAAAA;
    font-size: 10px;
    margin: 10px 0;
    min-height: 16px;
}

.status-text.success {
    color: #55FF55;
}

.status-text.error {
    color: #FF5555;
}

.error-text {
    color: #FF5555;
    font-size: 10px;
    margin: 5px 0;
}

.waiting-text {
    color: #FFAA00;
    font-size: 12px;
    margin: 15px 0;
    text-align: center;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Room List */
#room-list-container {
    max-height: 250px;
    overflow-y: auto;
    margin-bottom: 15px;
    border: 2px solid #3A3A3A;
    background: #1A1A1A;
}

#room-list {
    padding: 5px;
}

.room-item {
    background: #2C2C2C;
    border: 2px solid #3A3A3A;
    padding: 12px;
    margin: 5px 0;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.room-item:hover {
    background: #3A3A3A;
    border-color: #55FF55;
}

.room-name {
    color: #FFFFFF;
    font-size: 12px;
    margin-bottom: 5px;
}

.room-info {
    display: flex;
    justify-content: space-between;
    color: #888888;
    font-size: 9px;
}

.room-host {
    color: #FFAA00;
}

.room-players {
    color: #55FFFF;
}

.no-rooms, .loading {
    color: #888888;
    font-size: 11px;
    padding: 20px;
    text-align: center;
}

/* Lobby Panel */
.lobby-panel {
    min-width: 500px;
    max-width: 600px;
}

.lobby-header {
    margin-bottom: 20px;
}

.room-code-display {
    color: #55FFFF;
    font-size: 14px;
    margin-top: 10px;
}

.room-code-display span {
    background: #2C2C2C;
    padding: 5px 10px;
    border: 2px solid #3A3A3A;
    letter-spacing: 3px;
}

#copy-code-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 5px;
    width: auto;
}

#copy-code-btn:hover {
    transform: scale(1.2);
}

.lobby-content {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.lobby-players {
    flex: 1;
    background: #1A1A1A;
    border: 2px solid #3A3A3A;
    padding: 10px;
    text-align: left;
}

.lobby-players h3 {
    font-size: 11px;
    margin-bottom: 10px;
    color: #AAAAAA;
}

#lobby-player-list {
    max-height: 200px;
    overflow-y: auto;
}

.lobby-player {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    margin: 4px 0;
    background: #2C2C2C;
    border: 1px solid #3A3A3A;
}

.player-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.player-name {
    color: #FFFFFF;
    font-size: 11px;
    flex: 1;
}

.host-badge {
    background: #FFAA00;
    color: #000000;
    font-size: 8px;
    padding: 2px 6px;
    border-radius: 2px;
}

/* Lobby Chat */
.lobby-chat {
    flex: 1.5;
    background: #1A1A1A;
    border: 2px solid #3A3A3A;
    display: flex;
    flex-direction: column;
}

#lobby-chat-messages {
    flex: 1;
    min-height: 150px;
    max-height: 200px;
    overflow-y: auto;
    padding: 10px;
    text-align: left;
}

.chat-message {
    margin: 5px 0;
    font-size: 10px;
    word-wrap: break-word;
}

.chat-message.system .system-text {
    color: #FFAA00;
    font-style: italic;
}

.chat-sender {
    font-weight: bold;
}

.chat-content {
    color: #FFFFFF;
    margin-left: 5px;
}

.chat-input-container {
    display: flex;
    gap: 5px;
    padding: 8px;
    background: #2C2C2C;
}

.chat-input-container input {
    flex: 1;
    background: #1A1A1A;
    border: 2px solid #3A3A3A;
    color: #FFFFFF;
    padding: 8px;
    font-family: inherit;
    font-size: 10px;
}

.chat-input-container input:focus {
    outline: none;
    border-color: #55FF55;
}

.chat-input-container button {
    padding: 8px 12px;
    font-size: 10px;
    width: auto;
}

/* Lobby Footer */
.lobby-footer {
    border-top: 2px solid #3A3A3A;
    padding-top: 15px;
}

.lobby-buttons {
    display: flex;
    gap: 10px;
}

.lobby-buttons button {
    flex: 1;
}

/* Connection Status Bar */
.connection-status-bar {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid #3A3A3A;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 50;
    font-size: 10px;
}

.connection-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
}

.connection-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    transition: background-color 0.3s;
}

.connection-dot.connected {
    background: #55FF55;
    box-shadow: 0 0 8px #55FF55;
}

.connection-dot.disconnected {
    background: #FF5555;
}

.connection-dot.reconnecting {
    background: #FFAA00;
    animation: pulse 1s infinite;
}

.connection-dot.error {
    background: #FF5555;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

#connection-text {
    color: #AAAAAA;
}

.connection-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

#player-count-info, #ping-info {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #AAAAAA;
}

.ping-good { color: #55FF55; }
.ping-medium { color: #FFAA00; }
.ping-bad { color: #FF5555; }

/* In-Game Chat */
.game-chat {
    position: absolute;
    bottom: 100px;
    left: 10px;
    width: 350px;
    z-index: 40;
}

.chat-messages-container {
    max-height: 150px;
    overflow-y: auto;
    padding: 5px;
    transition: opacity 0.5s;
}

.chat-messages-container.faded {
    opacity: 0.3;
}

.game-chat-message {
    background: rgba(0, 0, 0, 0.6);
    padding: 4px 8px;
    margin: 2px 0;
    font-size: 10px;
    border-radius: 2px;
}

.game-chat-message.system .system-text {
    color: #FFAA00;
    font-style: italic;
}

.chat-input-bar {
    background: rgba(0, 0, 0, 0.8);
    padding: 5px;
    margin-top: 5px;
}

.chat-input-bar input {
    width: 100%;
    background: #1A1A1A;
    border: 2px solid #3A3A3A;
    color: #FFFFFF;
    padding: 8px;
    font-family: inherit;
    font-size: 10px;
}

.chat-input-bar input:focus {
    outline: none;
    border-color: #55FF55;
}

/* Disconnection Warning */
.disconnection-warning {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

.warning-content {
    background: #2C2C2C;
    border: 4px solid #FF5555;
    padding: 30px;
    text-align: center;
}

.warning-content h3 {
    color: #FF5555;
    font-size: 16px;
    margin-bottom: 15px;
}

.warning-content p {
    color: #AAAAAA;
    font-size: 11px;
    margin-bottom: 20px;
}

.warning-content button {
    background: #4A4A4A;
    border: 3px solid #2C2C2C;
    border-bottom-color: #1A1A1A;
    border-right-color: #1A1A1A;
    border-top-color: #6A6A6A;
    border-left-color: #6A6A6A;
    color: #FFFFFF;
    padding: 10px 20px;
    font-family: inherit;
    font-size: 11px;
    cursor: pointer;
}

.warning-content button:hover {
    background: #5A5A5A;
    color: #FFFF55;
}
