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

body {
    font-family: 'Courier New', Courier, monospace;
    background: #0a0a0f;
    color: #c0c0c0;
    height: 100vh;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* --- Top Bar --- */

#top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid #1a1a2e;
    background: #0f0f1a;
    flex-shrink: 0;
}

#top-bar h1 {
    font-size: 1.3rem;
    color: #4fc3f7;
    text-shadow: 0 0 10px rgba(79, 195, 247, 0.3);
}

#currency-display {
    font-size: 1.1rem;
}

#currency-amount {
    color: #4fc3f7;
    font-weight: bold;
    margin-right: 0.3rem;
}

.currency-label {
    color: #666;
    font-size: 0.85rem;
}

#lucidity-rate-display {
    color: #4a7a5a;
    font-size: 0.8rem;
    margin-left: 0.4rem;
}

/* --- Game Area --- */

#game-area {
    display: flex;
    flex: 1;
    min-height: 0;
}

#grid-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    min-width: 0;
    position: relative;
}

#clear-btn {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    font-family: inherit;
    font-size: 0.75rem;
    padding: 0.4rem 0.8rem;
    background: transparent;
    color: #555;
    border: 1px solid #1a1a2e;
    border-radius: 4px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

#clear-btn:hover {
    color: #c0c0c0;
    border-color: #4fc3f7;
}

/* --- SVG Hex Grid --- */

.hex-svg {
    width: 100%;
    height: 100%;
    max-width: 600px;
    max-height: 600px;
}

.hex-cell {
    cursor: default;
}

.hex-bg {
    fill: #0f0f1a;
    stroke: #1a1a2e;
    stroke-width: 1.5;
    transition: fill 0.15s, stroke 0.15s;
}

.hex-cell.occupied .hex-bg {
    fill: #141428;
    stroke: #2a2a4a;
}

.hex-cell.occupied {
    cursor: grab;
}

.hex-cell.drop-target .hex-bg {
    fill: #1a2a3a;
    stroke: #4fc3f7;
    stroke-width: 2;
}

.hex-cell.dragging-source .hex-bg {
    fill: #0a0a14;
    stroke: #1a1a2e;
    stroke-dasharray: 4 3;
}

.hex-text {
    fill: #c0c0c0;
    font-family: 'Courier New', Courier, monospace;
    font-size: 11px;
    pointer-events: none;
}

.hex-cell.dragging-source .hex-text {
    fill: transparent;
}

/* --- Word Bank --- */

#word-bank-container {
    width: 260px;
    flex-shrink: 0;
    border-left: 1px solid #1a1a2e;
    background: #0c0c16;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#word-bank-container h2 {
    font-size: 0.8rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 0.8rem 1rem 0.5rem;
    flex-shrink: 0;
}

#word-bank {
    flex: 1;
    overflow-y: auto;
    padding: 0 0.75rem 0.75rem;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 0.4rem;
}

.word-tile {
    padding: 0.35rem 0.65rem;
    background: #141428;
    border: 1px solid #2a2a4a;
    border-radius: 4px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.8rem;
    color: #c0c0c0;
    cursor: grab;
    transition: border-color 0.15s, box-shadow 0.15s, opacity 0.15s;
    touch-action: none;
}

.word-tile:hover {
    border-color: #4fc3f7;
    box-shadow: 0 0 8px rgba(79, 195, 247, 0.15);
}

.word-tile.placed {
    opacity: 0.25;
    pointer-events: none;
}

.word-tile.dragging {
    opacity: 0.25;
}

/* --- Drag Ghost --- */

.drag-ghost {
    position: fixed;
    transform: translate(-50%, -50%);
    padding: 0.4rem 0.7rem;
    background: #1a2a3a;
    border: 1px solid #4fc3f7;
    border-radius: 4px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85rem;
    color: #4fc3f7;
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 0 16px rgba(79, 195, 247, 0.3);
    will-change: left, top;
}

/* --- Link Score Toast --- */

.link-toast {
    position: fixed;
    transform: translate(-50%, -50%);
    padding: 0.25rem 0.5rem;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.75rem;
    font-weight: bold;
    border-radius: 3px;
    pointer-events: none;
    z-index: 999;
    transition: opacity 1s ease-out, transform 1s ease-out;
    text-shadow: 0 0 6px currentColor;
}

.link-toast.link-good {
    color: #4fc3f7;
    background: rgba(15, 30, 50, 0.85);
    border: 1px solid rgba(79, 195, 247, 0.4);
}

.link-toast.link-bad {
    color: #f44336;
    background: rgba(50, 15, 15, 0.85);
    border: 1px solid rgba(244, 67, 54, 0.4);
}

.link-toast-fade {
    opacity: 0;
    transform: translate(-50%, -80%);
}

/* --- Scrollbar --- */

#word-bank::-webkit-scrollbar {
    width: 4px;
}

#word-bank::-webkit-scrollbar-track {
    background: transparent;
}

#word-bank::-webkit-scrollbar-thumb {
    background: #1a1a2e;
    border-radius: 2px;
}
