:root {
    --hw-green: #6aaa64;
    --hw-yellow: #c9b458;
    --hw-gray: #787c7e;
    --hw-empty: #f3f4f6;
    --hw-stroke: #e5e7eb;
    --hw-hover: #e9ecef;
    --hw-text: #1f2937;
    --accent: #6366f1;
}

body {
    background-color: #f9fafb;
    background-image: radial-gradient(#e5e7eb 1px, transparent 1px);
    background-size: 20px 20px;
}

.text-gradient {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.game-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 500px;
    margin: 0 auto;
}

/* SVG Board */
.hex-board-wrapper {
    width: 100%;
    max-width: 400px;
    filter: drop-shadow(0 10px 15px rgba(0,0,0,0.05));
}

#hexSvg {
    width: 100%;
    height: auto;
    overflow: visible;
}

/* SVG Elements */
.hex-group {
    cursor: pointer;
    /* Removed transform transition to fix flickering */
}

.hex-polygon {
    fill: var(--hw-empty);
    stroke: var(--hw-stroke);
    stroke-width: 2;
    transition: fill 0.2s ease, stroke 0.2s ease, stroke-width 0.2s ease;
}

.hex-text {
    font-family: 'Arial', sans-serif;
    font-weight: 800;
    font-size: 24px;
    fill: var(--hw-text);
    pointer-events: none; 
    user-select: none;
    text-anchor: middle;
    dominant-baseline: central;
}

/* Word Position Indicator */
.word-position-indicator {
    font-family: 'Arial', sans-serif;
    font-size: 10px;
    font-weight: 700;
    fill: #6366f1;
    text-anchor: middle;
    dominant-baseline: middle;
    opacity: 0.7;
    pointer-events: none;
}

.word-position-indicator[data-word="w1"] { fill: #6366f1; } /* Blue for horizontal */
.word-position-indicator[data-word="w2"] { fill: #10b981; } /* Green for vertical */
.word-position-indicator[data-word="w3"] { fill: #f59e0b; } /* Orange for diagonal */

/* Hover State - Color change instead of scale */
.hex-group:hover .hex-polygon {
    stroke: #cbd5e1;
    stroke-width: 3;
    fill: #ffffff;
}

/* Selected State */
.hex-group.selected .hex-polygon {
    stroke: var(--accent);
    stroke-width: 4;
    fill: #eef2ff;
}

/* Filled State */
.hex-group.filled .hex-polygon {
    fill: white;
    filter: url(#dropShadow);
    stroke: #d1d5db;
}

/* Color States */
.hex-group.green .hex-polygon { fill: var(--hw-green); stroke: var(--hw-green); }
.hex-group.yellow .hex-polygon { fill: var(--hw-yellow); stroke: var(--hw-yellow); }
.hex-group.gray .hex-polygon { fill: var(--hw-gray); stroke: var(--hw-gray); }

.hex-group.green .hex-text,
.hex-group.yellow .hex-text,
.hex-group.gray .hex-text {
    fill: white;
}

/* Center Hex */
.hex-group[data-id="0"] .hex-polygon {
    stroke-width: 3;
    stroke: #94a3b8;
}

/* Hinted Slot */
.hex-group.hinted-slot .hex-polygon {
    stroke: #f59e0b;
    stroke-width: 3;
    stroke-dasharray: 5,5;
    animation: hintPulse 2s ease-in-out;
}

.hex-group.hinted {
    animation: hintFlash 0.5s ease-in-out;
}

@keyframes hintPulse {
    0%, 100% { stroke-opacity: 1; }
    50% { stroke-opacity: 0.5; }
}

@keyframes hintFlash {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Letter Pool */
.letter-pool {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.pool-tile {
    width: 48px;
    height: 48px;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--hw-text);
    cursor: pointer;
    box-shadow: 0 4px 0 #e5e7eb;
    transition: all 0.1s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}

.pool-tile:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #e5e7eb;
}

.pool-tile.used {
    opacity: 0.4;
    background: #f3f4f6;
    box-shadow: none;
    transform: translateY(4px);
    cursor: default;
}

.pool-tile.selected {
    border-color: var(--accent);
    background-color: #eef2ff;
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #c7d2fe;
}

/* Controls */
.btn-action {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    border: 2px solid #e5e7eb;
    color: #6b7280;
    background: white;
    transition: all 0.2s;
}

.btn-action:hover {
    background-color: #f9fafb;
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.tracking-wide {
    letter-spacing: 0.1em;
}

/* Hex Preview for Modal */
.hex-preview {
    width: 30px; height: 34px;
    background-color: #ccc;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 0.8rem;
}
.hex-preview.green { background: var(--hw-green); }
.hex-preview.yellow { background: var(--hw-yellow); }
.hex-preview.gray { background: var(--hw-gray); }

/* Direction Arrows Legend */
.directions-legend {
    max-width: 500px;
    margin: 0 auto;
}

.direction-arrow {
    width: 40px;
    height: 40px;
    position: relative;
}

.direction-arrow.horizontal::after {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 100%;
    height: 3px;
    background: #6366f1;
    transform: translateY(-50%);
}

.direction-arrow.horizontal::before {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    width: 0;
    height: 0;
    border-left: 8px solid #6366f1;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    transform: translateY(-50%);
}

.direction-arrow.vertical::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    width: 3px;
    height: 100%;
    background: #10b981;
    transform: translateX(-50%);
}

.direction-arrow.vertical::before {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 0;
    width: 0;
    height: 0;
    border-top: 8px solid #10b981;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    transform: translateX(-50%);
}

.direction-arrow.diagonal::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 3px;
    background: #f59e0b;
    transform: rotate(-45deg);
    transform-origin: left bottom;
}

.direction-arrow.diagonal::before {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    width: 0;
    height: 0;
    border-left: 8px solid #f59e0b;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    transform: rotate(-45deg);
}
