* {
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --accent: black;
    --bg-gradient-start: #f0f9ff;
    --bg-gradient-end: #e0f2fe;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.app {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    padding: 3dvmin;
    overflow: hidden;
}

.card {
    background: var(--card-bg);
    border-radius: 2.5dvmin;
    box-shadow: var(--shadow-xl);
    display: flex;
    justify-content: center;
    width: 100%;
    height: 100%;
    max-height: 100%;
    padding: 4dvmin;
    position: relative;
    overflow-y: auto;
}

.landing {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 3dvh;
    padding: 5dvh 2dvw;
}

.landing h1 {
    font-size: clamp(4dvmin, 5vw, 7dvmin);
    font-weight: 700;
    margin: 0;
    background: var(--accent);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.landing h3 {
    font-size: clamp(2dvmin, 2.5vw, 2.5dvmin);
    font-weight: 400;
    color: var(--text-secondary);
    margin: 0;
}

.subtitle {
    color: var(--text-secondary);
}

.btn {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 1.5dvmin;
    padding: 2dvh 4dvw;
    font-size: 2.25dvmin;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-md);
}

.btn:hover {
    background: var(--primary-dark);
    transform: translateY(-0.3dvmin);
    box-shadow: var(--shadow-lg);
}

.btn:active {
    transform: translateY(0);
}

.loading {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3dvh;
    padding: 8dvh 2dvw;
}

.spinner {
    width: 6dvmin;
    height: 6dvmin;
    border: 0.8dvmin solid var(--border);
    border-top: 0.8dvmin solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    font-size: 2.25dvmin;
    font-weight: 500;
    color: var(--text-secondary);
}

.game-view {
    display: none;
    flex-direction: column;
    gap: 2dvmin;
    height: 100%;
}

.top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2dvw;
    padding-bottom: 2dvmin;
    border-bottom: 0.4dvmin solid var(--border);
    flex-shrink: 0;
}

.location {
    font-size: clamp(3dvmin, 4vw, 4dvmin);
    font-weight: 700;
    color: var(--text-primary);
}

.progress {
    font-size: clamp(1.75dvmin, 2vw, 2dvmin);
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-gradient-start);
    padding: 1dvh 2dvw;
    border-radius: 4dvmin;
}

.main {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2dvmin;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    justify-items: center;
}

.carousel-container {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2dvw;
}

.carousel-img-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-height: 50dvh;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.carousel-img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    border-radius: 2dvmin;
    box-shadow: var(--shadow-lg);
}

.carousel-controls {
    display: contents;
}

.arrow {
    background: rgba(255, 255, 255, 0.95);
    border: none;
    border-radius: 50%;
    width: 6dvmin;
    height: 6dvmin;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 3dvmin;
    color: var(--text-primary);
    box-shadow: var(--shadow-md);
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.arrow:hover {
    background: white;
    transform: scale(1.1);
    box-shadow: var(--shadow-lg);
}

.arrow:active {
    transform: scale(0.95);
}

.info {
    display: flex;
    flex-direction: column;
    gap: 2dvmin;
    justify-content: center;
}

.info table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--card-bg);
    overflow: hidden;
}

.info table tr {
    border-bottom: 0.2dvmin solid var(--border);
}

.info table tr:last-child {
    border-bottom: none;
}

.info th,
.info td {
    padding: 2dvh 1vw;
    text-align: left;
}

.info th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 1.75dvmin;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    width: 40%;
}

.info td {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 2dvmin;
}

.guess-container {
    display: flex;
    flex-direction: column;
    gap: 1dvmin;
}

.guess-grid {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto auto auto;
    gap: 1dvmin 1dvw;
    align-items: center;
}

