@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&display=swap');

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

:root {
    --font: 'DM Sans', system-ui, sans-serif;

    /* background mesh */
    --grad-a: #c8d8f8;
    --grad-b: #e8d0f0;
    --grad-c: #c0e8f0;
    --grad-d: #f0d8c8;

    /* glass surfaces */
    --glass-bg:     rgba(255, 255, 255, 0.45);
    --glass-border: rgba(255, 255, 255, 0.75);
    --glass-shine:  rgba(255, 255, 255, 0.6);
    --glass-shadow: rgba(80, 80, 120, 0.12);

    /* type */
    --fg:       rgba(20, 20, 40, 0.88);
    --fg-mid:   rgba(20, 20, 40, 0.44);
    --fg-dim:   rgba(20, 20, 40, 0.28);
    --accent:   rgba(90, 100, 220, 0.9);
    --gold:     rgba(200, 140, 20, 1);
    --positive: rgba(40, 160, 100, 0.9);
    --negative: rgba(210, 60, 60, 0.9);
}

/* ── background ── */
html { min-height: 100%; }

body {
    font-family: var(--font);
    min-height: 100vh;
    background-color: var(--grad-a);
    background-image:
        radial-gradient(ellipse 80% 80% at 10% 10%,  var(--grad-a) 0%, transparent 60%),
        radial-gradient(ellipse 70% 70% at 90% 15%,  var(--grad-b) 0%, transparent 55%),
        radial-gradient(ellipse 60% 60% at 80% 85%,  var(--grad-c) 0%, transparent 55%),
        radial-gradient(ellipse 75% 75% at 15% 85%,  var(--grad-d) 0%, transparent 60%);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
}

/* ── app shell ── */
#app {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -webkit-flex-direction: column;
    flex-direction: column;
    -webkit-align-items: stretch;
    align-items: stretch;
    max-width: 430px;
    margin: 0 auto;
    padding: clamp(3rem, 10vw, 4.5rem) 20px clamp(2rem, 6vw, 3rem);
    min-height: 100vh;
}

/* ── page heading ── */
h1 {
    font-size: clamp(1.9rem, 7vw, 2.4rem);
    font-weight: 600;
    letter-spacing: -0.03em;
    color: var(--fg);
    margin-bottom: 0.2em;
    line-height: 1.05;
}

#app-header {
    position: relative;
    left: 0px;
}

#account-link {
    position: absolute;
    top: 3px;
    right: 3px;
    font-size: 0.9rem;
    text-decoration: underline;
    cursor: pointer;
    padding: 3px 8px;
    /* background: rgb(var(--glass-bg) / var(--glass-trans));
    border: 1px solid rgb(var(--glass-border) / var(--glass-trans)); */
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    box-shadow:
        0 0px 0 0 var(--glass-shine) inset,
        0 8px 32px var(--glass-shadow),
        0 1px 2px rgba(255, 255, 255, 0.5) inset;
    -webkit-backdrop-filter: blur(24px) saturate(1.6);
    backdrop-filter: blur(24px) saturate(1.6);
}

/* ── section label (h2) ── */
h2 {
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--fg-mid);
    padding: 0 4px;
    margin-bottom: 0.75rem;
}

/* ─────────────────────────────────────
   SHARED GLASS PANEL
───────────────────────────────────── */

#rankings-container,
#scores-container {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -webkit-flex-direction: column;
    flex-direction: column;
    -webkit-backdrop-filter: blur(24px) saturate(1.6);
    backdrop-filter: blur(24px) saturate(1.6);
    border-radius: 20px;
    overflow: hidden;
    background: var(--glass-bg);
    box-shadow:
        0 1px 0 0 var(--glass-shine) inset,
        0 8px 32px var(--glass-shadow),
        0 1px 2px rgba(255, 255, 255, 0.5) inset;
}

/* ─────────────────────────────────────
   RANKINGS
───────────────────────────────────── */

#rankings-container {
    margin-top: 1.5rem;
}

