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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #fafafa;
    color: #333;
    padding: 24px 16px;
    line-height: 1.6;
    -webkit-text-size-adjust: 100%;
}

.container {
    max-width: 560px;
    margin: 0 auto;
}

h1 {
    font-size: 22px;
    font-weight: 600;
    color: #111;
    margin-bottom: 4px;
}

.subtitle {
    color: #888;
    font-size: 13px;
    margin-bottom: 24px;
}

/* Grid */
.grid-section {
    margin-bottom: 24px;
}

#gridCanvas {
    width: 100%;
    aspect-ratio: 1;
    cursor: crosshair;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: white;
    display: block;
    touch-action: none; /* Prevent scroll on touch */
    -webkit-touch-callout: none;
    user-select: none;
}

.grid-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    padding: 0 2px;
}

#pointCount {
    font-size: 13px;
    color: #999;
}

.clear-btn {
    background: none;
    border: none;
    color: #999;
    font-size: 13px;
    cursor: pointer;
    padding: 4px 8px;
    -webkit-tap-highlight-color: transparent;
}

.clear-btn:hover {
    color: #333;
}

/* Results */
.results {
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

.results.hidden {
    display: none;
}

.search-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: #f5f5f5;
    border-radius: 6px;
    margin-bottom: 12px;
    font-size: 13px;
    color: #888;
}

.search-status.hidden {
    display: none;
}

.status-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid #e0e0e0;
    border-radius: 50%;
    border-top-color: #111;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

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

.result-box {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 14px;
}

.result-box.success {
    border-color: #4a9d5f;
    background: #f8fdf9;
}

.result-box.error {
    border-color: #d4d4d4;
    background: #fafafa;
    color: #999;
    font-size: 13px;
}

.result-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #aaa;
    margin-bottom: 4px;
}

.result-expression {
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-size: 16px;
    color: #111;
    margin-bottom: 10px;
    word-break: break-all;
    overflow-wrap: break-word;
}

.verification {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e8e8e8;
    font-size: 12px;
}

.verification-header {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #aaa;
    margin-bottom: 4px;
}

.verification-item {
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    color: #888;
    margin: 2px 0;
    font-size: 11px;
}

.verification-item.max-error {
    margin-top: 4px;
    font-weight: 600;
    color: #555;
}

.hidden {
    display: none;
}

/* Responsive */
@media (max-width: 480px) {
    body {
        padding: 16px 12px;
    }
    h1 {
        font-size: 20px;
    }
    .result-expression {
        font-size: 14px;
    }
}
