@import url('https://fonts.googleapis.com/css2?family=Bungee&family=Plus+Jakarta+Sans:wght@400;600;700&display=swap');

:root {
    --ink: #231f1a;
    --ink-muted: #6a6259;
    --primary: #2f6f7e;
    --primary-dark: #1f4d57;
    --accent: #ff8a4c;
    --accent-dark: #e06f33;
    --surface: #fffaf4;
    --surface-muted: #f2efe8;
    --banner: #f7e1b5;
    --banner-edge: #e7b96c;
    --success: #2a9d8f;
    --danger: #e76f51;
    --glow: rgba(255, 138, 76, 0.35);
    --shadow: rgba(35, 31, 26, 0.25);
}

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

body {
    font-family: 'Plus Jakarta Sans', 'Trebuchet MS', sans-serif;
    background:
        radial-gradient(circle at 20% 20%, rgba(255, 138, 76, 0.18), transparent 45%),
        radial-gradient(circle at 80% 10%, rgba(47, 111, 126, 0.25), transparent 50%),
        linear-gradient(120deg, #fff4e4 0%, #f0f7f7 55%, #f8efe5 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: var(--ink);
}

.container {
    max-width: 900px;
    width: 100%;
    background: var(--surface);
    border-radius: 24px;
    box-shadow: 0 25px 60px var(--shadow);
    overflow: hidden;
    border: 1px solid rgba(19, 34, 58, 0.08);
}

/* Ad Banners */
.ad-banner {
    background: linear-gradient(135deg, var(--banner) 0%, #ffe3a6 100%);
    padding: 15px;
    text-align: center;
    font-weight: bold;
    color: var(--ink);
    border-bottom: 2px solid var(--banner-edge);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.85em;
}

.ad-bottom {
    border-bottom: none;
    border-top: 2px solid var(--banner-edge);
}

/* Header */
header {
    background:
        radial-gradient(circle at 20% 0%, rgba(255, 255, 255, 0.35), transparent 45%),
        linear-gradient(135deg, #2f6f7e 0%, #3a8c96 50%, #ff8a4c 100%);
    color: #fff6ea;
    text-align: center;
    padding: 36px 20px 40px;
}

header h1 {
    font-family: 'Bungee', 'Trebuchet MS', sans-serif;
    font-size: 3em;
    letter-spacing: 2px;
    text-shadow: 0 8px 18px rgba(35, 31, 26, 0.35);
    animation: popIn 0.6s ease-out;
}

/* Main Game Area */
main {
    padding: 30px 20px;
}

.game-area {
    display: grid;
    grid-template-columns: minmax(280px, 400px) minmax(0, 1fr);
    gap: 30px;
    align-items: start;
}

.left-panel {
    display: grid;
    gap: 18px;
}

.hangman-display {
    background:
        radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.6), transparent 45%),
        linear-gradient(160deg, #fff0dc 0%, #f4fbfb 100%);
    border-radius: 22px;
    padding: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 18px 36px rgba(35, 31, 26, 0.18);
    border: 1px solid rgba(35, 31, 26, 0.1);
}

#hangman-svg {
    filter: drop-shadow(0 12px 18px rgba(35, 31, 26, 0.25));
    animation: float 4s ease-in-out infinite;
}

#hangman-svg .jerry-head {
    transform-origin: center;
    transform-box: fill-box;
    animation: nod 5.5s ease-in-out infinite;
}

#hangman-svg .jerry-eye {
    transform-origin: center;
    transform-box: fill-box;
    animation: blink 4.8s ease-in-out infinite;
}

#hangman-svg .jerry-smile {
    transform-origin: center;
    transform-box: fill-box;
    animation: grin 6s ease-in-out infinite;
}

#hangman-svg.taunt .jerry-head {
    animation: tauntWobble 0.8s ease-in-out;
}

#hangman-svg.taunt .jerry-smile {
    animation: tauntGrin 0.8s ease-in-out;
}

