* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    background: #f1f5f9;
    color: #0f172a;
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}

button,
input {
    font: inherit;
}

.app-nav {
    border-bottom: 1px solid #e2e8f0;
    background: #fff;
    box-shadow: 0 1px 2px rgb(15 23 42 / 0.05);
}

.nav-links {
    display: flex;
    max-width: 64rem;
    margin: 0 auto;
    padding: 0.75rem 1.5rem;
    gap: 0.5rem;
}

.nav-link {
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    color: #475569;
    text-decoration: none;
    transition: background 150ms, color 150ms;
}

.nav-link:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.nav-link-home {
    color: #0f172a;
    font-weight: 600;
}

.app-content {
    max-width: 64rem;
    margin: 0 auto;
    padding: 3rem 1.5rem;
}

.app-content > h1 {
    font-size: 2.25rem;
    letter-spacing: -0.025em;
}

.button {
    padding: 0.5rem 0.75rem;
    border: 0;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    transition: background 150ms, color 150ms, transform 150ms;
}

.button:active {
    transform: scale(0.95);
}

.button-primary {
    background: #4f46e5;
    color: #fff;
}

.button-primary:hover {
    background: #6366f1;
}

.button-secondary {
    background: #f1f5f9;
    color: #334155;
}

.button-secondary:hover,
.button-quiet:hover {
    background: #e2e8f0;
}

.button-quiet {
    background: transparent;
    color: #475569;
    font-weight: 500;
}

.button-danger {
    background: transparent;
    color: #e11d48;
    font-weight: 500;
}

.button-danger:hover {
    background: #fff1f2;
}

.counter-card {
    display: grid;
    width: 100%;
    max-width: 28rem;
    margin: 0 auto;
    padding: 1.5rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    background: #fff;
    box-shadow: 0 20px 25px -5px rgb(148 163 184 / 0.35), 0 8px 10px -6px rgb(148 163 184 / 0.35);
}

.counter-card > .button {
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    font-size: 1rem;
}

.counter-heading {
    grid-row: 1;
    grid-column: 1 / -1;
    margin: 0 0 0.75rem;
    color: #0f172a;
    font-size: 2.25rem;
    letter-spacing: -0.025em;
    text-align: center;
}

.counter-heading span {
    color: #4f46e5;
}

.todo-card {
    max-width: 42rem;
    margin: 0 auto;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    background: #fff;
    box-shadow: 0 20px 25px -5px rgb(148 163 184 / 0.35), 0 8px 10px -6px rgb(148 163 184 / 0.35);
}

.todo-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
}

.todo-header h1 {
    margin: 0;
    font-size: 1.5rem;
    letter-spacing: -0.025em;
}

.todo-header .button {
    padding: 0.625rem 1rem;
    border-radius: 0.75rem;
}

.signals {
    display: none;
}

.todo-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.todo-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    padding: 1rem 1.5rem;
    gap: 0.75rem;
    transition: background 150ms;
}

.todo-item + .todo-item {
    border-top: 1px solid #f1f5f9;
}

.todo-item:hover {
    background: #f8fafc;
}

.todo-checkbox {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: #4f46e5;
}

.todo-title,
.todo-input {
    min-width: 0;
    flex: 1;
}

.todo-title {
    color: #334155;
}

.todo-checkbox:checked ~ .todo-title {
    color: #94a3b8;
    text-decoration: line-through;
}

.todo-input {
    padding: 0.5rem 0.75rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.5rem;
    background: #fff;
    color: #0f172a;
    outline: none;
    transition: border-color 150ms, box-shadow 150ms;
}

.todo-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 4px #e0e7ff;
}

.tetris-page {
    max-width: 52rem;
    margin: 0 auto;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    background: #fff;
    box-shadow: 0 20px 25px -5px rgb(148 163 184 / 0.35), 0 8px 10px -6px rgb(148 163 184 / 0.35);
}

.tetris-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    gap: 1.5rem;
    border-bottom: 1px solid #e2e8f0;
}

.tetris-header h1,
.tetris-header p {
    margin: 0;
}

.tetris-header h1 {
    font-size: 1.75rem;
    letter-spacing: -0.025em;
}

.tetris-eyebrow {
    margin: 0 0 0.2rem;
    color: #64748b;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.tetris-header > p {
    max-width: 20rem;
    color: #64748b;
    font-size: 0.875rem;
    line-height: 1.5;
    text-align: right;
}

.tetris-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 19 / 18;
    overflow: hidden;
    background: #090c13;
}

#tetris-canvas {
    position: absolute;
    inset: 0;
    display: block;
    width: 100% !important;
    height: 100% !important;
    outline: none;
    touch-action: none;
}

#tetris-canvas:focus-visible {
    box-shadow: inset 0 0 0 3px #818cf8;
}

.tetris-status {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    background: #090c13;
    color: #e2e8f0;
    font-weight: 600;
}

.tetris-status[hidden] {
    display: none;
}

.tetris-status-error {
    padding: 2rem;
    color: #fecdd3;
    text-align: center;
}

.tetris-spinner {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid #475569;
    border-top-color: #a5b4fc;
    border-radius: 999px;
    animation: tetris-spin 700ms linear infinite;
}

@keyframes tetris-spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 48rem), (max-height: 32rem) and (hover: none) {
    body:has(.tetris-page) {
        overflow: hidden;
    }

    .app-content:has(.tetris-page) {
        padding: 0;
    }

    .tetris-page {
        position: fixed;
        inset: 0;
        z-index: 100;
        width: 100%;
        height: 100dvh;
        max-width: none;
        overflow: hidden;
        border: 0;
        border-radius: 0;
        background: #090c13;
        box-shadow: none;
    }

    .tetris-header {
        display: none;
    }

    .tetris-stage {
        width: 100%;
        height: 100%;
        min-height: 0;
        aspect-ratio: auto;
    }
}

@media (max-width: 40rem) {
    .tetris-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.5rem;
    }

    .tetris-header > p {
        text-align: left;
    }

    .app-content:has(.tetris-page) {
        padding-right: 0;
        padding-left: 0;
    }

    .tetris-page {
        border-right: 0;
        border-left: 0;
        border-radius: 0;
    }

    .nav-links,
    .app-content {
        padding-right: 1rem;
        padding-left: 1rem;
    }

    .todo-header,
    .todo-item {
        padding-right: 1rem;
        padding-left: 1rem;
    }
}