.rank-card {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-flex-direction: row;
    flex-direction: row;
    -webkit-align-items: center;
    align-items: center;
    padding: 13px 15px;
    /* margin: 12px 20px 0px; */
    /* border-radius: 15px; */
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    /* background: var(--glass-bg); */
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    -webkit-transition: background 0.15s ease;
    transition: background 0.15s ease;
    min-height: 52px;
    opacity: 0;
    -webkit-animation: glassIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    animation: glassIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.rank-card:active { background: rgba(255, 255, 255, 0.35); }

.rank-card:nth-child(1)  { -webkit-animation-delay: 0.08s; animation-delay: 0.08s; }
.rank-card:nth-child(2)  { -webkit-animation-delay: 0.13s; animation-delay: 0.13s; }
.rank-card:nth-child(3)  { -webkit-animation-delay: 0.18s; animation-delay: 0.18s; }
.rank-card:nth-child(4)  { -webkit-animation-delay: 0.23s; animation-delay: 0.23s; }
.rank-card:nth-child(5)  { -webkit-animation-delay: 0.28s; animation-delay: 0.28s; }
.rank-card:nth-child(6)  { -webkit-animation-delay: 0.33s; animation-delay: 0.33s; }
.rank-card:nth-child(7)  { -webkit-animation-delay: 0.38s; animation-delay: 0.38s; }
.rank-card:nth-child(8)  { -webkit-animation-delay: 0.43s; animation-delay: 0.43s; }
.rank-card:nth-child(9)  { -webkit-animation-delay: 0.48s; animation-delay: 0.48s; }
.rank-card:nth-child(10) { -webkit-animation-delay: 0.53s; animation-delay: 0.53s; }
.rank-card:nth-child(11) { -webkit-animation-delay: 0.58s; animation-delay: 0.58s; }

.rank-card .rank {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--fg-dim);
    width: 36px;
    -webkit-flex-shrink: 0;
    flex-shrink: 0;
    letter-spacing: 0.02em;
}

.rank-card:first-child .rank {
    color: var(--gold);
    font-weight: 600;
}

.rank-card .name {
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    flex: 1;
    font-size: 1.02rem;
    font-weight: 500;
    color: var(--fg);
    letter-spacing: -0.01em;
}

.rank-card:first-child .name { font-weight: 600; }

.rank-card .points {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--fg-mid);
    letter-spacing: -0.01em;
    min-width: 36px;
    text-align: right;
}

.rank-card:first-child .points {
    color: var(--accent);
    font-weight: 600;
}

.rank-card:nth-last-child(-n+3) .points {
    color: var(--fg-dim);
}

/* ─────────────────────────────────────
   SCORES
───────────────────────────────────── */

#scores-title {
    margin-top: 2.5rem;
    padding-left: 10px;
}

.score-card {
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    grid-template-rows: auto auto;
    grid-template-areas:
        "name    scorer  time    points"
        "reason  reason  reason  reason";
    -webkit-column-gap: 6px;
    column-gap: 6px;
    row-gap: 3px;
    padding: 13px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.45);
    background: transparent;
    position: relative;
    -webkit-transition: background 0.15s ease;
    transition: background 0.15s ease;
    opacity: 0;
    -webkit-animation: glassIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    animation: glassIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.score-card:last-child { border-bottom: none; }

/*
.score-card:nth-child(1)  { -webkit-animation-delay: 0.12s; animation-delay: 0.12s; }
.score-card:nth-child(2)  { -webkit-animation-delay: 0.17s; animation-delay: 0.17s; }
.score-card:nth-child(3)  { -webkit-animation-delay: 0.22s; animation-delay: 0.22s; }
.score-card:nth-child(4)  { -webkit-animation-delay: 0.27s; animation-delay: 0.27s; }
.score-card:nth-child(5)  { -webkit-animation-delay: 0.32s; animation-delay: 0.32s; }
.score-card:nth-child(6)  { -webkit-animation-delay: 0.37s; animation-delay: 0.37s; }
.score-card:nth-child(7)  { -webkit-animation-delay: 0.42s; animation-delay: 0.42s; }
.score-card:nth-child(8)  { -webkit-animation-delay: 0.47s; animation-delay: 0.47s; }
.score-card:nth-child(9)  { -webkit-animation-delay: 0.52s; animation-delay: 0.52s; }
.score-card:nth-child(10) { -webkit-animation-delay: 0.57s; animation-delay: 0.57s; }
.score-card:nth-child(11) { -webkit-animation-delay: 0.62s; animation-delay: 0.62s; }
.score-card:nth-child(12) { -webkit-animation-delay: 0.67s; animation-delay: 0.67s; }
.score-card:nth-child(13) { -webkit-animation-delay: 0.72s; animation-delay: 0.72s; }
.score-card:nth-child(14) { -webkit-animation-delay: 0.77s; animation-delay: 0.77s; }
.score-card:nth-child(15) { -webkit-animation-delay: 0.82s; animation-delay: 0.82s; }
.score-card:nth-child(16) { -webkit-animation-delay: 0.87s; animation-delay: 0.87s; }
.score-card:nth-child(17) { -webkit-animation-delay: 0.92s; animation-delay: 0.92s; }
.score-card:nth-child(18) { -webkit-animation-delay: 0.97s; animation-delay: 0.97s; }
.score-card:nth-child(19) { -webkit-animation-delay: 1.02s; animation-delay: 1.02s; }
.score-card:nth-child(20) { -webkit-animation-delay: 1.07s; animation-delay: 1.07s; }
*/

