/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    position: fixed;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #0a0a0b 0%, #1a1a1f 50%, #0f0f12 100%) fixed;
    background-color: #121213;
    color: #ffffff;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    overflow: hidden;
    margin: 0;
}

.container {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    max-height: 100vh;
    overflow: hidden;
    padding-bottom: 10px;
}

/* Header */
header {
    position: relative;
    text-align: center;
    border-bottom: 1px solid #3a3a3c;
    width: 100%;
    padding-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.new-btn {
    position: absolute;
    left: 0;
    background-color: #c9b458;
    border: none;
    border-radius: 4px;
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    padding: 8px 16px;
    transition: background-color 0.2s, transform 0.1s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.new-btn:hover {
    background-color: #b8a347;
}

.new-btn:active {
    transform: scale(0.95);
    background-color: #a89236;
}

header h1 {
    font-size: 37px;
    font-weight: 700;
    letter-spacing: 0.2em;
    color: #ffffff;
    margin: 0;
}

/* Game Board */
.game-board {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 420px;
    flex-shrink: 0;
}

.row {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.tile {
    width: 68px;
    height: 68px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    background-color: rgba(31, 41, 55, 0.6);
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 32px;
    font-weight: 700;
    text-transform: uppercase;
    color: #ffffff;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.tile.filled {
    border-color: rgba(255, 255, 255, 0.4);
    animation: pop 0.15s;
}

.tile.correct {
    background-color: #3B82F6;
    border-color: #3B82F6;
    color: #ffffff;
}

.tile.present {
    background-color: #8B5CF6;
    border-color: #8B5CF6;
    color: #ffffff;
}

.tile.absent {
    background-color: #787c7e;
    border-color: #787c7e;
    color: #ffffff;
}

.tile.flip {
    animation: flip 0.6s ease-in-out;
}

.tile.shake {
    animation: shake 0.5s;
}

/* Animations */
@keyframes pop {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes flip {
    0% {
        transform: rotateX(0);
    }
    50% {
        transform: rotateX(90deg);
    }
    100% {
        transform: rotateX(0);
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

/* Keyboard */
.keyboard {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    max-width: 500px;
    padding: 0 8px;
    margin-top: 10px;
    flex-shrink: 0;
}

.keyboard-row {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.key {
    flex: 1;
    min-width: 0;
    height: 58px;
    border: none;
    border-radius: 8px;
    background-color: rgba(107, 114, 128, 0.8);
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.key:hover {
    background-color: rgba(107, 114, 128, 1);
    transform: translateY(-2px);
}

.key:active {
    opacity: 0.8;
    transform: translateY(0);
}

.key.key-enter,
.key.key-backspace {
    flex: 1.5;
    font-size: 12px;
    font-weight: 600;
}

.key.correct {
    background-color: #3B82F6;
    color: #ffffff;
}

.key.present {
    background-color: #8B5CF6;
    color: #ffffff;
}

.key.absent {
    background-color: #3a3a3c;
    color: #ffffff;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    cursor: pointer;
}

.modal-content {
    position: relative;
    background-color: #121213;
    border: 2px solid #3a3a3c;
    border-radius: 8px;
    padding: 30px;
    max-width: 90%;
    width: 400px;
    text-align: center;
    z-index: 1001;
    max-height: 90vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: #ffffff;
    font-size: 32px;
    font-weight: 300;
    line-height: 1;
    cursor: pointer;
    padding: 5px 10px;
    transition: opacity 0.2s;
    z-index: 1002;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close-btn:hover {
    opacity: 0.7;
}

.modal-close-btn:active {
    opacity: 0.5;
}

.modal-content h2 {
    margin-bottom: 15px;
    font-size: 24px;
}

.modal-content p {
    margin-bottom: 20px;
    color: #d7dadc;
}

.modal-content input {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    text-align: center;
    text-transform: uppercase;
    background-color: #121213;
    border: 2px solid #3a3a3c;
    border-radius: 4px;
    color: #ffffff;
    margin-bottom: 20px;
    letter-spacing: 0.2em;
}

.modal-content input:focus {
    outline: none;
    border-color: #565758;
    font-size: 16px;
}

.link-display input:focus {
    font-size: 14px;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-primary,
.btn-secondary {
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 700;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.btn-primary {
    background-color: #3B82F6;
    color: #ffffff;
}

.btn-primary:hover {
    background-color: #2563EB;
}

.btn-secondary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #5568d3 0%, #653a8e 100%);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.btn-primary:active,
.btn-secondary:active {
    transform: scale(0.95);
}

/* Share Link Container */
.share-link-container {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.share-link-container.hidden {
    display: none;
}

.link-display {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.link-display input {
    flex: 1;
    padding: 8px;
    font-size: 14px;
    background-color: #1a1a1b;
    border: 1px solid #3a3a3c;
    border-radius: 4px;
    color: #ffffff;
    text-align: left;
    letter-spacing: normal;
    margin: 0;
}

.btn-copy {
    padding: 8px 16px;
    font-size: 14px;
    background-color: #818384;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-copy:hover {
    background-color: #6b6d6f;
}

/* Result Grid */
.result-grid {
    margin: 20px 0;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
    background-color: #1a1a1b;
    padding: 15px;
    border-radius: 4px;
    text-align: left;
}

/* View Results Button */
.view-results-btn {
    padding: 14px 28px;
    font-size: 18px;
    font-weight: 700;
    border: none;
    border-radius: 6px;
    background-color: #3B82F6;
    color: #ffffff;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    margin-top: 20px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.view-results-btn:hover {
    background-color: #2563EB;
}

.view-results-btn:active {
    transform: scale(0.95);
}

.view-results-btn.hidden {
    display: none;
}

/* Not a Word Message */
.not-a-word-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #ffffff;
    color: #121213;
    padding: 16px 32px;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 700;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    animation: fadeInOut 2s ease-in-out;
}

.not-a-word-message.hidden {
    display: none;
}

@keyframes fadeInOut {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    10% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    90% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
}

/* Confetti */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: #3B82F6;
    top: 50%;
    left: 50%;
    opacity: 1;
    border-radius: 2px;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

@keyframes confetti-shoot {
    0% {
        transform: translate(0, 0) rotate(0deg) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx), var(--ty)) rotate(720deg) scale(0);
        opacity: 0;
    }
}

.hidden {
    display: none !important;
}

/* Mobile-only optimizations */
@media (max-width: 768px) {
    .game-card {
        padding: 24px 16px;
        border-radius: 20px;
    }

    .tile {
        width: 60px;
        height: 60px;
        font-size: 28px;
    }

    .game-header h1 {
        font-size: 36px;
    }

    .modal-content {
        padding: 24px;
        width: 95%;
        border-radius: 16px;
    }

    .key {
        height: 52px;
        font-size: 13px;
    }

    .key.key-enter,
    .key.key-backspace {
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .tile {
        width: 54px;
        height: 54px;
        font-size: 26px;
    }

    .game-header h1 {
        font-size: 32px;
    }

    .tagline {
        font-size: 12px;
    }

    .modal-content {
        padding: 20px;
        width: 95%;
    }

    .key {
        height: 50px;
        font-size: 12px;
    }

    .key.key-enter,
    .key.key-backspace {
        font-size: 10px;
    }

    .game-board {
        gap: 8px;
    }

    .row {
        gap: 8px;
    }
}

@media (max-width: 360px) {
    .tile {
        width: 48px;
        height: 48px;
        font-size: 24px;
    }

    .game-header h1 {
        font-size: 28px;
    }

    .key {
        height: 48px;
        font-size: 11px;
    }

    .key.key-enter,
    .key.key-backspace {
        font-size: 9px;
    }
}

/* Hide on desktop - mobile only */
@media (min-width: 769px) {
    body::before {
        content: "This game is optimized for mobile devices only. Please use a mobile device to play.";
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: #0f172a;
        color: #ffffff;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        padding: 20px;
        z-index: 10000;
        font-size: 18px;
        font-family: 'Inter', sans-serif;
    }
}
