body {
    background-color: #1a0b0f;
    color: #ffb3b3;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    margin: 0;
    scrollbar-gutter: stable;
    overflow-x: hidden;
}

h1 {
    color: #ff3333;
    text-shadow: 0 0 10px #ff0000;
    margin-bottom: 5px;
    text-align: center;
    font-size: clamp(1.5rem, 4vw, 2.2rem);
}

p.subtitle {
    margin-top: 0;
    margin-bottom: 20px;
    font-style: italic;
    color: #cc8888;
    font-size: clamp(0.85rem, 2.5vw, 1.1rem);
}

/* Container for the image and the board */
#game-container {
    position: relative;
    width: min(92vw, 600px, 85vh);
    height: min(92vw, 600px, 85vh);
    container-type: inline-size;
    box-shadow: 0 0 30px rgba(255, 0, 0, 0.3);
    border: 2px solid #5a1010;
    border-radius: 10px;
    overflow: hidden;
    background-color: #000;
}

#game-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    user-select: none;
    pointer-events: none;
}

#ronova-img,
#ronova-smile-img {
    position: absolute;
    top: 0;
    left: 0;
}

#ronova-smile-img {
    opacity: 0;
}

#game-container.win {
    box-shadow: 0 0 60px 15px rgba(255, 0, 0, 0.85);
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-7px); }
    40% { transform: translateX(7px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

/* The Tic-Tac-Toe Grid drawn as 4 simple lines on the upper forehead */
#board {
    position: absolute;
    top: 12%;     /* Positioned lower on the forehead */
    left: 36%;    /* Tightened the horizontal centering */
    width: 28%;   /* Made narrower */
    height: 18%;  /* Made shorter to completely clear the eyebrows/eyes */
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 0;
    background-image:
        linear-gradient(rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.8)),
        linear-gradient(rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.8)),
        linear-gradient(rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.8)),
        linear-gradient(rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.8));
    background-size: 2px 100%, 2px 100%, 100% 2px, 100% 2px;
    background-position: 33.33% 0, 66.66% 0, 0 33.33%, 0 66.66%;
    background-repeat: no-repeat;
}

#win-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
    z-index: 2;
}

#win-line line {
    stroke-width: 3px;
    stroke-linecap: round;
    opacity: 0;
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.8));
}

#win-line.show line {
    opacity: 1;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 0.4s ease 0.15s, opacity 0.15s;
}

.cell {
    background-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4cqw; /* Smaller X/O so they never stretch the grid */
    font-weight: bold;
    font-family: 'Courier New', Courier, monospace;
    line-height: 1;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    cursor: pointer;
    transition: background-color 0.2s;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

.cell:hover {
    background-color: rgba(255, 0, 0, 0.1);
}

.cell.x {
    color: #ffffff; /* Mortal player is White X */
}

.cell.o {
    color: #ff1a1a; /* Ronova is Blood Red O */
}

#message {
    margin-top: 20px;
    font-size: clamp(1rem, 3vw, 1.5rem);
    font-weight: bold;
    min-height: 2rem;
    color: #ff4d4d;
    text-align: center;
}

#scoreboard {
    margin-top: 10px;
    font-size: clamp(0.8rem, 2vw, 1rem);
    color: #cc8888;
    letter-spacing: 1px;
}

#difficulty {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    font-size: clamp(0.85rem, 2.2vw, 1rem);
    color: #cc8888;
}

.difficulty-btn {
    margin-top: 0;
    padding: 5px 14px;
    font-size: clamp(0.8rem, 2vw, 0.95rem);
    background-color: #2a0a0a;
    color: #cc8888;
    border: 1px solid #5a1010;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
}

.difficulty-btn:hover {
    background-color: #4a0909;
    color: white;
}

.difficulty-btn.active {
    background-color: #ff3333;
    color: black;
    border-color: #ff3333;
    box-shadow: 0 0 12px #ff0000;
}

button {
    margin-top: 15px;
    padding: 10px 20px;
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    background-color: #4a0909;
    color: white;
    border: 1px solid #ff3333;
    cursor: pointer;
    border-radius: 5px;
    transition: all 0.3s;
}

button:hover {
    background-color: #ff3333;
    color: black;
    box-shadow: 0 0 15px #ff0000;
}
