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

:root {
    --bg-main: #06080f;
    --bg-soft: #101423;
    --bg-card: #151b2f;
    --bg-card-hover: #1a2240;
    --stroke: #2a3352;
    --text-main: #f4f7ff;
    --text-soft: #98a5cf;
    --primary: #53d1ff;
    --primary-strong: #31a8db;
    --success: #2de58d;
    --danger: #ff6b84;
    --radius-xl: 20px;
    --radius-lg: 14px;
    --shadow: 0 18px 42px rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    background:
        radial-gradient(circle at 20% 0%, rgba(83, 209, 255, 0.14), transparent 35%),
        radial-gradient(circle at 80% 0%, rgba(104, 122, 255, 0.16), transparent 40%),
        var(--bg-main);
    color: var(--text-main);
    font-family: 'Space Grotesk', 'Segoe UI', sans-serif;
}

.app-shell {
    width: min(1180px, 100% - 24px);
    margin: 12px auto 28px;
    display: grid;
    gap: 14px;
}

.card {
    background: linear-gradient(160deg, rgba(28, 38, 72, 0.9), rgba(17, 21, 38, 0.92));
    border: 1px solid var(--stroke);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
    padding: 16px;
}

.topbar {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.brand-eyebrow {
    font-size: 12px;
    letter-spacing: 1.3px;
    text-transform: uppercase;
    color: var(--primary);
    margin: 0;
    font-weight: 700;
}

.brand-title {
    margin: 4px 0;
    font-size: 24px;
    line-height: 1.15;
}

.brand-subtitle {
    margin: 0;
    color: var(--text-soft);
    font-size: 14px;
    line-height: 1.5;
}

.lang-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 220px;
}

label {
    font-size: 12px;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--text-soft);
    font-weight: 600;
}

select,
input {
    width: 100%;
    border: 1px solid var(--stroke);
    border-radius: var(--radius-lg);
    background: rgba(14, 19, 34, 0.95);
    color: var(--text-main);
    font-size: 15px;
    padding: 13px 14px;
    outline: none;
    transition: border-color 0.2s ease, transform 0.2s ease;
}

select:focus,
input:focus {
    border-color: var(--primary);
    transform: translateY(-1px);
}

.community-header,
.field-head,
.players-head,
.controls-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

h2 {
    margin: 0;
    font-size: 19px;
}

.hint {
    color: var(--text-soft);
    margin: 4px 0 0;
    font-size: 13px;
}

.feed-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 10px;
}

.feed-card {
    border: 1px solid rgba(83, 209, 255, 0.25);
    background: rgba(11, 15, 27, 0.8);
    border-radius: 14px;
    display: grid;
    grid-template-columns: 96px 1fr;
    gap: 10px;
    overflow: hidden;
    min-height: 86px;
}

.feed-preview {
    background: #0a0d18;
    height: 100%;
    width: 100%;
    object-fit: cover;
}

.feed-fallback {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    width: 100%;
    font-size: 11px;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--text-soft);
    padding: 6px;
    text-align: center;
    background: linear-gradient(145deg, #20315f, #0d1431);
}

.feed-meta {
    padding: 10px 12px 10px 0;
    display: grid;
    gap: 4px;
    align-content: center;
}

.feed-name {
    font-size: 15px;
    font-weight: 700;
    margin: 0;
}

.feed-detail {
    margin: 0;
    font-size: 12px;
    color: var(--text-soft);
    line-height: 1.35;
}

.empty-state {
    border: 1px dashed var(--stroke);
    border-radius: 14px;
    padding: 14px;
    text-align: center;
    color: var(--text-soft);
    font-size: 13px;
    margin-top: 10px;
}

.builder-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.input-group {
    margin-top: 12px;
}

.hidden {
    display: none !important;
}

.selection-summary {
    margin-top: 12px;
    border-radius: 14px;
    border: 1px solid rgba(83, 209, 255, 0.25);
    background: rgba(11, 15, 27, 0.75);
    padding: 10px 12px;
    font-size: 13px;
    color: var(--text-soft);
    line-height: 1.45;
    min-height: 44px;
    display: flex;
    align-items: center;
}

.actions-grid {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}

