* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
    font-family: 'Luckiest Guy', cursive;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    background: #000000;
    overflow-x: hidden;
    overflow-y: auto;
    scroll-behavior: smooth;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#game-container {
    display: flex;
    flex-direction: column;
    width: 100vw;
    min-height: calc(var(--viewport-height, 100vh));
    align-items: center;
    padding-bottom: 10vmin;
}

#header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 2vmin 4vmin;
    background: transparent;
    z-index: 10;
    flex: 0 0 auto;
    height: 10vmin;
}

#game-name {
    font-size: 5vmin;
    color: #FFB300;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    cursor: pointer;
}

#game-name:focus {
    outline: 2px solid #FFB300;
}

#score {
    font-size: 4.5vmin;
    color: #FFFFFF;
    text-shadow: 1px 1px 2px #000000;
    text-align: right;
    transition: color 0.1s ease;
}

#score.deducting {
    color: #FF0000;
    animation: flashRed 0.5s ease infinite;
}

#score.adding {
    color: #50FF50;
    animation: flashGreen 0.5s ease infinite;
}

@keyframes flashRed {
    0%, 100% { color: #FF0000; }
    50% { color: #FFFFFF; }
}

@keyframes flashGreen {
    0%, 100% { color: #50FF50; }
    50% { color: #FFFFFF; }
}

#guess-section {
    display: flex;
    justify-content: center;
    width: 90vw;
    max-width: 600px;
    touch-action: manipulation;
}

#guess-area {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 12vmin;
    margin: 2vmin 0;
    background: #FFFFFF;
    border-radius: 1vmin;
    z-index: 10;
    flex: 0 0 auto;
    touch-action: manipulation;
}

#guess-input-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    background: #FFFFFF;
    border: 2px solid #FFB300;
    border-radius: 1vmin;
}

#guess-input-container.game-over {
    pointer-events: none;
    opacity: 0.5;
}

#guess-input {
    border: none;
    outline: none;
    font-family: 'Luckiest Guy', cursive;
    font-size: 5vmin;
    color: #000000;
    background: #FFFFFF;
    width: 100%;
    text-align: center;
    text-transform: uppercase;
    flex: 1;
    border-radius: 1vmin;
}

#guess-input::placeholder {
    color: #808080;
    font-size: 3.5vmin;
    animation: blink 1.5s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

#guess-input:focus {
    outline: none;
}

#guess-input:disabled {
    opacity: 0.5;
}

#guess-input-container.wrong-guess {
    animation: shakeAndFlash 0.35s ease;
}

@keyframes shakeAndFlash {
    0%, 100% { transform: translateX(0); background: #FFFFFF; }
    20%, 60% { transform: translateX(-8px); background: #FF0000; }
    40%, 80% { transform: translateX(8px); background: #FF0000; }
}

#game-number-section {
    width: 90vw;
    max-width: 600px;
    margin: 2vmin 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#game-number-text {
    font-size: 3vmin;
    color: #808080;
    text-shadow: 1px 1px 2px #000000;
    text-align: center;
}

#hints-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 90vw;
    max-width: 600px;
    margin: 0.2vmin 0;
}

#hints-container.hidden {
    display: none; /* Simplified: fully hide */
}

.hints-box {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#hints-heading {
    font-size: 4vmin;
    color: #FFB300;
    text-shadow: 1px 1px 2px #000000;
    text-align: center;
    margin: 1vmin 0;
}

#hints-list {
    font-size: 3.5vmin;
    color: #FFFFFF;
    text-shadow: 1px 1px 2px #000000;
    text-align: center;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2vmin;
    min-height: 5vmin; /* Ensure visibility from start */
}

#hints-list div {
    margin: 0 1vmin;
}

.hint-separator {
    color: #FFB300;
}

@keyframes hintBurst {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.5); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

.hint-burst {
    animation: hintBurst 0.5s ease-out;
}

#background-image-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin: 2vmin 0;
    gap: 20vmin; /* Increased gap for better arrow spacing */
    position: relative;
}

#background-image-container.hidden {
    display: none; /* Simplified: fully hide if needed, but we hide pieces individually */
}

#background-image {
    width: auto;
    height: 2.25in;
    max-width: 90vw;
    border-radius: 1vmin;
}

/* Hide image but keep arrows visible during end game */
#background-image-container.end-game #background-image {
    display: none;
}

/* Hide arrows during end game */
#background-image-container.end-game .image-arrow {
    display: none;
}

.image-arrow {
    width: 8vmin;
    height: 8vmin;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: transform 0.1s ease;
    touch-action: manipulation;
    position: relative;
    z-index: 12;
}

#prev-image-arrow::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 4vmin solid transparent;
    border-right-color: #FFB300;
}

#next-image-arrow::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 4vmin solid transparent;
    border-left-color: #FFB300;
}

.image-arrow:active::before {
    border-right-color: #E0A000;
    border-left-color: #E0A000;
}

.image-arrow.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.image-arrow.loading::before {
    border-right-color: #FFFFFF;
    border-left-color: #FFFFFF;
}