.score-card .name {
    grid-area: name;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--fg);
    letter-spacing: -0.01em;
    -webkit-align-self: baseline;
    align-self: baseline;
    white-space: nowrap;
}

.score-card .scorer,
.score-card .time {
    font-size: 0.72rem;
    font-weight: 400;
    letter-spacing: 0.01em;
    line-height: 1.5;
    -webkit-align-self: baseline;
    align-self: baseline;
    white-space: nowrap;
}

.score-card .scorer { grid-area: scorer; color: var(--fg-mid); }
.score-card .scorer::before { content: '· '; color: var(--fg-dim); }
.score-card .time   { grid-area: time; color: var(--fg-dim); }
.score-card .time::before   { content: '· '; color: var(--fg-dim); }

.score-card .points {
    grid-area: points;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--positive);
    letter-spacing: -0.01em;
    text-align: right;
    -webkit-align-self: baseline;
    align-self: baseline;
    white-space: nowrap;
}

.score-card .points.negative { color: var(--negative); }

.score-card .reason {
    grid-area: reason;
    font-size: 0.72rem;
    font-weight: 400;
    color: var(--fg-mid);
    letter-spacing: 0.01em;
    line-height: 1.5;
}

/* ─────────────────────────────────────
   INTERACTIVE SCORE CARD
───────────────────────────────────── */

.iscore-card {
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    grid-template-rows: auto auto auto;
    grid-template-areas:
        "name    scorer  time    points"
        "reason  reason  reason  reason"
        "button  button  button  button";
    -webkit-column-gap: 6px;
    column-gap: 6px;
    row-gap: 8px;
    padding: 13px 18px;
    border-top: 1px solid rgba(180, 180, 210, 0.3);
    background: rgba(90, 100, 220, 0.04);
}

.iscore-card .name {
    grid-area: name;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--fg);
    letter-spacing: -0.01em;
    -webkit-align-self: baseline;
    align-self: baseline;
    white-space: nowrap;
}

.iscore-card .scorer {
    grid-area: scorer;
    font-size: 0.72rem;
    font-weight: 400;
    color: var(--fg-mid);
    letter-spacing: 0.01em;
    -webkit-align-self: baseline;
    align-self: baseline;
    white-space: nowrap;
}

.iscore-card .scorer::before { content: '· '; color: var(--fg-dim); }

.iscore-card .time {
    grid-area: time;
    font-size: 0.72rem;
    font-weight: 400;
    color: var(--fg-dim);
    letter-spacing: 0.01em;
    -webkit-align-self: baseline;
    align-self: baseline;
    white-space: nowrap;
}

.iscore-card .time::before { content: '· '; color: var(--fg-dim); }

/* font-size: 1rem (16px) prevents iOS Safari auto-zoom on focus */
.iscore-card input {
    -webkit-appearance: none;
    appearance: none;
    font-family: var(--font);
    font-size: 1rem;
    outline: none;
    border: 1px solid rgba(140, 160, 255, 0.55);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.55);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    box-shadow: 0 1px 0 0 rgba(255, 255, 255, 0.8) inset;
    padding: 4px 8px;
    -webkit-transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.iscore-card input:focus {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(110, 130, 255, 0.85);
    box-shadow: 0 1px 0 0 rgba(255, 255, 255, 0.9) inset, 0 0 0 3px rgba(110, 130, 255, 0.18);
}

