* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background-color: #000;
    display: grid;
    place-items: center;
    overflow: auto;
    min-width: 100vw;
    min-height: 100vh;
    font-family: "Avenir Next", "Segoe UI", sans-serif;
}

html {
    font-size: 16px;
}

button {
    font: inherit;
}

#app-container {
    position: relative;
}

.phase-container {
    position: relative;
    width: 100%;
    height: 100%;
}

/* --- Main menu --- */
.menu-screen {
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 0%, #5c2a6e 0%, rgba(92, 42, 110, 0) 46%),
        linear-gradient(165deg, #24141c 0%, #120e10 55%, #0c0b0c 100%);
    color: #f6f0e4;
}

.menu-frame {
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
    padding: 1.45rem 1.7rem 1.55rem;
    background:
        linear-gradient(#c6a15b, #c6a15b) top left / 100% 1px no-repeat,
        linear-gradient(#c6a15b, #c6a15b) bottom left / 100% 1px no-repeat,
        linear-gradient(#c6a15b, #c6a15b) top left / 1px 100% no-repeat,
        linear-gradient(#c6a15b, #c6a15b) top right / 1px 100% no-repeat;
    box-shadow: inset 0 0 0 7px rgba(12, 11, 12, 0.35);
}

.menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 0.2rem 0.35rem 0.95rem;
    border-bottom: 1px solid rgba(198, 161, 91, 0.55);
}

.menu-titleblock {
    display: flex;
    align-items: center;
    gap: 2.4rem;
    min-width: 0;
}

.menu-kicker {
    margin: 0 0 0.2rem;
    font-family: Cinzel, Palatino, "Palatino Linotype", serif;
    font-size: 0.95rem;
    letter-spacing: 0.04em;
    color: #c6a15b;
}

.menu-kicker a {
    color: inherit;
    text-decoration: none;
}

.menu-kicker a:hover {
    color: #e6c669;
}

.menu-brand h1 {
    margin: 0;
    font-family: Cinzel, Palatino, "Palatino Linotype", serif;
    font-size: 3.15rem;
    font-weight: 700;
    letter-spacing: 0.045em;
    line-height: 0.95;
    color: #f7f3ea;
}

.menu-heading {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    min-width: 0;
}

.menu-heading h1 {
    margin: 0;
    max-width: 36rem;
    font-family: Cinzel, Palatino, "Palatino Linotype", serif;
    font-size: 1.7rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #f6f0e4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.menu-hint {
    margin: 0.2rem 0 0;
    font-family: "Cormorant Garamond", Palatino, "Palatino Linotype", serif;
    font-size: 1.25rem;
    font-style: italic;
    color: #e4d3a1;
}

.menu-play,
.menu-ghost {
    min-width: 8.4rem;
    padding: 0.78rem 1.25rem;
    border: 2px solid #c6a15b;
    border-radius: 2px;
    font-family: Cinzel, Palatino, "Palatino Linotype", serif;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.menu-play {
    background: #8e1b2c;
    color: #f7f3ea;
}

.menu-play:hover {
    background: #a82438;
}

.menu-ghost {
    background: transparent;
    color: #f7f3ea;
}

.menu-ghost:hover {
    background: rgba(198, 161, 91, 0.16);
}

.menu-play.disabled,
.menu-play:disabled {
    background: #3a3632;
    color: #8a8478;
    border-color: #6e6a64;
    opacity: 1;
    cursor: not-allowed;
    pointer-events: none;
}

.menu-layout {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(16rem, 22rem) minmax(0, 1fr);
    gap: 1.15rem;
    padding: 0.15rem 0.35rem 0.2rem;
}

.menu-scores {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    min-height: 0;
}

.menu-maps {
    display: grid;
    grid-template-columns: 1fr;
    align-content: start;
    gap: 0.55rem;
    min-height: 0;
    height: 100%;
    overflow-y: auto;
    padding-right: 0.15rem;
}

.map-item {
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 0.15rem;
    width: 100%;
    text-align: left;
    padding: 0.7rem 1.05rem 0.65rem;
    cursor: pointer;
    border-radius: 2px;
    border: 1px solid #c6a15b;
    background-color: #f6f0e4;
    color: #161311;
}

.map-item:hover {
    background-color: #fffaf2;
    border-color: #e0c27a;
}

.map-name {
    font-family: Cinzel, Palatino, "Palatino Linotype", serif;
    font-size: 1.28rem;
    font-weight: 500;
    letter-spacing: 0.04em;
}

.map-blurb {
    font-family: "Cormorant Garamond", Palatino, "Palatino Linotype", serif;
    font-size: 1.2rem;
    color: #5c574e;
    line-height: 1.15;
}

.map-item.selected {
    background-color: #4c1d5a;
    border-color: #c6a15b;
    color: #f6f0e4;
    box-shadow: inset 5px 0 0 #8e1b2c;
}

.map-item.selected .map-blurb {
    color: #e4d3a1;
}

.score-panel {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 0.85rem 0.95rem;
    background: #f6f0e4;
    border: 1px solid #c6a15b;
    color: #161311;
}

.score-list-title {
    text-align: center;
    font-family: Cinzel, Palatino, "Palatino Linotype", serif;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    margin-bottom: 8px;
    color: #8e1b2c;
}

.score-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.1rem 0.6rem;
    padding: 0.4rem 0.15rem;
    border-bottom: 1px solid rgba(198, 161, 91, 0.55);
    color: #161311;
    font-size: 0.95rem;
}

.score-name {
    font-weight: 650;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.score-value {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

.score-date {
    grid-column: 1 / -1;
    color: #6e6a64;
    font-size: 0.75rem;
}

.score-empty {
    text-align: center;
    color: #6e6a64;
    margin: 1.5rem 0.5rem;
}

/* --- Play screens ---
   The bar and the map are both pinned to the 1920x1080 stage.
   The map box is 16:9, so the artwork fills it and does not letterbox or drift. */
.play-screen {
    height: 100%;
}

.play-actions {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-shrink: 0;
}

.timer-readout {
    min-width: 8.4rem;
    padding: 0.78rem 1.25rem;
    border: 2px solid #c6a15b;
    border-radius: 2px;
    background: #8e1b2c;
    color: #f7f3ea;
    font-family: Cinzel, Palatino, "Palatino Linotype", serif;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.play-viewport {
    position: relative;
    flex: 1;
    min-height: 0;
    container-type: size;
    display: flex;
    align-items: center;
    justify-content: center;
}

.play-screen .map-stage {
    position: relative;
    z-index: 1;
    width: min(100cqi, calc(100cqh * 2032 / 1143));
    aspect-ratio: 2032 / 1143;
    height: auto;
    overflow: hidden;
    outline: 1px solid #c6a15b;
    background: #16324a;
}

.map-stage > svg {
    display: block;
    width: 100%;
    height: 100%;
}

#game-map-content .location {
    cursor: pointer;
}

#game-map-content .location,
#game-map-content .location > * {
    transition: fill 0.1s ease-in-out, stroke 0.1s ease-in-out, stroke-width 0.1s ease-in-out;
}

#game-map-content .location:hover,
#game-map-content .location:hover > path,
#game-map-content .location:hover > circle,
#game-map-content .location:hover > rect,
#game-map-content .location:hover > ellipse {
    fill: rgba(255, 255, 255, 0.3) !important;
    stroke: white !important;
    stroke-width: 2 !important;
}

#game-map-content .location.correct,
#game-map-content .location.correct > path,
#game-map-content .location.correct > circle,
#game-map-content .location.correct > rect,
#game-map-content .location.correct > ellipse {
    fill: rgba(46, 204, 113, 0.7) !important;
    stroke: #2ecc71 !important;
    stroke-width: 2 !important;
}

#game-map-content .location.incorrect,
#game-map-content .location.incorrect > path,
#game-map-content .location.incorrect > circle,
#game-map-content .location.incorrect > rect,
#game-map-content .location.incorrect > ellipse {
    fill: rgba(231, 76, 60, 0.7) !important;
    stroke: #e74c3c !important;
    stroke-width: 2 !important;
}

.popup-dialog {
    position: absolute;
    z-index: 8;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(34rem, 62%);
    padding: 1.5rem 1.7rem 1.35rem;
    background: #1a1218;
    color: #f6f0e4;
    border: 1px solid #c6a15b;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.result-kicker {
    margin: 0;
    font-family: Cinzel, Palatino, "Palatino Linotype", serif;
    font-size: 0.78rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: #c6a15b;
}

.result-score {
    margin: 0.25rem 0 0;
    font-family: Cinzel, Palatino, "Palatino Linotype", serif;
    font-size: 4.2rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.04em;
    color: #f7f3ea;
}

.result-meta {
    margin: 0.45rem 0 0;
    font-family: "Cormorant Garamond", Palatino, "Palatino Linotype", serif;
    font-size: 1.45rem;
    font-style: italic;
    color: #e4d3a1;
}

.username-display {
    margin: 0.9rem 0 0;
    font-size: 1.05rem;
}

.result-form {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 0.45rem 0.7rem;
    width: min(22rem, 100%);
    margin-top: 1rem;
    text-align: left;
    font-family: "Cormorant Garamond", Palatino, "Palatino Linotype", serif;
    font-size: 1.25rem;
}

.result-form input {
    width: 100%;
    padding: 0.4rem 0.55rem;
    border: 1px solid #c6a15b;
    border-radius: 2px;
    background: #f6f0e4;
    color: #161311;
    font-family: "Avenir Next", "Segoe UI", sans-serif;
    font-size: 0.95rem;
}

.result-form .class-input {
    width: 3.2rem;
}

.result-form .year-input {
    width: 5.5rem;
}

.result-pair {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.result-error {
    grid-column: 1 / -1;
    margin: 0;
    color: #e7b2a8;
    font-family: "Avenir Next", "Segoe UI", sans-serif;
    font-size: 0.85rem;
}

.result-saved {
    grid-column: 1 / -1;
    margin: 0;
    color: #e4d3a1;
    font-style: italic;
}

.popup-confirm {
    grid-column: 1 / -1;
    justify-self: center;
    min-width: 8rem;
    margin-top: 0.2rem;
}

.result-actions {
    display: flex;
    gap: 0.7rem;
    margin-top: 1.15rem;
}
