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

:root {
    --alberta-blue: #0D3692;
    --alberta-gold: #FEBA35;
    --canada-red: #D80621;
    --canada-red-display: #D80621;
    --white: #FFFFFF;
    --light-gray: #F4F5F7;
    --dark-text: #111;
    --surface: #ECEEF1;
    --border: #ddd;
    --muted: #666;
    --subtle: #999;
    --bg-gradient: radial-gradient(ellipse at 50% 30%, rgba(13, 54, 146, 0.04) 0%, transparent 60%);
}

html.dark {
    --white: #161616;
    --light-gray: #0e0e0e;
    --dark-text: #e0e0e0;
    --surface: #222;
    --border: #2e2e2e;
    --muted: #aaa;
    --subtle: #666;
    --canada-red-display: #FF2D46;
    --bg-gradient: none;
}

body {
    font-family: 'Space Grotesk', 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Oxygen, Ubuntu, sans-serif;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-gradient), var(--light-gray);
    color: var(--dark-text);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    text-align: center;
    padding: 3.5rem 3rem 3rem;
    background: var(--white);
    width: 520px;
    margin: 1rem;
    border-radius: 16px;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.04),
        0 2px 8px rgba(0, 0, 0, 0.04),
        0 8px 32px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.flag-stripe {
    display: flex;
    width: 64px;
    gap: 0;
    margin-bottom: 2rem;
    border-radius: 2px;
    overflow: hidden;
}

.flag-stripe span {
    flex: 1;
    height: 4px;
}

.flag-stripe .blue { background: var(--alberta-blue); }
.flag-stripe .gold { background: var(--alberta-gold); }
.flag-stripe .red { background: var(--canada-red); }

.info-bar {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.85rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--muted);
    letter-spacing: 0.01em;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.info-item svg {
    width: 12px;
    height: 12px;
    opacity: 0.5;
}

h1 {
    font-size: 1.4rem;
    margin-bottom: 1.75rem;
    font-weight: 600;
    color: var(--alberta-blue);
    letter-spacing: -0.02em;
    line-height: 1.3;
}

.answer {
    font-size: clamp(4rem, 16vmin, 7.5rem);
    font-weight: 800;
    margin: 0.25rem 0;
    line-height: 1;
    letter-spacing: 0.04em;
    animation: answer-entrance 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.15s both;
}

.answer.no {
    color: var(--canada-red-display);
    text-shadow: 0 1px 24px rgba(216, 6, 33, 0.15);
}

.answer.yes {
    color: #228B22;
    text-shadow: 0 1px 24px rgba(34, 139, 34, 0.15);
}