.iscore-card input:user-invalid {
    border-color: rgba(210, 60, 60, 0.35);
}

.iscore-card input.points {
    grid-area: points;
    width: 60px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--fg-mid);
    text-align: center;
    letter-spacing: -0.01em;
    -webkit-align-self: center;
    align-self: center;
}

.iscore-card input.points::placeholder { color: var(--fg-dim); font-weight: 400; }

.iscore-card input.reason {
    grid-area: reason;
    width: 100%;
    font-size: 0.72rem;
    color: var(--fg-mid);
    letter-spacing: 0.01em;
}

.iscore-card input.reason::placeholder { color: var(--fg-dim); }

.iscore-card .add-points-button {
    grid-area: button;
    -webkit-appearance: none;
    appearance: none;
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    /* color: var(--accent);
    background: rgba(255, 255, 255, 0.55); */
    color: rgba(255, 255, 255, 0.8);
    background: var(--accent);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(140, 160, 255, 0.55);
    border-radius: 8px;
    box-shadow: 0 1px 0 0 rgba(255, 255, 255, 0.3) inset;
    padding: 6px 12px;
    cursor: pointer;
    width: 100%;
    -webkit-transition: background 0.15s, border-color 0.15s, -webkit-transform 0.1s;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.iscore-card .add-points-button:active {
    background: rgba(110, 130, 255, 0.25);
    -webkit-transform: scale(0.96);
    transform: scale(0.96);
}

/* ─────────────────────────────────────
   PERSON MODAL
───────────────────────────────────── */

/* backdrop-filter on ::backdrop unsupported on iOS Safari */
#person-modal::backdrop {
    background: rgba(10, 10, 30, 0.55);
}

#person-modal {
    background-color: var(--grad-a);
    background-image:
        radial-gradient(ellipse 80% 80% at 10% 10%,  var(--grad-a) 0%, transparent 60%),
        radial-gradient(ellipse 70% 70% at 90% 15%,  var(--grad-b) 0%, transparent 55%),
        radial-gradient(ellipse 60% 60% at 80% 85%,  var(--grad-c) 0%, transparent 55%),
        radial-gradient(ellipse 75% 75% at 15% 85%,  var(--grad-d) 0%, transparent 60%);
    -webkit-backdrop-filter: blur(24px) saturate(1.6);
    backdrop-filter: blur(24px) saturate(1.6);
    border-radius: 24px;
    border: 1px solid var(--glass-border);
    box-shadow:
        0 1px 0 0 var(--glass-shine) inset,
        0 20px 60px rgba(80, 80, 120, 0.2);
    width: calc(100vw - 32px);
    max-width: 420px;
    max-height: 80vh;
    max-height: 80dvh;
    padding: 8px;
    margin: auto;
}

#person-modal[open] {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -webkit-flex-direction: column;
    flex-direction: column;
}

/* person-info must not grow so scores container gets all remaining space */
#person-modal .person-info {
    position: relative;
    -webkit-flex-shrink: 0;
    flex-shrink: 0;
    padding: 22px 22px 0;
    margin-bottom: 15px;
}

#person-modal .title {
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--fg);
}

#person-modal .total-points {
    position: absolute;
    top: 22px;
    right: 22px;
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--accent);
}

#person-scores-container {
    border-radius: 12px;
    box-shadow: 0 0 5px 1px rgba(100, 100, 100, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.8); */
    margin: 8px;
    overflow: hidden;
}

#person-scores-container .scores-holder {
    overflow: auto;
}

#person-scores-container .score-card, 
#person-scores-container .iscore-card {
    background: var(--glass-bg);
}

#close-person-modal {
    -webkit-appearance: none;
    appearance: none;
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    padding: 13px 0;
    margin: 25px 16px 16px;
    display: block;
    width: calc(100% - 32px);
    background: rgba(255, 255, 255, 0.55);
    color: var(--fg-mid);
    cursor: pointer;
    outline: none;
    -webkit-flex-shrink: 0;
    flex-shrink: 0;
    -webkit-transition: opacity 0.15s, -webkit-transform 0.1s;
    transition: opacity 0.15s, transform 0.1s;
}