.image-arrow.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 4vmin;
    animation: spin 1s linear infinite;
}

#game-over {
    display: none; /* Hidden by default, flows in column */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 90vw;
    max-width: 600px;
    margin: 2vmin 0; /* Match surrounding spacing */
}

#game-over.active {
    display: flex; /* Show when active */
}

#share-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin-bottom: 2vmin;
    gap: 3vmin;
    position: relative;
}

#congrats-message {
    font-size: 6vmin;
    color: #FFB300;
    text-shadow: 1px 1px 2px #000000;
    text-align: center;
    margin-bottom: 2vmin;
}

#secret-word-display {
    font-size: 4vmin;
    color: #FFB300;
    text-shadow: 1px 1px 2px #000000;
    text-align: center;
    margin-bottom: 2vmin;
}

#share-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: auto;
    max-width: 80vw; /* Adjusted to fit content comfortably */
    background: #333333;
    border: 2px solid #FFB300;
    border-radius: 1vmin;
    padding: 3vmin;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3); /* Added subtle shadow for polish */
}

#share-panel.flash-border {
    animation: flashYellowBorder 1s ease-in-out 3;
}

@keyframes flashYellowBorder {
    0%, 100% { border-color: #FFB300; }
    50% { border-color: #FFFFFF; }
}

#share-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5vmin; /* Slightly increased for better spacing */
}

#share-text div {
    font-size: 3.5vmin;
    color: #FFFFFF;
    text-shadow: 1px 1px 2px #000000;
    text-align: center;
}

#share-text .guess-count {
    color: #FFB300;
}

#game-number-display {
    font-size: 3vmin;
    color: #FFFFFF;
    text-shadow: 1px 1px 2px #000000;
    margin-top: 1.5vmin;
}

#share-buttons {
    display: flex;
    justify-content: center;
    gap: 3vmin; /* Increased for better touch targets on mobile */
    margin-top: 2vmin;
}

#share-buttons a {
    display: block;
    width: 7vmin; /* Slightly larger for mobile */
    height: 7vmin;
}

#share-buttons img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#next-game-btn-end {
    margin-top: 2vmin; /* Spacing below share buttons */
}

#guesses-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 90vw;
    max-width: 600px;
    margin: 2vmin 0;
}

#guesses-section.hidden {
    display: none; /* Simplified: fully hide */
}

#guesses-title {
    font-size: 4vmin;
    color: #FFB300;
    text-shadow: 1px 1px 2px #000000;
    text-align: center;
    margin: 1vmin 0;
}

#guesses-list {
    font-size: 4.5vmin;
    color: #FFFFFF;
    text-shadow: 1px 1px 2px #000000;
    text-align: center;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2vmin;
}

#guesses-list div {
    margin: 0 1vmin;
}

.guess-separator {
    color: #FFB300;
}

#no-guesses-text {
    font-size: 4.5vmin;
    color: #FFFFFF;
    text-shadow: 1px 1px 2px #000000;
    text-align: center;
    margin: 1vmin 0;
}

#ad-box {
    width: 100%;
    height: 6vmin;
    background: #FFFFFF;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    flex: 0 0 auto;
    margin: 2vmin 0;
}

#ad-box span {
    font-size: 2.5vmin;
    color: #000000;
}

#incorrect-guess-indicator {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 15vmin;
    color: #FF0000;
    text-shadow: 2px 2px 4px #000000;
    z-index: 100;
    animation: flashIncorrect 1s ease-out forwards;
}

@keyframes flashIncorrect {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1.5); }
}

#all-games-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 90vw;
    max-width: 600px;
    margin: 4vmin 0;
}

#all-games-title {
    font-size: 4vmin;
    color: #FFB300;
    text-shadow: 1px 1px 2px #000000;
    text-align: center;
    margin: 1vmin 0;
}

#tabs {
    display: flex;
    justify-content: center;
    gap: 2vmin;
    margin: 2vmin 0;
}

.tab {
    font-size: 3.5vmin;
    color: #FFFFFF;
    text-shadow: 1px 1px 2px #000000;
    cursor: pointer;
    background: #333333;
    padding: 1vmin 3vmin;
    border-radius: 0.5vmin;
    touch-action: manipulation;
}

.tab.active {
    background: #FFB300;
    color: #000000;
    text-shadow: 1px 1px 2px #FFFFFF;
    text-decoration: underline;
}

.tab:focus {
    outline: 2px solid #FFB300;
}

.tab-seperator {
    font-size: 3.5vmin;
    color: #FFFFFF;
    text-shadow: 1px 1px 2px #000000;
}

.tab-content {
    display: none;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-height: 80vmin;
    border-radius: 1vmin;
    padding: 2vmin;
    overflow-y: auto;
}

.tab-content.active {
    display: flex;
}

.tab-content > span {
    font-size: 3.5vmin;
    color: #FFFFFF;
    text-shadow: 1px 1px 2px #000000;
    margin-bottom: 1vmin;
}

.game-list {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-height: 60vmin;
    overflow-y: auto;
}