.game-info {
    min-width: 300px;
    background: #fffef9;
    border-radius: 20px;
    padding: 20px;
    border: 1px solid rgba(35, 31, 26, 0.08);
    box-shadow: 0 12px 28px rgba(35, 31, 26, 0.1);
}

.game-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
    padding: 14px;
    background: var(--surface-muted);
    border-radius: 14px;
    border: 1px solid rgba(35, 31, 26, 0.08);
}

.control {
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-align: center;
}

.control label,
.control .label {
    font-size: 0.85em;
    color: var(--ink-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.control .value {
    font-size: 1.25em;
    font-weight: 700;
    color: var(--ink);
}

.select-control {
    appearance: none;
    border: 1px solid rgba(35, 31, 26, 0.12);
    border-radius: 10px;
    padding: 8px 12px;
    font-weight: 600;
    background: #fff;
    color: var(--ink);
    box-shadow: inset 0 0 0 1px rgba(35, 31, 26, 0.04);
}

.category-display {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-weight: 700;
    color: var(--ink);
}

.category-display .value {
    background: #e7f3f6;
    color: #1f7a8c;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.9em;
}

/* Word Display */
.word-display {
    font-size: 2.5em;
    letter-spacing: 10px;
    text-align: center;
    margin-bottom: 30px;
    font-weight: bold;
    color: var(--ink);
    min-height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    text-shadow: 0 6px 14px rgba(35, 31, 26, 0.12);
    flex-wrap: wrap;
    row-gap: 6px;
}

/* Game Stats */
.game-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
    padding: 15px;
    background: var(--surface-muted);
    border-radius: 14px;
    border: 1px solid rgba(19, 34, 58, 0.08);
}

.stat {
    text-align: center;
}

.stat .label {
    display: block;
    font-size: 0.9em;
    color: var(--ink-muted);
    margin-bottom: 5px;
}

.stat .value {
    display: block;
    font-size: 1.5em;
    font-weight: bold;
    color: var(--ink);
}

/* Letters Used */
.letters-used {
    margin-bottom: 20px;
}

.letters-used p {
    margin-bottom: 10px;
    color: var(--ink-muted);
}

#used-letters {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    min-height: 30px;
}

.used-letter {
    padding: 5px 10px;
    background: #e3edf2;
    border-radius: 999px;
    font-weight: bold;
    color: var(--ink);
}

.used-letter.power-grey {
    background: #e0e5ea;
    color: #6b7882;
}

.boosts {
    background: #fff6ee;
    border: 1px solid rgba(255, 122, 89, 0.25);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: 0 10px 22px rgba(255, 122, 89, 0.1);
}

.boost-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.boost-title {
    font-weight: 700;
    color: #7a3a24;
}

.meter {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.pip {
    flex: 1;
    height: 12px;
    border-radius: 999px;
    background: rgba(122, 58, 36, 0.2);
    box-shadow: inset 0 0 0 1px rgba(122, 58, 36, 0.2);
}

.pip.active {
    background: linear-gradient(135deg, #ff7a59 0%, #ff9a5c 100%);
    box-shadow: 0 0 12px var(--glow);
}

.meter.ready .pip.active {
    animation: pulse 0.9s ease-in-out infinite;
}

.boost-message {
    font-size: 0.9em;
    color: #7a3a24;
    min-height: 18px;
}

.coin {
    width: 48px;
    height: 48px;
    margin: 6px auto 8px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s ease;
}

.coin .coin-face {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.1em;
    color: #7a3a24;
    backface-visibility: hidden;
    border: 2px solid #e0b07e;
    background: radial-gradient(circle at 30% 30%, #ffe8c9, #f5c98a 65%, #e2a55e 100%);
    box-shadow: inset 0 0 10px rgba(122, 58, 36, 0.18), 0 6px 12px rgba(122, 58, 36, 0.18);
}

.coin .coin-face[data-face="tails"] {
    transform: rotateY(180deg);
    background: radial-gradient(circle at 30% 30%, #fff1dc, #f7d6a5 60%, #e4a763 100%);
}

.coin.flip {
    animation: coinFlip 0.8s ease-out;
}

.coin.flip.heads {
    transform: rotateY(720deg);
}

.coin.flip.tails {
    transform: rotateY(900deg);
}

.coin.heads-success .coin-face {
    box-shadow: 0 0 18px rgba(42, 157, 143, 0.6), inset 0 0 10px rgba(42, 157, 143, 0.35);
    border-color: rgba(42, 157, 143, 0.75);
}

.coin.tails-fail {
    animation: coinShake 0.45s ease-out;
}

.boost-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin-top: 8px;
}

.boost-btn {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(122, 58, 36, 0.25);
    background: #fff2e6;
    color: #7a3a24;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    touch-action: manipulation;
}

.boost-btn:hover:not(:disabled) {
    background: #ffe4d0;
    transform: translateY(-1px);
    box-shadow: 0 8px 14px rgba(122, 58, 36, 0.18);
}

.boost-btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
    background: #f1e7dd;
}

/* Keyboard */
.keyboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(40px, 1fr));
    gap: 8px;
    margin-bottom: 20px;
}