@keyframes answer-entrance {
    0% {
        opacity: 0;
        transform: scale(0.85);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.subtitle {
    font-size: 0.9rem;
    color: var(--muted);
    font-weight: 400;
    margin-top: 0.75rem;
    margin-bottom: 2rem;
    transition: color 0.3s ease;
}

.share-buttons {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.75rem;
    padding-bottom: 1.75rem;
    border-bottom: 1px solid var(--border);
    transition: border-color 0.3s ease;
}

.share-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, background-color 0.15s ease, color 0.15s ease;
    text-decoration: none;
    background: var(--surface);
    color: var(--muted);
}

.share-btn:hover {
    transform: translateY(-2px);
    color: var(--dark-text);
}

.share-btn.x:hover {
    background: #000;
    color: #fff;
}

html.dark .share-btn.x:hover {
    background: #e7e9ea;
    color: #000;
}

.share-btn.facebook:hover {
    background: #1877F2;
    color: #fff;
}

.share-btn.copy:hover {
    background: #22c55e;
    color: #fff;
}

/* Tooltips */
.share-btn {
    position: relative;
}

.share-btn::before {
    content: attr(aria-label);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    padding: 0.3rem 0.6rem;
    background: var(--dark-text);
    color: var(--white);
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.share-btn:hover::before {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.share-btn svg {
    width: 16px;
    height: 16px;
}

.share-btn .check-icon {
    display: none;
    color: #22c55e;
}

.share-btn.copied .link-icon {
    display: none;
}

.share-btn.copied .check-icon {
    display: block;
}

.share-btn.copied:hover {
    background: var(--surface);
    color: var(--dark-text);
}

nav {
    margin-top: 0;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

nav a {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.5rem 1.1rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 100px;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.15s ease;
}

nav a::after {
    content: '\2192';
    font-size: 0.85em;
    transition: transform 0.15s ease;
}

nav a:hover {
    background: var(--surface);
    color: var(--dark-text);
    border-color: var(--surface);
}

nav a:hover::after {
    transform: translateX(3px);
}

footer {
    margin-top: 1.75rem;
    font-size: 0.7rem;
    color: var(--subtle);
    font-weight: 400;
    letter-spacing: 0.02em;
    transition: color 0.3s ease;
}

/* Skeleton loading */
@keyframes skeleton-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

.skeleton {
    background: currentColor;
    border-radius: 4px;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    display: inline-block;
    min-width: 3ch;
    height: 1em;
    vertical-align: middle;
}

.info-item .skeleton {
    opacity: 0.3;
}

html.dark .container {
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.06),
        0 8px 32px rgba(0, 0, 0, 0.5);
}

html.dark .answer.no {
    text-shadow: 0 2px 32px rgba(255, 45, 70, 0.25);
}

.theme-toggle {
    position: fixed;
    top: 1rem;
    right: 1rem;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    transition: background-color 0.3s ease, border-color 0.3s ease, transform 0.15s ease;
}

.theme-toggle:hover {
    transform: translateY(-1px);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
    position: absolute;
    transition: opacity 0.3s ease, transform 0.3s ease, color 0.3s ease;
    color: var(--dark-text);
}

.theme-toggle .sun {
    opacity: 0;
    transform: rotate(-90deg);
}

.theme-toggle .moon {
    opacity: 1;
    transform: rotate(0deg);
}

html.dark .theme-toggle .sun {
    opacity: 1;
    transform: rotate(0deg);
}

html.dark .theme-toggle .moon {
    opacity: 0;
    transform: rotate(90deg);
}

/* Focus styles */
.theme-toggle:focus-visible,
.share-btn:focus-visible,
nav a:focus-visible {
    outline: 2px solid var(--alberta-blue);
    outline-offset: 2px;
}

/* Page transitions */
@keyframes page-fade-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.container {
    animation: page-fade-in 0.35s ease-out;
}

body.page-exit .container {
    animation: page-fade-out 0.2s ease-in forwards;
}

@keyframes page-fade-out {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-8px);
    }
}

@media (max-width: 600px) {
    body {
        background: var(--white);
    }

    .container {
        width: 100%;
        padding: 2rem 1.5rem;
        margin: 0;
        min-height: 100vh;
        min-height: 100dvh;
        border-radius: 0;
        box-shadow: none;
    }

    .flag-stripe {
        width: 100%;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        margin: 0;
        border-radius: 0;
    }

    .flag-stripe span {
        height: 3px;
    }

    h1 {
        font-size: 1.15rem;
        margin-bottom: 1.25rem;
    }

    .subtitle {
        font-size: 0.85rem;
    }

    .info-bar {
        gap: 0.4rem;
        margin-bottom: 1.5rem;
    }

    .info-item {
        padding: 0.3rem 0.7rem;
        font-size: 0.7rem;
    }

    .share-buttons {
        margin-bottom: 1.25rem;
        padding-bottom: 1.25rem;
    }

    .share-btn {
        width: 44px;
        height: 44px;
    }

    nav a {
        padding: 0.65rem 1.25rem;
        font-size: 0.85rem;
    }

    .theme-toggle {
        top: 0.75rem;
        right: 0.75rem;
    }
}

/* Landscape phones */
@media (max-height: 500px) and (orientation: landscape) {
    .container {
        padding: 1.5rem 2rem;
        min-height: auto;
    }

    h1 {
        margin-bottom: 1rem;
    }

    .answer {
        margin: 0.25rem 0;
    }

    .info-bar {
        margin-bottom: 1rem;
    }

    .share-buttons {
        margin-bottom: 1rem;
        padding-bottom: 1rem;
    }
}

@media (max-width: 350px) {
    h1 {
        font-size: 1rem;
    }
}

/* Dashboard */
.dashboard-container {
    text-align: center;
    padding: 2.5rem 2.5rem 2rem;
    background: var(--white);
    width: 860px;
    max-width: calc(100% - 2rem);
    margin: 2rem auto;
    align-self: flex-start;
    border-radius: 16px;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.04),
        0 2px 8px rgba(0, 0, 0, 0.04),
        0 8px 32px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
    animation: page-fade-in 0.35s ease-out;
}

