body {
    background-color: black;
    margin: auto;
    color: azure;
    overflow: hidden;
    font-family: "Lucida Console", monospace;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

#hexes {
    position: fixed;
    left: 50%;
    top: 50%;
    height: 0;
    width: 0;
    overflow: visible;
    transform-origin: center center;
}

.hex {
    position: absolute;
    width: 240px;
    height: 276px;
    margin-left: -120px;
    margin-top: -138px;
    user-select: none;
    opacity: 0;
    transition: transform 0.5s, left 0.5s, top 0.5s, opacity 0.5s;
    z-index: 2;
    will-change: transform, top, left, opacity;
}

.hex img {
    width: 240px;
    height: 276px;
}

/* The image wrapper applies the clip path so the image is hex-shaped,
   but the container remains a square to hold the knob */
.hex-inner {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    z-index: 1;
}

/* --- STACKED HEX / KNOB STYLING --- */
.knob-container {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 300px;
    height: 300px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.3s;
}

.hex.centered .knob-container {
    opacity: 1;
    pointer-events: auto;
}

.knob-track {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px dashed rgba(255, 255, 255, 0.25);
    box-sizing: border-box;
}

.knob-tick {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.knob-hint {
    position: absolute;
    bottom: -28px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s;
}

.hex.centered .knob-hint {
    opacity: 1;
    animation: hintFade 3s ease-in-out forwards;
}

@keyframes hintFade {
    0% { opacity: 0; }
    15% { opacity: 1; }
    70% { opacity: 1; }
    100% { opacity: 0; }
}

.knob {
    position: absolute;
    top: 0;
    left: 50%;
    width: 30px;
    height: 30px;
    background-color: white;
    border-radius: 50%;
    margin-left: -15px;
    margin-top: -15px;
    cursor: grab;
    box-shadow: 0 0 10px white;
    pointer-events: auto;
}

.hex.centered .knob {
    animation: knobPulse 1.5s ease-in-out 0.3s 2;
}

@keyframes knobPulse {
    0% { box-shadow: 0 0 10px white; }
    50% { box-shadow: 0 0 20px #00ffff, 0 0 40px rgba(0, 255, 255, 0.3); }
    100% { box-shadow: 0 0 10px white; }
}

.knob:active {
    cursor: grabbing;
    background-color: #00ffff;
}

/* Center hex dimensions are half of standard hex (240/2, 276/2) */
#centerHex {
    width: 120px;
    height: 138px;
    margin-left: -60px;
    margin-top: -69px;
    cursor: pointer;
    z-index: 3;
}

#centerHex img {
    width: 100% !important;
    height: 100% !important;
}

.hex.show { opacity: 1; }
.hex img, .hex .contents { transition: opacity 0.5s; opacity: 1; }
.hex.dimmed img, .hex.dimmed .contents { opacity: 0.3; }

.hex:not(.stacked-hex):hover { transform: scale(1.1); }
.hex.link-pointer:hover { cursor: pointer; }

.contents {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 32px;
    text-align: center;
    pointer-events: none;
    z-index: 5;
    text-shadow: 0px 0px 5px black;
}

.line {
    position: absolute;
    width: 2px;
    transform-origin: 0 0;
    border-left: 6px dotted white;
    opacity: 0;
    z-index: 1;
    transition: left 0.5s, top 0.5s, height 0.5s, opacity 0.5s;
    will-change: height, top, left, opacity;
}

.hex-grow { animation: grow 0.5s; }
@keyframes grow { from { transform: scale(0); } to { transform: scale(1); } }

/* --- GAME HEX --- */
.hex:not(.dimmed) .game-hex {
    animation: gameGlow 2s ease-in-out infinite;
}

@keyframes gameGlow {
    0% { filter: drop-shadow(0 0 8px rgba(0, 255, 255, 0.3)); }
    50% { filter: drop-shadow(0 0 20px rgba(0, 255, 255, 0.7)); }
    100% { filter: drop-shadow(0 0 8px rgba(0, 255, 255, 0.3)); }
}

/* --- INFO HEX --- */
.info-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    width: 360px;
    max-height: 400px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.92);
    border: 2px solid rgba(240, 255, 255, 0.4);
    border-radius: 8px;
    padding: 24px;
    font-size: 16px;
    color: azure;
    font-family: "Lucida Console", monospace;
    z-index: 20;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s, transform 0.4s;
}

.info-panel.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

.info-panel h3 {
    font-size: 14px;
    color: #00ffff;
    margin: 16px 0 6px 0;
    letter-spacing: 2px;
}

.info-panel h3:first-child {
    margin-top: 0;
}

.info-panel p {
    margin: 0 0 8px 0;
    line-height: 1.5;
    font-size: 14px;
}

/* --- TIMER HEX --- */
.timer-value {
    font-size: 22px;
    color: #00ffff;
    display: block;
    margin-top: 4px;
}

#footer {
    position: fixed;
    bottom: 10px;
    right: 10px;
    font-size: 28px;
    color: #B3B3B3;
    pointer-events: none;
}

#notification {
    position: fixed;
    top: 10px;
    left: 10px;
    background-color: black;
    color: white;
    padding: 10px;
    border: 2px solid white;
    font-size: 20px;
    z-index: 10000;
    opacity: 0;
    transition: opacity 1s ease-in-out;
    pointer-events: none;
}

#clearStorageButton {
    margin-top: 10px;
    padding: 5px 10px;
    font-size: 16px;
    font-family: "Lucida Console", monospace;
    background-color: white;
    color: black;
    border: none;
    cursor: pointer;
    display: block;
    margin-left: auto;
    margin-right: auto;
}
