:root {
    --bg: #0f1014;
    --bg-grad: radial-gradient(circle at 20% 0%, #1a1d27 0%, #0f1014 55%);
    --surface: #1a1c22;
    --text: #eef0f4;
    --text-dim: #9aa1ad;
    --accent-top: #ff8a5b;
    --accent-bottom: #ef4d2a;
    --accent-shadow: #8a2412;
    --secondary-top: #6c7689;
    --secondary-bottom: #444b5a;
    --secondary-shadow: #1f232c;
    --border: #2c303a;
    --focus: rgba(255, 138, 91, 0.35);
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 10px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    background: var(--bg-grad);
    min-height: 100vh;
    min-height: 100dvh;
}

.app {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    padding: 32px 0 40px;
    width: 100%;
}

.header {
    text-align: center;
    padding: 0 16px;
}

.header h1 {
    margin: 0 0 6px;
    font-size: clamp(1.6rem, 3.2vw, 2.25rem);
    font-weight: 700;
    letter-spacing: -0.025em;
    background: linear-gradient(180deg, #ffffff 0%, #b6bcc8 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.subtitle {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-dim);
}

.panel {
    width: min(560px, calc(100% - 32px));
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0.01) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin: 0;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field label {
    font-size: 0.82rem;
    color: var(--text-dim);
    font-weight: 500;
    letter-spacing: 0.01em;
}

.field input {
    width: 100%;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    appearance: textfield;
    -moz-appearance: textfield;
}

.field input::-webkit-outer-spin-button,
.field input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.field input:focus {
    border-color: var(--accent-top);
    box-shadow: 0 0 0 4px var(--focus);
}

.buttons {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    justify-content: center;
}

.btn {
    position: relative;
    flex: 1 1 160px;
    min-width: 150px;
    max-width: 220px;
    padding: 14px 22px;
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    letter-spacing: 0.01em;
    transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.15s ease;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
    will-change: transform;
}

.btn-primary {
    background: linear-gradient(180deg, var(--accent-top) 0%, var(--accent-bottom) 100%);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.35) inset,
        0 -2px 0 rgba(0, 0, 0, 0.2) inset,
        0 4px 0 var(--accent-shadow),
        0 8px 18px rgba(239, 77, 42, 0.35);
}

.btn-secondary {
    background: linear-gradient(180deg, var(--secondary-top) 0%, var(--secondary-bottom) 100%);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.25) inset,
        0 -2px 0 rgba(0, 0, 0, 0.25) inset,
        0 4px 0 var(--secondary-shadow),
        0 8px 18px rgba(0, 0, 0, 0.35);
}

.btn:hover {
    filter: brightness(1.06);
}

.btn:focus-visible {
    outline: none;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.35) inset,
        0 -2px 0 rgba(0, 0, 0, 0.2) inset,
        0 4px 0 var(--accent-shadow),
        0 0 0 4px var(--focus);
}

.btn:active {
    transform: translateY(3px);
}

.btn-primary:active {
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.25) inset,
        0 -1px 0 rgba(0, 0, 0, 0.2) inset,
        0 1px 0 var(--accent-shadow),
        0 2px 6px rgba(239, 77, 42, 0.3);
}

.btn-secondary:active {
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.18) inset,
        0 -1px 0 rgba(0, 0, 0, 0.25) inset,
        0 1px 0 var(--secondary-shadow),
        0 2px 6px rgba(0, 0, 0, 0.3);
}

.board-wrap {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.board-viewport {
    position: relative;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
}

.board-spacer {
    position: relative;
}

.board {
    display: block;
    position: sticky;
    top: 0;
    left: 0;
    margin: 0;
    image-rendering: -webkit-optimize-contrast;
}

@media (max-width: 480px) {
    .app {
        padding: 20px 0 28px;
        gap: 18px;
    }

    .panel {
        padding: 18px;
        gap: 18px;
    }

    .btn {
        flex-basis: 100%;
        max-width: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .btn {
        transition: none;
    }
}
