/* LAYOUT RULE (all pages and games): mobile first.
   - The plain rules are the phone layout: one column, big touch targets, everything fits a phone screen.
   - The desktop layout is a second set of rules under :root[data-device="desktop"].
   - index.html sets data-device ("mobile" or "desktop") when the page loads and keeps it in the
     "sonikKidsUser" cookie. Each game's .razor.css ends with its own "Desktop layout" section. */

/* Color schemes. The theme picker sets data-theme on <html>; Pink is the default. */
:root,
:root[data-theme="pink"] {
    --bg: #ffe3f1;
    --panel: #ff1493;
    --panel-ink: #5c0010;
    --ink: #7a0016;
    --card: #ffc4e1;
    --card-hover: #ff9ccf;
    --border: #ff2fa8;
    --accent: #ff6ec7;
    --accent-border: #c2006b;
    --board: #ffb0d8;
    --good: #7a0016;
    --edge: #b8005f;
    --x1: #ff4fb8;
    --x2: #e8008a;
    --x3: #b8005f;
}

:root[data-theme="blue"] {
    --bg: #ffffff;
    --panel: #00d4ff;
    --panel-ink: #000000;
    --ink: #000000;
    --card: #ffffff;
    --card-hover: #d4f7ff;
    --border: #00b8ff;
    --accent: #4df0ff;
    --accent-border: #0090cc;
    --board: #d9f6ff;
    --good: #0047ff;
    --edge: #0090cc;
    --x1: #33ddff;
    --x2: #00b0e0;
    --x3: #0080aa;
}

:root[data-theme="green"] {
    --bg: #ecff9e;
    --panel: #39ff14;
    --panel-ink: #000000;
    --ink: #000000;
    --card: #f6ffd0;
    --card-hover: #d4ff5c;
    --border: #2ad40c;
    --accent: #b6ff1f;
    --accent-border: #5aa800;
    --board: #d6ff7a;
    --good: #000000;
    --edge: #3f9a00;
    --x1: #5cff3a;
    --x2: #2ad40c;
    --x3: #1e9e00;
}

/* Futuristic type: Orbitron for titles and numbers, Exo 2 for everything else. */
:root {
    --font-title: 'Orbitron', 'Segoe UI', Helvetica, Arial, sans-serif;
    --font-body: 'Exo 2', 'Segoe UI', Helvetica, Arial, sans-serif;

    /* Plexiglass: a bright reflection across the top half and a faint bounce light at the bottom. */
    --shine: linear-gradient(to bottom, #ffffffe0 0%, #ffffff70 42%, #ffffff18 50%, #ffffff00 78%, #ffffff50 100%);
    /* Tinted see-through fill for glass surfaces. */
    --glass-fill: color-mix(in srgb, var(--card) 45%, transparent);
    --glow: color-mix(in srgb, var(--accent) 55%, transparent);
}

html, body {
    height: 100%;
    margin: 0;
    overscroll-behavior: none;
    color: var(--ink);
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 16px;
}

/* Soft colored light behind a faint tech grid, so the glass has something to show through. */
body {
    background:
        radial-gradient(circle at 15% 10%, color-mix(in srgb, var(--x1) 40%, transparent), transparent 45%),
        radial-gradient(circle at 90% 85%, color-mix(in srgb, var(--accent) 45%, transparent), transparent 50%),
        linear-gradient(color-mix(in srgb, var(--edge) 9%, transparent) 1px, transparent 1px) 0 0 / 32px 32px,
        linear-gradient(90deg, color-mix(in srgb, var(--edge) 9%, transparent) 1px, transparent 1px) 0 0 / 32px 32px,
        var(--bg);
    background-attachment: fixed;
}

/* Chrome lettering: a white-to-color fill, a crisp edge, stacked depth and a glow. */
h1, .brand {
    font-family: var(--font-title);
    font-weight: 900;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: transparent;
    background: linear-gradient(to bottom, #ffffff 0%, #ffffff 35%, var(--x1) 55%, var(--x3) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-stroke: 1px var(--edge);
    filter: drop-shadow(0 1px 0 var(--edge)) drop-shadow(0 2px 0 var(--x3))
            drop-shadow(0 4px 4px #0004) drop-shadow(0 0 10px var(--glow));
}

h1 {
    font-size: 38px;
}

#app, .page {
    height: 100%;
    height: 100dvh;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background-color: color-mix(in srgb, var(--panel) 70%, transparent);
    background-image: var(--shine);
    border-bottom: 1px solid #ffffffb0;
    box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--edge) 50%, transparent),
                0 6px 24px color-mix(in srgb, var(--panel) 45%, transparent);
    backdrop-filter: blur(12px) saturate(1.6);
    -webkit-backdrop-filter: blur(12px) saturate(1.6);
    color: var(--panel-ink);
}