.btn {
    border: none;
    border-radius: 14px;
    padding: 14px;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.2px;
    cursor: pointer;
    transition: transform 0.18s ease, opacity 0.18s ease, box-shadow 0.18s ease;
}

.btn:hover {
    transform: translateY(-1px);
    opacity: 0.96;
}

.btn-primary {
    background: linear-gradient(135deg, var(--success), #16b66f);
    box-shadow: 0 8px 20px rgba(45, 229, 141, 0.22);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    box-shadow: 0 8px 20px rgba(83, 209, 255, 0.24);
}

.btn-ghost {
    background: rgba(17, 24, 43, 0.86);
    border: 1px solid var(--stroke);
    color: var(--text-soft);
}

.field-top-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid var(--stroke);
    background: rgba(12, 18, 34, 0.95);
    color: var(--text-main);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.icon-btn:hover {
    transform: translateY(-1px);
    border-color: var(--primary);
}

.icon-btn svg {
    width: 20px;
    height: 20px;
}

.canvas-shell {
    border: 1px solid rgba(83, 209, 255, 0.2);
    border-radius: 16px;
    background: #090d18;
    padding: 10px;
    margin-top: 8px;
}

canvas {
    width: 100%;
    max-width: 460px;
    margin: 0 auto;
    display: block;
    border-radius: 14px;
    background: #0a0f1d;
}

.share-wrap {
    margin-top: 10px;
    border-top: 1px solid var(--stroke);
    padding-top: 10px;
    display: none;
}

.share-wrap.is-visible {
    display: block;
}

.share-label {
    margin: 0 0 8px;
    font-size: 12px;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.7px;
}

.share-buttons {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.share-btn {
    border: 1px solid var(--stroke);
    border-radius: 12px;
    background: rgba(10, 16, 31, 0.95);
    color: #fff;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    min-height: 62px;
}

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

.share-btn.instagram {
    color: #ff8db2;
}

.share-btn.x {
    color: #d8deff;
}

.share-btn.linkedin {
    color: #8ec7ff;
}

.players-note {
    font-size: 12px;
    color: var(--text-soft);
    margin-top: 2px;
}

.player-grid {
    margin-top: 10px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    max-height: 480px;
    overflow: auto;
    padding-right: 2px;
}

.player-card {
    border: 1px solid var(--stroke);
    border-radius: 12px;
    background: rgba(13, 19, 35, 0.95);
    padding: 8px;
    text-align: left;
    display: flex;
    gap: 8px;
    align-items: center;
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease;
}

.player-card:hover {
    transform: translateY(-1px);
    border-color: rgba(83, 209, 255, 0.5);
}

.player-card.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(83, 209, 255, 0.35);
    background: linear-gradient(145deg, #2d4478, #10192d);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #eff4ff;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
    overflow: hidden;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.player-name {
    font-size: 12px;
    line-height: 1.3;
    color: #ecf2ff;
    margin: 0;
    word-break: break-word;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(3, 6, 12, 0.75);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 20;
    padding: 18px;
}

.modal.is-open {
    display: flex;
}

.modal-card {
    width: min(420px, 100%);
    border-radius: 18px;
    border: 1px solid var(--stroke);
    background: linear-gradient(170deg, rgba(24, 35, 66, 0.98), rgba(14, 20, 38, 0.98));
    padding: 16px;
    box-shadow: var(--shadow);
}

.modal-card h3 {
    margin: 0 0 8px;
    font-size: 19px;
}

.modal-card p {
    margin: 0 0 12px;
    color: var(--text-soft);
    font-size: 13px;
    line-height: 1.45;
}

.modal-actions {
    margin-top: 12px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%) translateY(16px);
    background: rgba(9, 14, 28, 0.97);
    border: 1px solid rgba(83, 209, 255, 0.38);
    border-radius: 999px;
    color: #f0f5ff;
    padding: 10px 16px;
    font-size: 13px;
    opacity: 0;
    transition: opacity 0.22s ease, transform 0.22s ease;
    z-index: 25;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

@media (min-width: 880px) {
    .topbar {
        flex-direction: row;
        justify-content: space-between;
        align-items: flex-start;
    }

    .builder-grid {
        grid-template-columns: 320px minmax(0, 1fr) 300px;
    }

    .player-grid {
        grid-template-columns: 1fr;
        max-height: 600px;
    }
}