.guess-label {
    grid-column: 1 / 4;
    grid-row: 1;
    font-size: 1.75dvmin;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.prefix {
    grid-column: 1;
    grid-row: 2;
    color: var(--text-muted);
    font-size: 2.25dvmin;
    font-weight: 500;
}

.guess-grid input[type="number"] {
    grid-column: 2;
    grid-row: 2;
    width: 100%;
    padding: 1.75dvh 2dvw;
    border: 0.4dvmin solid var(--border);
    border-radius: 1dvmin;
    font-size: 2.25dvmin;
    font-weight: 500;
    text-align: right;
    transition: all 0.2s ease;
}

.guess-grid input[type="number"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 0.6dvmin rgba(37, 99, 235, 0.1);
}

.suffix {
    grid-column: 3;
    grid-row: 2;
    color: var(--text-muted);
    font-size: 1.75dvmin;
    font-weight: 500;
    white-space: nowrap;
}

.submit {
    grid-column: 1 / 4;
    grid-row: 4;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 1dvmin;
    padding: 1.75dvh 3dvw;
    font-size: 2dvmin;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    width: 100%;
}

.submit:hover {
    background: var(--primary-dark);
}

.error-message {
    grid-column: 1 / 4;
    grid-row: 3;
    color: #ef4444;
    font-size: 1.75dvmin;
    visibility: hidden;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(0.8dvmin);
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 2dvmin;
}

.modal {
    background: white;
    border-radius: 2.5dvmin;
    box-shadow: var(--shadow-xl);
    padding: 4dvmin;
    max-width: 50dvmin;
    width: 100%;
}

.modal h3 {
    margin: 0 0 3dvh 0;
    font-size: 3dvmin;
    font-weight: 700;
    color: var(--text-primary);
}

.modal table {
    width: 100%;
    margin-bottom: 3dvh;
    border-collapse: separate;
    border-spacing: 0;
    border: 0.2dvmin solid var(--border);
    border-radius: 1dvmin;
    overflow: hidden;
}

.modal table tr {
    border-bottom: 0.2dvmin solid var(--border);
}

.modal table tr:last-child {
    border-bottom: none;
}

.modal th,
.modal td {
    padding: 1.75dvh 2dvw;
    text-align: left;
}

.modal th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 1.75dvmin;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.modal td {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 2.25dvmin;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
}

.results {
    display: none;
    flex-direction: column;
    gap: 5dvh;
    justify-content: space-evenly;
    width: 100%;
}

.results-heading {
    font-size: 4dvmin;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
}

.result-list {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1.5dvh 4dvw;
    border-radius: 2dvmin;
}

.result-item {
    background: white;
    display: grid;
    gap: 0.5dvh 0dvw;
    justify-content: space-between;
}

.result-item-left {
    grid-column: 1;
}

.result-item-right {
    grid-column: 2;
    justify-self: end;
}

.result-item-bold {
    font-weight: 700;
    font-size: 2.25dvmin;
    color: var(--text-primary);
}

.result-item-default {
    font-size: 1.75dvmin;
    color: var(--text-secondary);
}

.results-footer {
    display: flex;
    flex-direction: column;
}

.share-container {
    position: relative;
    display: flex;
    justify-content: center;
}

#copied-modal {
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-primary);
    color: white;
    padding: 1.5dvh 3dvw;
    border-radius: 1dvmin;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

#copied-modal[aria-hidden="false"] {
    opacity: 1;
}

.copied-modal-content {
    font-weight: bold;
}

@media (min-width: 1000px) {
    .card {
        padding: 5dvmin;
    }

    .main {
        grid-template-columns: 2.2fr 1fr;
        gap: 5dvw;
    }

    .top-row {
        grid-column: 1 / 3;
    }

    .carousel-img-container {
        height: 55dvh;
    }
}

@media (max-width: 1000px) {
    .app {
        padding: 2dvmin;
        height: 100vh;
        height: 100dvh;
    }

    .game-view {
        flex: 1;
        min-height: 0;
    }

    .main {
        gap: 1.5dvmin;
    }

    .top-row {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 2dvw;
        flex-shrink: 0;
        padding-bottom: 1.5dvmin;
    }

    .carousel-container {
        flex-direction: row;
        gap: 2dvw;
    }

    .carousel-controls {
        display: contents;
    }

    .carousel-img-container {
        max-height: 35dvh;
    }

    .arrow {
        width: 5dvmin;
        height: 5dvmin;
        font-size: 2.5dvmin;
    }

    .info {
        gap: 1.5dvmin;
    }

    .guess-grid {
        grid-template-columns: auto 1fr auto;
        grid-template-rows: auto auto auto auto;
    }

    .guess-label {
        grid-column: 1 / 4;
    }

    .prefix {
        grid-column: 1;
        grid-row: 2;
    }

    .guess-grid input[type="number"] {
        grid-column: 2;
        grid-row: 2;
    }

    .suffix {
        grid-column: 3;
        grid-row: 2;
        text-align: left;
        margin-top: 0;
    }

    .submit {
        grid-column: 1 / 4;
        grid-row: 4;
        margin-left: 0;
        width: 100%;
    }

    .error-message {
        grid-column: 1 / 4;
        grid-row: 3;
    }

    .result-list {
        gap: 2dvh 2dvw;
    }
}