/*
 * Mini Games - the chrome around the court.
 *
 * Six screens share one sheet: the lobby, the waiting room for an online room,
 * the menu of mini games, the match, the result and the tournament's end. The
 * court is the only thing that fills the window; everything else is a panel with
 * a warm ink palette and one colour per seat, so a name on the menu is the same
 * colour as the paddle on the wall.
 */

:root {
    --ink: #05060b;
    --panel: #0f1220;
    --panel-2: #161a2e;
    --line: #262b48;
    --text: #f4f1ea;
    --dim: #9a94a8;
    --p1: #ff9f45;
    --p2: #9fe8ff;
    --p3: #c68bff;
    --p4: #8fe86a;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html,
body {
    margin: 0;
    height: 100%;
    background: var(--ink);
    color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    overscroll-behavior: none;
}

.app {
    position: fixed;
    /* The site bar holds the top of the window, so the court starts under it and
       the bottom wall stays on screen. `--jn-nav-height` comes from navbar.css's
       :root; 44px is the bar's own height as a fallback. */
    inset: var(--jn-nav-height, 44px) 0 0 0;
    overflow: hidden;
    background: radial-gradient(120% 90% at 50% 0%, #131a33 0%, var(--ink) 70%);
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.screen {
    position: absolute;
    inset: 0;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 20px;
    overflow: auto;
}

.app[data-screen="lobby"] .screen--lobby,
.app[data-screen="online"] .screen--online,
.app[data-screen="select"] .screen--select,
.app[data-screen="play"] .screen--play,
.app[data-screen="result"] .screen--result,
.app[data-screen="champion"] .screen--champion {
    display: flex;
}

.sheet {
    width: min(620px, 100%);
    margin: auto;
    padding: 26px 26px 22px;
    background: linear-gradient(180deg, var(--panel-2), var(--panel));
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}

.sheet--wide {
    width: min(880px, 100%);
}

.sheet--narrow {
    width: min(460px, 100%);
    text-align: center;
}

.kicker {
    margin: 0 0 6px;
    color: var(--dim);
    font-size: 0.72rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.name {
    margin: 0 0 10px;
    font-size: clamp(1.9rem, 5vw, 2.7rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.05;
}

.name--small {
    font-size: clamp(1.3rem, 3.4vw, 1.7rem);
}

/* The waiting room's code: the biggest thing on the screen, because it is the
   one thing somebody has to read off it. The indent cancels the trailing
   letter-space so the four letters sit centred under the kicker. */
.name--code {
    font-size: clamp(2.6rem, 12vw, 4.2rem);
    letter-spacing: 0.24em;
    text-indent: 0.24em;
    color: var(--p2);
    font-variant-numeric: tabular-nums;
}

/* Joining a room: the code field and the button that takes it. */
.join {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin: 14px 0 0;
}

.join .label {
    margin: 0;
}

.code-input {
    width: 7.5ch;
    padding: 8px 10px;
    background: #0a0d1a;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--text);
    font: inherit;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    text-align: center;
}

.code-input:focus {
    outline: 2px solid var(--p2);
    outline-offset: 1px;
}

.lede {
    margin: 0 0 18px;
    color: #cfc9dc;
    font-size: 0.95rem;
}

.note {
    margin: 8px 0 0;
    color: var(--dim);
    font-size: 0.8rem;
}

.label {
    margin: 0;
    color: var(--dim);
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.block {
    margin: 0 0 16px;
    padding: 14px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--line);
    border-radius: 12px;
}

.block__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.button {
    padding: 11px 18px;
    background: var(--p1);
    border: 1px solid var(--p1);
    border-radius: 999px;
    color: #170d05;
    font: inherit;
    font-weight: 650;
    cursor: pointer;
}

.button:hover {
    filter: brightness(1.1);
}

.button--ghost {
    background: transparent;
    border-color: var(--line);
    color: var(--text);
}

.button:disabled,
.tool:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.tool {
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--text);
    font: inherit;
    font-size: 0.8rem;
    cursor: pointer;
}

.tool:hover:not(:disabled) {
    border-color: var(--p2);
    color: var(--p2);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 6px;
}

.sheet--narrow .actions {
    justify-content: center;
}

.keys {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 6px 18px;
    margin: 18px 0 0;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    font-size: 0.82rem;
}

.keys div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.keys dt {
    color: var(--dim);
}

.keys dd {
    margin: 0;
}

kbd {
    display: inline-block;
    min-width: 1.5em;
    margin-left: 3px;
    padding: 1px 5px;
    background: #0a0d1a;
    border: 1px solid var(--line);
    border-bottom-width: 2px;
    border-radius: 5px;
    font: inherit;
    font-size: 0.78rem;
    text-align: center;
}

/* The seat colours: a name, a chip and a paddle are the same colour. */
[data-colour="0"] { --seat: var(--p1); }
[data-colour="1"] { --seat: var(--p2); }
[data-colour="2"] { --seat: var(--p3); }
[data-colour="3"] { --seat: var(--p4); }

/* The lobby's players. */
.players {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.player {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    background: #0a0d1a;
    border: 1px solid var(--line);
    border-left: 3px solid var(--seat);
    border-radius: 10px;
}

.player__badge {
    color: var(--seat);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.player__name {
    flex: 1;
    min-width: 0;
    padding: 6px 8px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text);
    font: inherit;
}

.player__name:focus {
    outline: none;
    background: #05060b;
    border-color: var(--line);
}

.stepper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stepper__value {
    min-width: 2.4ch;
    font-size: 1.4rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

/* The menu of mini games. */
.bar {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 4px 12px;
    margin-bottom: 14px;
}

.bar__title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
}

.bar__target {
    margin: 0;
    color: var(--dim);
    font-size: 0.82rem;
}

.seats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 16px;
    padding: 0;
    list-style: none;
}

.seat {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 6px 12px;
    background: #0a0d1a;
    border: 1px solid var(--line);
    border-radius: 999px;
}

.seat__name {
    color: var(--seat);
    font-weight: 650;
}

.seat__kind {
    color: var(--dim);
    font-size: 0.72rem;
}

.seat__points {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 12px;
}

.card {
    display: grid;
    gap: 6px;
    padding: 16px;
    background: #0a0d1a;
    border: 1px solid var(--line);
    border-radius: 14px;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.card:hover,
.card.is-picked {
    border-color: var(--p2);
    box-shadow: inset 0 0 0 1px rgba(159, 232, 255, 0.3), 0 12px 30px rgba(0, 0, 0, 0.4);
}

.card__title {
    font-size: 1.05rem;
    font-weight: 700;
}

.card__blurb {
    color: #cfc9dc;
    font-size: 0.86rem;
}

.card__rule {
    color: var(--p1);
    font-size: 0.78rem;
}

.card__keys {
    color: var(--dim);
    font-size: 0.78rem;
}

.foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 12px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.foot .note {
    margin: 0;
}

/* The match. */
.screen--play {
    padding: 0;
}

#court {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

.hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 14px;
    background: linear-gradient(180deg, rgba(5, 6, 11, 0.9), rgba(5, 6, 11, 0));
    pointer-events: none;
}

.hud > * {
    pointer-events: auto;
}

.hud__title {
    margin: 0;
    font-weight: 700;
}

.hud__rule {
    flex: 1;
    margin: 0;
    color: var(--dim);
    font-size: 0.78rem;
}

/* The result, the tournament and the pause. */
.overlay {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(3, 4, 9, 0.78);
    backdrop-filter: blur(6px);
}

.standings {
    display: grid;
    gap: 8px;
    margin: 16px 0 20px;
    padding: 0;
    list-style: none;
    text-align: left;
}

.standing {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    background: #0a0d1a;
    border: 1px solid var(--line);
    border-left: 3px solid var(--seat);
    border-radius: 10px;
}

.standing:first-child {
    border-color: var(--seat);
}

.standing__name {
    color: var(--seat);
    font-weight: 650;
}

.standing__points {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 640px) {
    .screen {
        padding: 12px;
    }

    .sheet {
        padding: 18px 14px 16px;
        border-radius: 14px;
    }

    .keys {
        grid-template-columns: 1fr;
    }

    .cards {
        grid-template-columns: 1fr;
    }
}