.key {
    padding: 12px;
    background: var(--primary);
    color: #fef6ee;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    touch-action: manipulation;
}

.key:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(19, 34, 58, 0.25);
}

.key:disabled {
    background: #b8c4cc;
    cursor: not-allowed;
    opacity: 0.5;
}

.key.correct {
    background: var(--success);
}

.key.wrong {
    background: var(--danger);
}

.key.power-grey {
    background: #cbd5dc;
    color: #51606b;
    box-shadow: none;
}

/* Game Message */
.game-message {
    text-align: center;
    padding: 20px;
    border-radius: 14px;
    margin-bottom: 20px;
    font-size: 1.3em;
    font-weight: bold;
    min-height: 70px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    border: 1px solid transparent;
}

.game-message.win {
    background: #dcf3e9;
    color: #0f4a3f;
    border-color: #bde4d4;
}

.game-message.lose {
    background: #fde6dc;
    color: #6f2c1d;
    border-color: #f6c3b4;
}

.game-message .word-reveal {
    font-size: 0.8em;
    margin-top: 10px;
    opacity: 0.8;
}

/* Buttons */
.btn-primary {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, var(--accent) 0%, #ff9a5c 100%);
    color: #2c1a12;
    border: none;
    border-radius: 10px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    touch-action: manipulation;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(19, 34, 58, 0.25);
}

/* Footer */
footer {
    background: #13223a;
    color: #fef6ee;
    text-align: center;
    padding: 20px;
    font-size: 0.9em;
}

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 2.2em;
    }

    .word-display {
        font-size: 1.9em;
        letter-spacing: 5px;
    }

    .game-area {
        grid-template-columns: 1fr;
    }

    .hangman-display {
        width: 100%;
    }

    #hangman-svg {
        width: 210px;
        height: 240px;
    }

    .keyboard {
        grid-template-columns: repeat(7, 1fr);
    }

    .key {
        padding: 10px 5px;
        font-size: 0.9em;
    }
}

@media (max-width: 520px) {
    body {
        padding: 10px;
        align-items: flex-start;
    }

    .container {
        border-radius: 18px;
    }

    header {
        padding: 20px 12px 24px;
    }

    header h1 {
        font-size: 1.9em;
    }

    main {
        padding: 16px 12px;
    }

    .game-area {
        gap: 16px;
    }

    .hangman-display {
        padding: 12px;
    }

    #hangman-svg {
        width: 180px;
        height: 210px;
    }

    .word-display {
        font-size: 1.4em;
        letter-spacing: 3px;
        margin-bottom: 16px;
        min-height: 40px;
    }

    .game-info {
        min-width: 0;
        padding: 14px;
    }

    .game-controls,
    .game-stats {
        gap: 8px;
        padding: 10px;
    }

    .control .value {
        font-size: 1.05em;
    }

    .stat .value {
        font-size: 1.2em;
    }

    .letters-used {
        margin-bottom: 12px;
    }

    .boosts {
        padding: 12px;
        margin-bottom: 12px;
    }

    .boost-message {
        min-height: 14px;
    }

    .keyboard {
        grid-template-columns: repeat(6, 1fr);
        gap: 6px;
        margin-bottom: 12px;
    }

    .key {
        padding: 8px 4px;
        font-size: 0.85em;
    }

    .boost-actions {
        grid-template-columns: 1fr;
    }

    .game-message {
        padding: 12px;
        margin-bottom: 12px;
        font-size: 1.05em;
        min-height: 48px;
    }

    .btn-primary {
        padding: 12px;
        font-size: 1em;
    }

    .ad-banner,
    footer {
        display: none;
    }
}