#close-person-modal:active {
    opacity: 0.75;
    -webkit-transform: scale(0.97);
    transform: scale(0.97);
}

#close-person-modal:focus:not(:focus-visible) { outline: none; }

/* ─────────────────────────────────────
   LOGIN MODAL
───────────────────────────────────── */

#login-modal::backdrop {
    background: rgba(10, 10, 30, 0.55);
}

#login-modal {
    background-color: var(--grad-a);
    background-image:
        radial-gradient(ellipse 80% 80% at 10% 10%,  var(--grad-a) 0%, transparent 60%),
        radial-gradient(ellipse 70% 70% at 90% 15%,  var(--grad-b) 0%, transparent 55%),
        radial-gradient(ellipse 60% 60% at 80% 85%,  var(--grad-c) 0%, transparent 55%),
        radial-gradient(ellipse 75% 75% at 15% 85%,  var(--grad-d) 0%, transparent 60%);
    -webkit-backdrop-filter: blur(24px) saturate(1.6);
    backdrop-filter: blur(24px) saturate(1.6);
    border-radius: 24px;
    border: 1px solid var(--glass-border);
    box-shadow:
        0 1px 0 0 var(--glass-shine) inset,
        0 20px 60px rgba(80, 80, 120, 0.2);
    width: calc(100vw - 32px);
    max-width: 320px;
    padding: 0;
    margin: auto;
}

#login-modal[open] {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -webkit-flex-direction: column;
    flex-direction: column;
    gap: 10px;
    padding: 24px;
}

#login-modal h1 {
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--fg);
    margin-bottom: 4px;
}

/* font-size: 1rem (16px) prevents iOS Safari auto-zoom on focus */
#login-modal input {
    -webkit-appearance: none;
    appearance: none;
    font-family: var(--font);
    font-size: 0.69rem;
    font-weight: 400;
    color: var(--fg);
    outline: none;
    border: 1px solid rgba(140, 160, 255, 0.55);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.55);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    box-shadow: 0 1px 0 0 rgba(255, 255, 255, 0.8) inset;
    padding: 10px 12px;
    width: 100%;
    -webkit-transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

#login-modal input::placeholder { color: var(--fg-dim); }

#login-modal input:focus {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(110, 130, 255, 0.85);
    box-shadow: 0 1px 0 0 rgba(255, 255, 255, 0.9) inset, 0 0 0 3px rgba(110, 130, 255, 0.18);
}

#login-modal input:user-invalid {
    border-color: rgba(210, 60, 60, 0.35);
}

#failed-login-note {
    color: var(--accent);
    font-size: 0.6rem;
}

#login-button,
#close-login-modal {
    -webkit-appearance: none;
    appearance: none;
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    border-radius: 12px;
    padding: 12px 0;
    width: 100%;
    cursor: pointer;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    box-shadow: 0 1px 0 0 rgba(255, 255, 255, 0.8) inset;
    -webkit-transition: background 0.15s, -webkit-transform 0.1s;
    transition: background 0.15s, transform 0.1s;
}

#login-button:active,
#close-login-modal:active {
    -webkit-transform: scale(0.97);
    transform: scale(0.97);
}

#login-button:focus:not(:focus-visible),
#close-login-modal:focus:not(:focus-visible) {
    outline: none;
}

#login-button {
    background: rgba(90, 100, 220, 0.75);
    border: 1px solid rgba(140, 160, 255, 0.6);
    color: #fff;
    margin-top: 4px;
}

#close-login-modal {
    background: rgba(255, 255, 255, 0.45);
    border: 1px solid var(--glass-border);
    color: var(--fg-mid);
}

/* ─────────────────────────────────────
   ANIMATIONS
───────────────────────────────────── */

@-webkit-keyframes glassIn {
    from { opacity: 0; -webkit-transform: translateY(10px); transform: translateY(10px); }
    to   { opacity: 1; -webkit-transform: translateY(0);    transform: translateY(0); }
}
@keyframes glassIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