.game-list-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 1vmin 10%;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.game-list-row span {
    font-size: 3.5vmin;
    color: #FFFFFF;
    text-shadow: 1px 1px 2px #000000;
    text-align: center;
}

.game-list-row span.result {
    color: #50FF50;
}

.game-list-row span.result.lost {
    color: #FF5050;
}

.game-list-row span.play-now {
    color: #FFB300;
    text-decoration: underline;
    cursor: pointer;
}

.control-btn {
    width: 40vw;
    max-width: 200px;
    height: 6vmin;
    min-height: 10vmin;
    background: #FFB300;
    border: none;
    border-radius: 1vmin;
    font-family: 'Luckiest Guy', cursive;
    font-size: 3vmin;
    color: #FFFFFF;
    text-shadow: 1px 1px 2px #000000;
    cursor: pointer;
    margin: 1vmin 0;
    transition: transform 0.1s ease, background 0.1s ease;
    touch-action: manipulation;
}

.control-btn:active {
    transform: scale(0.95);
    background: #E0A000;
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.control-btn.loading::after {
    content: "";
    margin-left: 1vmin;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.screen, .dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: calc(var(--viewport-height, 100vh));
    background: rgba(0, 0, 0, 0.7);
    z-index: 50;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
}

#form-container {
    display: flex;
    flex-direction: column;
    gap: 1vmin;
    width: 90vw;
    max-width: 600px;
    background: #333333;
    border-radius: 1vmin;
    padding: 2vmin;
}

#form-container input {
    height: 6vmin;
    background: #FFFFFF;
    border: none;
    border-radius: 1vmin;
    font-family: 'Luckiest Guy', cursive;
    font-size: 3.5vmin;
    color: #000000;
    padding: 0 2vmin;
    text-align: center;
    text-transform: uprising;
}

#form-container input:disabled {
    opacity: 0.5;
}

.dialog-content {
    position: relative;
    width: 90vw;
    max-width: 600px;
    background: #333333;
    border: 2px solid #FFB300;
    border-radius: 1vmin;
    padding: 2vmin;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: popIn 0.3s ease-out;
}

@keyframes popIn {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.dialog-message {
    font-size: 4vmin;
    color: #FFFFFF;
    text-shadow: 1px 1px 2px #000000;
    text-align: center;
    margin-bottom: 2vmin;
}

.pineapple-rain {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: calc(var(--viewport-height, 100vh));
    pointer-events: none;
    z-index: 1000;
}

.pineapple-piece {
    position: absolute;
    font-size: 2vmin;
    animation: fallPineapple linear forwards;
}

@keyframes fallPineapple {
    0% {
        transform: translateY(-10vmin) rotate(0deg) translateX(calc(var(--drift) * 5vw));
        opacity: 1;
    }
    80% {
        transform: translateY(calc(var(--viewport-height, 100vh) * var(--fall-distance, 0.8))) rotate(var(--rotation)) translateX(calc(var(--drift) * 5vw));
        opacity: 0.2;
    }
    100% {
        transform: translateY(calc(var(--viewport-height, 100vh) * var(--fall-distance, 0.8) + 10vmin)) rotate(var(--rotation)) translateX(calc(var(--drift) * 5vw));
        opacity: 0;
    }
}

@media screen and (max-width: 768px) {
    #game-container {
        min-height: calc(var(--viewport-height, 100vh));
    }
    #header {
        height: 10vmin;
        padding: 2vmin;
    }
    #guess-section, #guess-area {
        height: 12vmin;
        margin: 1vmin 0;
    }
    #guess-input-container {
        width: 100%;
    }
    #guess-input {
        font-size: 5vmin;
    }
    #guess-input::placeholder {
        font-size: 3.5vmin;
    }
    #game-number-text {
        font-size: 3vmin;
    }
    #hints-heading, #guesses-title, #all-games-title {
        font-size: 4vmin;
    }
    #hints-list {
        font-size: 3.5vmin;
        flex-wrap: wrap;
        gap: 1vmin;
        min-height: 5vmin;
    }
    #hints-list div {
        margin: 0 0.5vmin;
    }
    #guesses-list, #no-guesses-text {
        font-size: 4.5vmin;
        flex-wrap: wrap;
        gap: 1vmin;
    }
    #guesses-list div {
        margin: 0 0.5vmin;
    }
    #background-image {
        height: 2.25in;
        max-width: 80vw;
    }
    #share-panel {
        max-width: 70vw; /* Slightly smaller for mobile */
    }
    #share-buttons a {
        width: 8vmin; /* Larger touch targets for mobile */
        height: 8vmin;
    }
    #game-over {
        width: 80vw;
    }
}

/* Ensure Luckiest Guy applies consistently across text elements */
body,
#guess-input,
.control-btn,
#form-container input,
#hints-heading,
#hints-list,
#guesses-title,
#guesses-list,
#no-guesses-text,
#secret-word-display,
#share-text div,
#game-number-display,
#all-games-title,
.tab,
.game-list-row span,
.dialog-message,
#ad-box span,
#congrats-message {
    font-family: 'Luckiest Guy', cursive !important;
}