@media (max-width: 430px) {
    body {
        padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right))
            max(12px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    }

    header h1 {
        font-size: 1.75em;
        letter-spacing: 1px;
    }

    #hangman-svg {
        width: 170px;
        height: 200px;
    }

    .game-controls,
    .game-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .word-display {
        font-size: 1.3em;
        letter-spacing: 2px;
    }

    .keyboard {
        grid-template-columns: repeat(6, 1fr);
        gap: 5px;
    }

    .key {
        padding: 7px 4px;
        font-size: 0.8em;
    }

    .boost-btn {
        padding: 9px 10px;
        font-size: 0.9em;
    }

    .game-message {
        min-height: 44px;
    }
}

@media (max-height: 720px) {
    body {
        padding: 10px;
        align-items: flex-start;
    }

    header {
        padding: 20px 16px 24px;
    }

    main {
        padding: 16px;
    }

    .game-area {
        gap: 18px;
    }

    .hangman-display {
        padding: 12px;
    }

    #hangman-svg {
        width: 190px;
        height: 220px;
    }

    .game-message {
        min-height: 52px;
    }

    .ad-banner,
    footer {
        display: none;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes float {
    0% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-6px);
    }
    100% {
        transform: translateY(0px);
    }
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: translateY(-12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes nod {
    0%, 100% {
        transform: rotate(0deg) translateY(0);
    }
    45% {
        transform: rotate(-1deg) translateY(1px);
    }
    55% {
        transform: rotate(1deg) translateY(0);
    }
}

@keyframes blink {
    0%, 92%, 100% {
        transform: scaleY(1);
    }
    94%, 96% {
        transform: scaleY(0.15);
    }
}

@keyframes grin {
    0%, 100% {
        transform: scaleX(1);
    }
    50% {
        transform: scaleX(1.06);
    }
}

@keyframes tauntWobble {
    0% {
        transform: rotate(0deg) translateY(0);
    }
    25% {
        transform: rotate(-4deg) translateY(-2px);
    }
    50% {
        transform: rotate(4deg) translateY(-1px);
    }
    75% {
        transform: rotate(-2deg) translateY(1px);
    }
    100% {
        transform: rotate(0deg) translateY(0);
    }
}

@keyframes tauntGrin {
    0% {
        transform: scaleX(1) translateY(0);
    }
    40% {
        transform: scaleX(1.25) translateY(-1px);
    }
    100% {
        transform: scaleX(1) translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scaleX(1);
        box-shadow: 0 0 10px var(--glow);
    }
    50% {
        transform: scaleX(1.06);
        box-shadow: 0 0 16px rgba(255, 138, 76, 0.6);
    }
}

@keyframes coinFlip {
    0% {
        transform: rotateY(0deg) translateY(0);
    }
    50% {
        transform: rotateY(540deg) translateY(-6px);
    }
    100% {
        transform: rotateY(720deg) translateY(0);
    }
}

@keyframes coinShake {
    0% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-5px);
    }
    50% {
        transform: translateX(5px);
    }
    75% {
        transform: translateX(-3px);
    }
    100% {
        transform: translateX(0);
    }
}

@keyframes riseIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.game-message.win, .game-message.lose {
    animation: fadeIn 0.5s ease-out;
}
