/* Font declarations */
@font-face {
    font-family: 'PixelOperator';
    src: url('fonts/pixel-operator/PixelOperator.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'PixelOperator';
    src: url('fonts/pixel-operator/PixelOperator-Bold.ttf') format('truetype');
    font-weight: bold;
    font-style: normal;
}

/* Updated layout with 5-row structure */
.container {
    display: grid;
    grid-template-areas:
        "header header header"
        "status game game"
        "chat game game"
        "input input input"
        "footer footer footer";
    grid-template-columns: 350px 1fr 1fr;
    grid-template-rows: auto auto 1fr auto auto;
    height: 100vh;
    width: 100%;
    max-width: 100vw;
    overflow: hidden;
    gap: 1px;
    background-color: #222;
}

/* Header area */
.banner {
    grid-area: header;
    background-color: #111;
    padding: 5px;
    color: white;
    text-align: left;
    border-bottom: 1px solid #444;
    font-family: 'PixelOperator', monospace;
    font-weight: bold;
    font-size: 24px;
    letter-spacing: 1px;
}

/* Status area for block height display */
.status {
    grid-area: status;
    background-color: #222;
    padding: 10px;
    color: #0f0;
    font-family: monospace;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    border-right: 1px solid #444;
}

/* Make sure rotdis is properly visible across all browsers */
.rotdis {
    grid-area: game;
    background-color: #000;
    border: 2px solid #444;
    display: flex !important; /* Using flex to center canvas */
    justify-content: center;
    align-items: center;
    /* min-height: 608px; */ /* REMOVED to allow shrinking */
    width: 100%; /* Ensure it takes full width of its grid area */
    height: 100%; /* Ensure it takes full height of its grid area */
    position: relative;
    overflow: hidden; /* Important to clip canvas if it somehow overflows */
    z-index: 5;
}

.rotdis canvas {
    display: block !important;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    max-width: 100%;  /* ADDED: Scale down to fit container width */
    max-height: 100%; /* ADDED: Scale down to fit container height */
    object-fit: contain; /* ADDED: Maintain aspect ratio when scaling */
}

/* Add debug overlay to see container bounds */
.rotdis::before {
    content: "GAME AREA";
    position: absolute;
    top: 5px;
    left: 5px;
    color: rgba(255,255,255,0.3);
    font-family: monospace;
    font-size: 12px;
    z-index: 1;
    pointer-events: none;
}

/* Chat messages area */
.chat-container {
    grid-area: chat;
    background-color: #222;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #444;
    overflow: hidden; /* Prevents chat from causing scrolling */
}

#messageBox {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px;
    height: 100%;
    max-height: 100%;
}

#messages {
    list-style-type: none;
    margin: 0;
    padding: 0;
    color: #fff; /* Default text color */;
}

#messages li {
    padding: 3px 5px;
    margin-bottom: 2px;
    word-break: break-word;
}

/* Chat input area, now in its own row */
.input-container {
    grid-area: input;
    background-color: #333;
    padding: 10px;
    border-top: 1px solid #444;
    border-bottom: 1px solid #444;
}

#chatForm {
    display: flex;
    width: 100%;
}

#chatInput {
    flex-grow: 1;
    padding: 8px;
    border: none;
    background-color: #444;
    color: #fff;
    border-radius: 3px 0 0 3px;
}

#chatForm button {
    padding: 0 20px;
    background-color: #555;
    color: white;
    border: none;
    cursor: pointer;
    border-radius: 0 3px 3px 0;
}

/* Add this to your stylesheet to use the font in other places */
#staticbanner {
    font-family: 'PixelOperator', monospace;
    font-weight: bold;
    letter-spacing: 1px;
    padding: 10px;
}

.footer {
    grid-area: footer;
    background-color: #111;
    color: #888;
    padding: 5px;
    text-align: center;
    font-size: 0.8em;
    font-family: 'PixelOperator', sans-serif;
}

/* Game messages styling */
li.game-start {
    color: #0f0;
    font-weight: bold;
    text-align: center;
    margin: 5px 0;
    padding: 2px 0;
    background: rgba(0,255,0,0.1);
}

li.error {
    color: #f00;
    font-weight: bold;
    font-family: monospace;
    padding: 2px 5px;
    background: rgba(255,0,0,0.1);
    border-left: 2px solid #f00;
}

li.debug {
    color: #0ff;
    font-family: monospace;
    font-size: 0.9em;
    padding-left: 10px;
    border-left: 2px solid #0ff;
}

/* Utility */
.hidden {
    display: none !important;
}

/* Modal styling */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding: 20px;
}

.modal-content {
    background: #0a0a0f;
    border: 2px solid #0ff;
    border-radius: 6px;
    width: min(480px, 90vw);
    padding: 20px;
    color: #0ff;
    font-family: 'PixelOperator', monospace;
    position: relative;
    box-shadow: 0 0 18px rgba(0, 255, 255, 0.2);
}

.modal-content h2 {
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 20px;
}

.modal-description {
    margin-top: 0;
    margin-bottom: 16px;
    font-size: 12px;
    color: #9cf;
}

.modal-label {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

#addressModalInput {
    width: 100%;
    background: #020205;
    border: 1px solid #0ff;
    border-radius: 4px;
    color: #0ff;
    padding: 10px;
    font-family: monospace;
    resize: vertical;
    min-height: 100px;
    box-shadow: inset 0 0 6px rgba(0, 255, 255, 0.15);
}

.modal-actions {
    margin-top: 16px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.modal-actions button {
    padding: 8px 16px;
    border-radius: 4px;
    border: 1px solid #0ff;
    background: #031c28;
    color: #0ff;
    cursor: pointer;
    font-family: inherit;
}

.modal-actions button#addressModalSave {
    background: #013d2a;
    border-color: #0f7;
    color: #0f7;
}

.modal-actions button:hover {
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.2);
}

.modal-close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: transparent;
    border: none;
    color: #0ff;
    font-size: 18px;
    cursor: pointer;
}

.modal-feedback {
    margin-top: 12px;
    font-size: 12px;
    min-height: 16px;
}

.modal-feedback.error {
    color: #ff6b6b;
}

.modal-feedback.success {
    color: #5dff9c;
}

.modal-feedback.info {
    color: #9cf6ff;
}