html.dark .dashboard-container {
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.06),
        0 8px 32px rgba(0, 0, 0, 0.5);
}

body.page-exit .dashboard-container {
    animation: page-fade-out 0.2s ease-in forwards;
}

.dashboard-heading {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--alberta-blue);
    letter-spacing: -0.02em;
    line-height: 1.3;
    margin-bottom: 1.5rem;
}

.bento-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
    width: 100%;
    margin-bottom: 1.75rem;
}

.bento-section {
    grid-column: 1 / -1;
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--subtle);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 0.85rem 0 0.15rem;
    margin: 0.15rem 0 0;
    text-align: left;
    border-top: 1px solid var(--border);
}

.bento-tile {
    background: var(--surface);
    border-radius: 12px;
    padding: 1.1rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.bento-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

html.dark .bento-tile:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.bento-tile.span-2 {
    grid-column: span 2;
    padding: 1.25rem 1.15rem;
}

.tile-label {
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.tile-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--dark-text);
}

.bento-tile.span-2 .tile-value {
    font-size: 2rem;
}

.tile-spark {
    width: 100%;
    height: 32px;
    display: block;
    overflow: visible;
}

.bento-tile.span-2 .tile-spark {
    height: 40px;
}

.spark-line {
    fill: none;
    stroke: var(--alberta-blue);
    stroke-width: 1.5;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.spark-fill {
    stroke: none;
    opacity: 0;
    transition: opacity 0.6s ease-out 0.6s;
}

.spark-fill.visible {
    opacity: 1;
}

.spark-grad-start {
    stop-color: var(--alberta-blue);
    stop-opacity: 0.18;
}

.spark-grad-end {
    stop-color: var(--alberta-blue);
    stop-opacity: 0;
}

.spark-dot {
    fill: var(--alberta-blue);
    opacity: 0;
    transition: opacity 0.3s ease-out 0.9s;
}

.spark-dot.visible {
    opacity: 1;
}

html.dark .spark-line {
    stroke: var(--alberta-gold);
}

html.dark .spark-grad-start {
    stop-color: var(--alberta-gold);
    stop-opacity: 0.22;
}

html.dark .spark-grad-end {
    stop-color: var(--alberta-gold);
    stop-opacity: 0;
}

html.dark .spark-dot {
    fill: var(--alberta-gold);
}

.tile-meta {
    font-size: 0.7rem;
    color: var(--subtle);
    font-weight: 400;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.tile-delta {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    line-height: 1.4;
}

.tile-delta.positive {
    background: rgba(34, 197, 94, 0.12);
    color: #16a34a;
}

.tile-delta.negative {
    background: rgba(239, 68, 68, 0.12);
    color: #dc2626;
}

html.dark .tile-delta.positive {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}

html.dark .tile-delta.negative {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.dashboard-source {
    font-size: 0.7rem;
    color: var(--subtle);
    margin-bottom: 1.75rem;
    font-weight: 400;
    letter-spacing: 0.02em;
}

.dashboard-container nav {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

@media (max-width: 860px) {
    .bento-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .bento-tile.span-2 {
        grid-column: span 1;
    }

    .bento-tile.span-2 .tile-value {
        font-size: 1.75rem;
    }

    .bento-tile.span-2 .tile-spark {
        height: 32px;
    }
}

@media (max-width: 600px) {
    .dashboard-container {
        width: 100%;
        max-width: 100%;
        padding: 2rem 1.25rem;
        margin: 0;
        min-height: 100vh;
        min-height: 100dvh;
        border-radius: 0;
        box-shadow: none;
    }

    .dashboard-container .flag-stripe {
        width: 100%;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        margin: 0;
        border-radius: 0;
    }

    .dashboard-container .flag-stripe span {
        height: 3px;
    }

    .dashboard-heading {
        font-size: 1.15rem;
        margin-bottom: 1.25rem;
    }

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

    .dashboard-container nav a {
        padding: 0.65rem 1.25rem;
        font-size: 0.85rem;
    }
}
