* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #1e1e1e;
    color: #eee;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    padding: 10px 16px;
    background: #262626;
    border-bottom: 1px solid #3a3a3a;
    display: flex;
    align-items: center;
    gap: 16px;
}

h1 {
    font-size: 16px;
    margin: 0;
    font-weight: 600;
}

.controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

button {
    background: #3a3a3a;
    color: #eee;
    border: 1px solid #4a4a4a;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

button:hover {
    background: #4a4a4a;
}

.hint {
    color: #999;
    font-size: 12px;
    margin-left: 8px;
}

.stats {
    font-size: 13px;
    color: #ccc;
}

.stats span {
    color: #eee;
    font-weight: 600;
}

.density-control input[type="range"] {
    width: 100px;
}

#main-area {
    flex: 1;
    display: flex;
    overflow: hidden;
}

#canvas-wrap {
    flex: 1;
    overflow: hidden;
    cursor: crosshair;
    position: relative;
}

#canvas-wrap.game-over-active {
    cursor: default;
}

#status.game-over {
    color: #ff6b6b;
    font-weight: 600;
}

#game-over {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
}

#game-over.hidden {
    display: none;
}

.game-over-card {
    background: #262626;
    border: 1px solid #4a4a4a;
    border-radius: 8px;
    padding: 24px 32px;
    text-align: center;
}

.game-over-title {
    font-size: 28px;
    margin-bottom: 4px;
}

.game-over-sub {
    color: #bbb;
    margin-bottom: 16px;
}

.hidden {
    display: none !important;
}

#name-gate {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
}

.name-gate-card {
    background: #262626;
    border: 1px solid #4a4a4a;
    border-radius: 8px;
    padding: 28px 32px;
    text-align: center;
    width: 320px;
}

.name-gate-title {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 8px;
}

.name-gate-sub {
    color: #bbb;
    font-size: 13px;
    margin-bottom: 18px;
}

#name-input {
    width: 100%;
    padding: 8px 10px;
    border-radius: 4px;
    border: 1px solid #4a4a4a;
    background: #1e1e1e;
    color: #eee;
    font-size: 14px;
    margin-bottom: 12px;
}

#name-input:focus {
    outline: none;
    border-color: #4c7dff;
}

#join-btn {
    width: 100%;
    background: #4c7dff;
    border-color: #4c7dff;
}

#welcome-back-name {
    color: #eee;
    font-weight: 600;
}

#continue-btn {
    width: 100%;
    background: #4c7dff;
    border-color: #4c7dff;
    margin-bottom: 8px;
}

#new-name-btn {
    width: 100%;
}

.name-gate-error {
    color: #ff6b6b;
    font-size: 13px;
    margin: -6px 0 12px;
    text-align: left;
}

.player-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #eee;
    background: #1e1e1e;
    border: 1px solid #3a3a3a;
    border-radius: 999px;
    padding: 4px 10px 4px 6px;
}

.color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

#inventory-section {
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid #3a3a3a;
}

.inventory-badge {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.inventory-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #eee;
    background: #1e1e1e;
    border: 1px solid #3a3a3a;
    border-radius: 999px;
    padding: 4px 10px;
}

.inventory-item-count {
    color: #999;
    font-weight: 600;
}

.inventory-item.draggable {
    cursor: grab;
    border-color: #4c7dff;
}

.inventory-item.draggable:active {
    cursor: grabbing;
}

#canvas-wrap.drag-target {
    outline: 3px dashed #4c7dff;
    outline-offset: -3px;
}

#item-toast {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(30, 30, 30, 0.95);
    border: 1px solid #4c7dff;
    color: #eee;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#item-toast.hidden {
    display: none;
}

.item-fly {
    position: fixed;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(20, 20, 20, 0.82);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
    font-size: 15px;
    line-height: 1;
    pointer-events: none;
    transform: translate(-50%, -50%);
    opacity: 1;
    transition: transform 2000ms cubic-bezier(0.3, 0.7, 0.4, 1), opacity 0.65s ease-in;
    will-change: transform, opacity;
}

#minimap-wrap {
    position: absolute;
    right: 12px;
    bottom: 12px;
    width: 160px;
    height: 160px;
    background: rgba(13, 13, 13, 0.9);
    border: 1px solid #4a4a4a;
    border-radius: 6px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    overflow: hidden;
}

#minimap-wrap.hidden {
    display: none;
}

#minimap-label {
    position: absolute;
    top: 4px;
    left: 6px;
    font-size: 10px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    pointer-events: none;
    z-index: 1;
}

#minimap {
    display: block;
    width: 100%;
    height: 100%;
}

#leaderboard {
    width: 220px;
    flex-shrink: 0;
    background: #212121;
    border-left: 1px solid #3a3a3a;
    padding: 14px 12px;
    overflow-y: auto;
}

#leaderboard h2 {
    margin: 0 0 10px;
    font-size: 12px;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

#leaderboard-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.leaderboard-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 13px;
}

.leaderboard-row.me {
    background: #2f2f2f;
}

.leaderboard-rank {
    width: 18px;
    flex-shrink: 0;
    color: #888;
    font-size: 12px;
    text-align: right;
}

.leaderboard-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #eee;
}

.leaderboard-row.dead .leaderboard-name {
    color: #777;
}

.leaderboard-score {
    color: #ccc;
    font-weight: 600;
    font-size: 12px;
}

.leaderboard-empty {
    color: #777;
    font-size: 12px;
}