.brand {
    font-size: 24px;
    -webkit-text-stroke: 1px var(--panel-ink);
}

.back {
    color: var(--panel-ink);
    text-decoration: none;
    font-weight: 800;
    letter-spacing: 1px;
    background-color: #ffffff40;
    background-image: var(--shine);
    border: 1.5px solid #ffffffd0;
    border-radius: 12px;
    padding: 4px 14px;
    text-shadow: 0 1px 0 #ffffffa0;
    box-shadow: inset 0 1px 0 #fff, 0 4px 0 color-mix(in srgb, var(--edge) 70%, transparent), 0 7px 12px #0003;
    transition: transform 0.08s, box-shadow 0.08s;
}

.back:active {
    transform: translateY(3px);
    box-shadow: inset 0 1px 0 #fff, 0 1px 0 color-mix(in srgb, var(--edge) 70%, transparent), 0 2px 4px #0003;
}

.stage {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* Plexiglass buttons: tinted see-through acrylic with a thick glowing edge underneath,
   a reflection on top, and a light streak that sweeps across on hover. */
button {
    --btn-edge: var(--edge);
    --btn-fill: var(--glass-fill);
    position: relative;
    overflow: hidden;
    background-color: var(--btn-fill);
    background-image: var(--shine);
    color: var(--ink);
    border: 1.5px solid #ffffffd0;
    border-radius: 14px;
    padding: 10px 20px;
    margin-bottom: 6px;
    font: inherit;
    font-weight: 800;
    font-size: 17px;
    letter-spacing: 1px;
    text-shadow: 0 1px 0 #ffffffc0;
    cursor: pointer;
    backdrop-filter: blur(10px) saturate(1.7);
    -webkit-backdrop-filter: blur(10px) saturate(1.7);
    box-shadow:
        inset 0 1px 0 #ffffff,
        inset 0 -6px 12px color-mix(in srgb, var(--btn-edge) 30%, transparent),
        0 5px 0 color-mix(in srgb, var(--btn-edge) 75%, transparent),
        0 10px 18px #0003,
        0 0 16px var(--glow);
    transition: transform 0.08s, box-shadow 0.15s, background-color 0.15s;
}

button::before {
    content: "";
    position: absolute;
    top: 0;
    left: -70%;
    width: 45%;
    height: 100%;
    background: linear-gradient(100deg, transparent, #ffffffc0, transparent);
    transform: skewX(-20deg);
    transition: left 0.6s ease;
    pointer-events: none;
}

button:hover {
    --btn-fill: color-mix(in srgb, var(--card-hover) 60%, transparent);
    transform: translateY(-1px);
    box-shadow:
        inset 0 1px 0 #ffffff,
        inset 0 -6px 12px color-mix(in srgb, var(--btn-edge) 30%, transparent),
        0 6px 0 color-mix(in srgb, var(--btn-edge) 75%, transparent),
        0 12px 20px #0003,
        0 0 24px var(--glow);
}

button:hover::before {
    left: 130%;
}

button:active {
    transform: translateY(5px);
    box-shadow:
        inset 0 1px 0 #ffffff,
        inset 0 -3px 8px color-mix(in srgb, var(--btn-edge) 30%, transparent),
        0 0 0 color-mix(in srgb, var(--btn-edge) 75%, transparent),
        0 2px 4px #0003,
        0 0 12px var(--glow);
}

button.active {
    --btn-edge: var(--accent-border);
    --btn-fill: color-mix(in srgb, var(--accent) 65%, transparent);
    border-color: #ffffff;
    box-shadow:
        inset 0 1px 0 #ffffff,
        inset 0 -6px 12px color-mix(in srgb, var(--btn-edge) 35%, transparent),
        0 5px 0 color-mix(in srgb, var(--btn-edge) 80%, transparent),
        0 10px 18px #0003,
        0 0 28px var(--accent);
}

/* Home menu */
.menu {
    padding: 16px;
    text-align: center;
}

/* The games are stacked in one column: a wide card each, icon on the left. */
.menu-grid {
    display: flex;
    flex-direction: column;
    gap: 18px;
    max-width: 440px;
    margin: 0 auto;
}

.menu-card {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
    text-align: left;
    border-radius: 20px;
    background-color: var(--glass-fill);
    background-image: var(--shine);
    border: 1.5px solid #ffffffd0;
    color: var(--ink);
    text-decoration: none;
    font-family: var(--font-title);
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 1px;
    text-shadow: 0 1px 0 #ffffffc0;
    backdrop-filter: blur(12px) saturate(1.7);
    -webkit-backdrop-filter: blur(12px) saturate(1.7);
    box-shadow:
        inset 0 1px 0 #ffffff,
        inset 0 -10px 18px color-mix(in srgb, var(--edge) 25%, transparent),
        0 8px 0 color-mix(in srgb, var(--edge) 75%, transparent),
        0 14px 22px #0003,
        0 0 20px var(--glow);
    transition: transform 0.08s, box-shadow 0.15s;
}

a.menu-card:hover {
    transform: translateY(-2px);
    box-shadow:
        inset 0 1px 0 #ffffff,
        inset 0 -10px 18px color-mix(in srgb, var(--edge) 25%, transparent),
        0 10px 0 color-mix(in srgb, var(--edge) 75%, transparent),
        0 18px 26px #0003,
        0 0 30px var(--glow);
}

a.menu-card:active {
    transform: translateY(8px);
    box-shadow:
        inset 0 1px 0 #ffffff,
        0 0 0 color-mix(in srgb, var(--edge) 75%, transparent),
        0 2px 4px #0003,
        0 0 14px var(--glow);
}

.menu-card.soon {
    opacity: 0.45;
    border-style: dashed;
    box-shadow: none;
}

/* Picture icons (e.g. the little dragon) are the same size as the emoji ones. */
.menu-icon-img {
    width: 56px;
    height: 56px;
    flex: 0 0 56px;
    object-fit: cover;
    border-radius: 14px;
    border: 2px solid #ffffffd0;
    filter: drop-shadow(2px 3px 0 var(--x3)) drop-shadow(2px 4px 4px #0005);
}

.menu-icon {
    font-size: 48px;
    text-shadow: none;
    filter: drop-shadow(2px 3px 0 var(--x3)) drop-shadow(2px 4px 4px #0005);
}

.back {
    white-space: nowrap;
}

/* Phones: the color buttons move to a second row so nothing runs off the screen. */
@media (max-width: 600px) {
    .topbar {
        flex-wrap: wrap;
        row-gap: 6px;
        padding: 8px 12px;
    }

    .brand {
        font-size: 18px;
        letter-spacing: 1px;
    }

    /* Row 1: back button and title. Row 2: player name (left) and colors (right). */
    .topbar .brand {
        flex: 1 1 auto;
    }

    .topbar .player-chip {
        order: 1;
        margin-left: 0;
        max-width: 45vw;
        font-size: 14px;
    }

    .topbar .theme-picker {
        order: 2;
        margin-left: auto;
    }

    .topbar .brand + .player-chip {
        flex-basis: auto;
    }
}

/* Small icon-only Data button under the games list. */
.menu-data {
    display: inline-block;
    margin-top: 26px;
    font-size: 15px;
    line-height: 1;
    padding: 5px 8px;
    border-radius: 9px;
}

.player-chip {
    margin-left: auto;
    font-weight: 800;
    padding: 3px 12px;
    border-radius: 10px;
    background: #ffffff40;
    border: 1.5px solid #ffffffb0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 30vw;
}

.player-chip + .theme-picker {
    margin-left: 0;
}

/* "Who's playing?" */
.who {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.who h1 {
    margin-bottom: 4px;
}

.kid-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    max-width: 600px;
}

.who-or {
    margin: 4px 0 0;
    opacity: 0.8;
}

.kid-form {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap: 10px;
}

.glass-input {
    font: inherit;
    font-size: 18px;
    font-weight: 700;
    color: var(--ink);
    width: min(240px, 70vw);
    padding: 10px 14px;
    border-radius: 14px;
    border: 1.5px solid #ffffffd0;
    background-color: color-mix(in srgb, #ffffff 60%, transparent);
    box-shadow: inset 0 2px 6px #0002, 0 0 12px var(--glow);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    outline: none;
}

.glass-input:focus {
    border-color: var(--accent-border);
    box-shadow: inset 0 2px 6px #0002, 0 0 0 3px var(--glow), 0 0 18px var(--accent);
}

.form-error {
    margin: 0;
    font-weight: 800;
}

.change-player {
    font-size: 14px;
    padding: 6px 14px;
    margin-bottom: 18px;
}

/* Data manager */
.dm {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 12px 16px 24px;
    box-sizing: border-box;
}

.dm-where {
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.dm-tabs, .dm-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.dm-tabs button small {
    font-weight: 600;
    opacity: 0.75;
}

.dm-tools button {
    font-size: 15px;
    padding: 7px 14px;
}

button:disabled {
    opacity: 0.45;
    cursor: default;
    transform: none;
}

.dm-tools .kid-form, .dm .kid-form {
    justify-content: flex-start;
}

.dm-status {
    margin: 0;
    font-weight: 800;
}

.dm-table-wrap {
    overflow-x: auto;
    border-radius: 14px;
    border: 1.5px solid #ffffffd0;
    background-color: var(--glass-fill);
    background-image: linear-gradient(to bottom, #ffffff70, #ffffff10 60px, #ffffff00);
    backdrop-filter: blur(12px) saturate(1.6);
    -webkit-backdrop-filter: blur(12px) saturate(1.6);
    box-shadow: inset 0 1px 0 #fff, 0 8px 20px #0002, 0 0 16px var(--glow);
}

.dm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 15px;
}

.dm-table th, .dm-table td {
    padding: 7px 10px;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid color-mix(in srgb, var(--edge) 20%, transparent);
}

.dm-table th {
    font-family: var(--font-title);
    font-size: 12px;
    letter-spacing: 1px;
}

.dm-table tbody tr:last-child td {
    border-bottom: none;
}

.dm-table tr.dm-sel td {
    background: color-mix(in srgb, var(--accent) 30%, transparent);
}

.dm-check {
    width: 28px;
}

.dm-check input {
    width: 20px;
    height: 20px;
    accent-color: var(--accent-border);
}

.dm-row-del {
    width: 1%;
    text-align: right;
}

.dm-row-del button {
    font-size: 14px;
    padding: 4px 9px;
    margin: 0;
    border-radius: 10px;
    box-shadow: inset 0 1px 0 #fff, 0 3px 0 color-mix(in srgb, var(--btn-edge) 70%, transparent);
}

/* Phones only: tight columns, and the table box hugs them, so the play events fit without scrolling sideways. */
@media (max-width: 600px) {
    .dm {
        padding-left: 10px;
        padding-right: 10px;
    }

    .dm-table-wrap {
        align-self: flex-start;
        max-width: 100%;
    }

    .dm-table {
        width: auto;
        font-size: 13px;
    }

    .dm-table th, .dm-table td {
        padding: 4px 5px;
    }

    .dm-table th {
        letter-spacing: 0.5px;
    }

    .dm-check {
        width: 20px;
    }

    .dm-check input {
        width: 16px;
        height: 16px;
        margin: 0;
    }

    .dm-row-del button {
        font-size: 12px;
        padding: 2px 6px;
    }
}

.dm-empty {
    text-align: center !important;
    opacity: 0.7;
    padding: 18px !important;
}

/* Short status line ("Loading...") on the home and data pages. */
.loading-message {
    min-height: 1.4em;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-align: center;
    text-shadow: 0 1px 0 #ffffff, 0 0 12px #ffffff, 0 0 18px var(--glow);
}

/* Each game keeps its own styles next to its code: Games/<Game>/<Game>Game.razor.css. */

@media (prefers-reduced-motion: reduce) {
    button::before { transition: none; }
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

/* Theme picker */
.theme-picker {
    margin-left: auto;
    display: flex;
    gap: 6px;
}

.theme-picker button {
    padding: 4px 13px;
    margin-bottom: 5px;
    font-size: 13px;
    color: #000;
    border-radius: 10px;
    box-shadow: inset 0 1px 0 #fff, 0 4px 0 var(--btn-edge), 0 6px 9px #0004;
}

/* The chosen scheme stays pressed in. */
.theme-picker button.active,
.theme-picker button.active:hover {
    border-color: #000;
    transform: translateY(4px);
    box-shadow: inset 0 1px 0 #fff, 0 0 0 var(--btn-edge), 0 0 0 2px #fff, 0 0 14px #fff;
}

.theme-picker .swatch-pink {
    --btn-edge: #9e004f;
    background-image: var(--shine), linear-gradient(135deg, #ff1493, #ff6ec7);
    color: #5c0010;
}

.theme-picker .swatch-blue {
    --btn-edge: #0080aa;
    background-image: var(--shine), linear-gradient(135deg, #00d4ff, #ffffff);
}

.theme-picker .swatch-green {
    --btn-edge: #1e9e00;
    background-image: var(--shine), linear-gradient(135deg, #39ff14, #ecff9e);
}

h1:focus {
    outline: none;
}

/* ---- Desktop layout (the mobile layout above is the default) ---- */

/* Games menu: two cards per row, in a wider column. */
:root[data-device="desktop"] .menu-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: 880px;
}

:root[data-device="desktop"] .menu-card {
    padding: 18px 24px;
    font-size: 20px;
}

:root[data-device="desktop"] h1 {
    font-size: 46px;
}

:root[data-device="desktop"] .brand {
    font-size: 28px;
}

:root[data-device="desktop"] .topbar {
    padding: 12px 28px;
}

/* Device picker on the Data page. */
.dm-device {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.dm-device button {
    font-size: 14px;
    padding: 6px 12px;
}
