* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Avenir Next", "Segoe UI", -apple-system, sans-serif;
    color: #0d1a2d;
    background: radial-gradient(circle at 20% 20%, #e8f0ff 0%, #eef2f7 35%, #f8f9fb 80%);
}

a {
    color: inherit;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 28px 6%;
    gap: 12px;
    background: linear-gradient(135deg, #0f4c81, #0a2f57 60%, #051e3b);
    color: #e9f4ff;
    border-bottom: 1px solid rgba(255,255,255,0.18);
    box-shadow: 0 14px 30px rgba(4, 29, 58, 0.3);
}

.eyebrow {
    margin: 0;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-size: 12px;
    opacity: 0.75;
}

.top-bar h1 {
    margin: 6px 0 8px;
    font-size: 28px;
    letter-spacing: 0.02em;
}

.lede {
    margin: 0;
    max-width: 640px;
    line-height: 1.5;
    opacity: 0.88;
}

.pill {
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    font-weight: 600;
    align-self: center;
}

.layout {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 24px;
    padding: 28px 6%;
}

.full-row {
    grid-column: 1 / -1;
}

.controls-card, .canvas-card {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 16px 40px rgba(10, 40, 82, 0.14);
    padding: 20px 24px 24px;
    border: 1px solid #e4ebf3;
}

.controls-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.controls-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.controls-actions .ghost-button {
    white-space: nowrap;
}

.controls-header h2,
.canvas-card h2 {
    margin: 0;
    font-size: 18px;
}

.ghost-button {
    border: 1px solid #0f4c81;
    color: #0f4c81;
    background: rgba(15, 76, 129, 0.08);
    padding: 8px 14px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.ghost-button:hover {
    background: rgba(15, 76, 129, 0.16);
}

.charge-controls {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.charge-panel {
    padding: 14px;
    border-radius: 12px;
    border: 1px solid #e3ebf5;
    background: linear-gradient(135deg, #f8fbff, #f5f8fd);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: inline-block;
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.05);
}

.dot.positive {
    background: #f45b69;
}

.dot.negative {
    background: #2d7ff9;
}

.label {
    margin: 0 0 2px;
    font-weight: 700;
}

.small {
    margin: 0;
    font-size: 12px;
    color: #5f7189;
}

.polarity-button {
    padding: 8px 12px;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    font-weight: 700;
    background: #f45b69;
    color: #fff;
    transition: all 0.15s ease;
}

.polarity-button.negative {
    background: #2d7ff9;
}

.polarity-button:active {
    transform: translateY(1px);
}

.slider-row {
    display: grid;
    grid-template-columns: 90px 1fr 60px;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.slider-row input[type="range"] {
    width: 100%;
}

.slider-row .value {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: #10243e;
}

.slider-row.slim {
    grid-template-columns: 130px 1fr 60px;
    grid-column: 1 / -1;
    padding: 8px 10px;
    border-radius: 10px;
    background: #f5f8fd;
}

.hint {
    margin: 16px 0 0;
    color: #5f7189;
    line-height: 1.4;
    font-size: 14px;
}

.canvas-card {
    position: relative;
    padding: 18px 18px 22px;
}

.canvas-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

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

.legend {
    display: flex;
    gap: 12px;
    font-size: 13px;
    color: #3b4a60;
    flex-wrap: wrap;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.legend-item.stroke::before {
    content: "";
    display: inline-block;
    width: 16px;
    height: 3px;
    background: linear-gradient(90deg, #f45b69, #2d7ff9);
    border-radius: 999px;
}

.legend-item.equip .equip-line {
    display: inline-block;
    width: 18px;
    height: 3px;
    background: linear-gradient(90deg, #8a6cff, #38c6d9);
    border-radius: 999px;
}

.toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 12px;
    border: 1px solid #dbe4f2;
    background: #f6f8fd;
    font-weight: 700;
    color: #0f2c56;
    cursor: pointer;
    user-select: none;
}

.toggle input {
    width: 18px;
    height: 18px;
    accent-color: #6c8bff;
    cursor: pointer;
}

canvas {
    width: 100%;
    height: 520px;
    border-radius: 12px;
    display: block;
    background: radial-gradient(circle at 30% 30%, rgba(244, 245, 255, 0.9), rgba(236, 241, 250, 0.9)), #f8faff;
    border: 1px solid #e4ebf3;
    box-shadow: inset 0 1px 8px rgba(12, 42, 86, 0.08);
}

.overlay {
    text-align: center;
    margin-top: 12px;
}

.fieldmap-card {
    margin-top: -6px;
}

#fieldMapCanvas {
    height: 460px;
}

.legend-dot.strong-field {
    background: #f45b69;
}

.legend-dot.weak-field {
    background: #6a8bbd;
}

.motion-card {
    margin-top: -6px;
}

.field-type-row {
    display: flex;
    align-items: center;
    gap: 10px;
    grid-column: 1 / -1;
    flex-wrap: wrap;
}

.field-type-label {
    font-weight: 700;
    white-space: nowrap;
}

.field-type-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.field-type-btn {
    padding: 6px 14px;
    border-radius: 10px;
    border: 1px solid #c8d4e6;
    background: #f5f8fd;
    color: #0f2c56;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 13px;
}

.field-type-btn:hover {
    background: rgba(15, 76, 129, 0.12);
}

.field-type-btn.active {
    background: linear-gradient(135deg, #0f4c81, #2d7ff9);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(15, 76, 129, 0.25);
}

.motion-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

.motion-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.primary-button {
    border: none;
    background: linear-gradient(135deg, #0f4c81, #2d7ff9);
    color: #fff;
    padding: 10px 16px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(25, 73, 140, 0.22);
    transition: transform 0.1s ease, box-shadow 0.15s ease;
}

.primary-button:active {
    transform: translateY(1px);
    box-shadow: 0 6px 12px rgba(25, 73, 140, 0.18);
}

#motionCanvas {
    height: 420px;
}

.stat-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    border-radius: 12px;
    background: #f1f4fb;
    color: #0f2c56;
    border: 1px solid #dbe4f2;
    font-weight: 600;
}

.legend-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: inline-block;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.08);
}

.legend-dot.velocity {
    background: #2d7ff9;
}

.legend-dot.force {
    background: #f45b69;
}

.legend-dot.path {
    background: #0f2c56;
}

footer {
    text-align: center;
    padding: 18px 0 32px;
    color: #5f7189;
    font-size: 13px;
}

@media (max-width: 980px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .canvas-card {
        order: -1;
    }
}
