/**
 * Prompt Golf Styles
 * Prefix: pg-
 * Responsive: 768px, 480px
 * Reduced motion: prefers-reduced-motion
 */

/* ============================================
   Layout & Container
   ============================================ */

.pg-container {
    max-width: 640px;
    margin: 0 auto;
    padding: var(--space-sm) var(--space-sm) 120px;
    min-height: calc(100vh - var(--header-height));
}

/* ============================================
   Header
   ============================================ */

.pg-header {
    text-align: center;
    margin-bottom: var(--space-md);
}

.pg-title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    position: relative;
}

.pg-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.8rem;
    font-weight: 900;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 1px;
}

.pg-header-actions {
    position: absolute;
    right: 0;
    display: flex;
    gap: 6px;
}

.pg-icon-btn {
    background: none;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: inherit;
    cursor: pointer;
    padding: 10px;
    min-width: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast);
}

.pg-icon-btn:hover {
    background: var(--glass-dark);
}

.pg-subtitle {
    font-size: 0.85rem;
    opacity: 0.6;
    margin-top: 4px;
    font-family: 'JetBrains Mono', monospace;
}

/* ============================================
   Model Status Bar
   ============================================ */

.pg-model-bar {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 10px 16px;
    margin-bottom: var(--space-sm);
    text-align: center;
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    box-shadow: 0 2px 12px var(--glass-shadow);
}

.pg-model-status {
    font-size: 0.8rem;
    font-family: 'JetBrains Mono', monospace;
    opacity: 0.8;
}

.pg-model-progress {
    margin-top: 6px;
    height: 4px;
    background: var(--glass-dark);
    border-radius: 2px;
    overflow: hidden;
}

.pg-model-progress-bar {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 2px;
    transition: width 0.3s ease;
    width: 0%;
}

/* ============================================
   Target Card
   ============================================ */

.pg-target-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg) var(--space-md);
    margin-bottom: var(--space-md);
    text-align: center;
    backdrop-filter: blur(var(--glass-heavy-blur));
    -webkit-backdrop-filter: blur(var(--glass-heavy-blur));
    box-shadow: 0 8px 32px var(--glass-shadow);
    transition: all var(--transition-base);
}

.pg-target-card:hover {
    box-shadow: 0 12px 48px var(--glass-shadow);
    transform: translateY(-2px);
}

.pg-target-label {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.65rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    opacity: 0.5;
    margin-bottom: 8px;
}

.pg-target-text {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.4;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    word-break: break-word;
    padding: 4px 0;
}

body:not(.dark-mode) .pg-target-text {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    -webkit-background-clip: text;
    background-clip: text;
}

.pg-target-meta {
    font-size: 0.75rem;
    opacity: 0.5;
    margin-top: 8px;
}

/* ============================================
   Attempts Grid
   ============================================ */

.pg-attempts {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: var(--space-sm);
}

.pg-attempt {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    box-shadow: 0 2px 12px var(--glass-shadow);
    transition: all var(--transition-fast);
}

.pg-attempt:hover:not(.pg-attempt--empty) {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px var(--glass-shadow);
}

.pg-attempt--match {
    border-color: var(--success-color);
    background: rgba(72, 187, 120, 0.08);
}

.pg-attempt--miss {
    border-color: rgba(245, 101, 101, 0.3);
}

.pg-attempt--empty {
    opacity: 0.3;
    border-style: dashed;
}

.pg-attempt-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.pg-attempt-num {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    opacity: 0.5;
    min-width: 24px;
}

.pg-attempt-len {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: #a5b4fc;
}

body:not(.dark-mode) .pg-attempt-len {
    color: #667eea;
}

.pg-attempt-tier {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
}

.pg-attempt-blocks {
    display: flex;
    gap: 3px;
    margin-left: auto;
}

.pg-block {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    display: inline-block;
}

.pg-block--empty {
    background: var(--glass-dark);
    border: 1px dashed var(--glass-border);
}

.pg-attempt-prompt {
    font-size: 0.8rem;
    margin-top: 6px;
    padding: 4px 8px;
    background: rgba(102, 126, 234, 0.06);
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    word-break: break-word;
}

.pg-attempt-response {
    font-size: 0.8rem;
    margin-top: 4px;
    opacity: 0.85;
    line-height: 1.5;
    word-break: break-word;
}

.pg-match-highlight {
    background: rgba(72, 187, 120, 0.25);
    color: var(--success-color, #48bb78);
    padding: 1px 4px;
    border-radius: 3px;
    font-weight: 600;
}

/* ============================================
   Actions Bar (Hint + Mulligan)
   ============================================ */

.pg-actions-bar {
    display: flex;
    gap: 8px;
    margin-bottom: var(--space-sm);
    justify-content: center;
}

.pg-action-btn {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    padding: 6px 14px;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    background: var(--glass-bg);
    color: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
}

.pg-action-btn:hover:not(:disabled) {
    border-color: rgba(102, 126, 234, 0.4);
    background: rgba(102, 126, 234, 0.08);
}

.pg-action-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* ============================================
   Input Area
   ============================================ */

.pg-input-area {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 14px 16px;
    background: var(--glass-bg);
    border-top: 1px solid var(--glass-border);
    backdrop-filter: blur(var(--glass-heavy-blur));
    -webkit-backdrop-filter: blur(var(--glass-heavy-blur));
    box-shadow: 0 -4px 24px var(--glass-shadow);
    display: flex;
    gap: 10px;
    align-items: flex-end;
    max-width: 640px;
    margin: 0 auto;
    z-index: var(--z-sticky);
}

.pg-input-wrapper {
    flex: 1;
}

.pg-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    background: var(--glass-dark);
    color: inherit;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    resize: none;
    outline: none;
    transition: border-color var(--transition-fast);
}

.pg-input:focus {
    border-color: rgba(102, 126, 234, 0.5);
}

.pg-input-footer {
    display: flex;
    justify-content: space-between;
    padding: 4px 2px 0;
}

.pg-char-count,
.pg-attempts-left {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    opacity: 0.5;
}

.pg-submit-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    background: var(--gradient-primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
    white-space: nowrap;
}

.pg-submit-btn:hover:not(:disabled) {
    opacity: 0.9;
    transform: translateY(-1px);
}

.pg-submit-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* ============================================
   Modals
   ============================================ */

.pg-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: var(--z-modal-backdrop);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-sm);
}

.pg-modal {
    background: var(--glass-light);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    max-width: 440px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    z-index: var(--z-modal);
}

body.dark-mode .pg-modal {
    background: rgba(15, 15, 35, 0.95);
    border-color: rgba(255, 255, 255, 0.15);
}

.pg-modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    color: inherit;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity var(--transition-fast);
    line-height: 1;
    min-width: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pg-modal-close:hover {
    opacity: 1;
}

.pg-modal-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.2rem;
    margin-bottom: var(--space-md);
    text-align: center;
}

/* ============================================
   Results Modal
   ============================================ */

.pg-results-header {
    text-align: center;
    margin-bottom: var(--space-md);
}

.pg-results-emoji {
    font-size: 4rem;
    margin-bottom: 12px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

.pg-results-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.5rem;
    font-weight: 900;
}

.pg-results-score {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.1rem;
    color: #48bb78;
    margin-top: 4px;
}

.pg-share-preview {
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: var(--space-md);
    overflow-x: auto;
}

body:not(.dark-mode) .pg-share-preview {
    background: rgba(0, 0, 0, 0.04);
}

.pg-share-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    line-height: 1.6;
    white-space: pre-wrap;
    margin: 0;
}

.pg-results-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: var(--space-md);
}

.pg-results-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    text-align: center;
    margin-bottom: var(--space-md);
}

.pg-stat-val {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
}

.pg-stat-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.5;
    margin-top: 2px;
}

/* ============================================
   Buttons
   ============================================ */

.pg-btn {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
}

.pg-btn--primary {
    background: var(--gradient-primary);
    color: #fff;
}

.pg-btn--primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.pg-btn--secondary {
    background: var(--glass-dark);
    border: 1px solid var(--glass-border);
    color: inherit;
}

.pg-btn--secondary:hover {
    border-color: rgba(102, 126, 234, 0.4);
}

.pg-btn--sm {
    padding: 6px 12px;
    font-size: 0.7rem;
    margin-top: 6px;
}

.pg-btn--danger {
    border-color: rgba(245, 101, 101, 0.4);
    color: #f56565;
}

.pg-btn--danger:hover {
    background: rgba(245, 101, 101, 0.1);
    border-color: rgba(245, 101, 101, 0.6);
}

.pg-setting-divider {
    border-top: 1px solid var(--glass-border);
    padding-top: var(--space-md);
}

/* ============================================
   Stats Chart
   ============================================ */

.pg-stats-best {
    text-align: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    margin-bottom: var(--space-md);
    color: #48bb78;
}

.pg-tier-chart {
    margin-top: var(--space-sm);
}

.pg-chart-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
    margin-bottom: 10px;
    text-align: center;
    opacity: 0.7;
}

.pg-chart-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.pg-chart-label {
    width: 28px;
    text-align: center;
    font-size: 1rem;
}

.pg-chart-bar-track {
    flex: 1;
    height: 20px;
    background: var(--glass-dark);
    border-radius: 4px;
    overflow: hidden;
}

.pg-chart-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
    min-width: 2px;
}

.pg-chart-count {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    width: 28px;
    text-align: right;
    opacity: 0.7;
}

/* ============================================
   Settings
   ============================================ */

.pg-setting-group {
    margin-bottom: var(--space-md);
}

.pg-setting-label {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.7rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    opacity: 0.6;
    display: block;
    margin-bottom: 6px;
}

.pg-select,
.pg-text-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    background: var(--glass-dark);
    color: inherit;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    outline: none;
    transition: border-color var(--transition-fast);
}

.pg-select:focus,
.pg-text-input:focus {
    border-color: rgba(102, 126, 234, 0.5);
}

/* ============================================
   Toasts
   ============================================ */

.pg-hint-toast,
.pg-error-toast,
.pg-warning-toast {
    position: fixed;
    bottom: 140px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    z-index: var(--z-tooltip);
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    max-width: 90%;
    text-align: center;
}

.pg-hint-toast {
    background: rgba(66, 153, 225, 0.95);
    color: #fff;
}

.pg-error-toast {
    background: rgba(245, 101, 101, 0.95);
    color: #fff;
}

.pg-warning-toast {
    background: rgba(237, 137, 54, 0.95);
    color: #fff;
}

.pg-hint-toast--visible,
.pg-error-toast--visible,
.pg-warning-toast--visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ============================================
   Generative UI: Streaming Area
   ============================================ */

.pg-streaming-area {
    margin-bottom: var(--space-sm);
}

.pg-streaming-card {
    background: var(--glass-bg);
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: var(--radius-md);
    padding: 14px;
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    box-shadow: 0 4px 24px rgba(102, 126, 234, 0.1);
}

.pg-streaming-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.pg-thinking-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pg-thinking-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #a5b4fc;
    animation: pg-thinking-pulse 1.4s infinite ease-in-out both;
}

.pg-thinking-dot:nth-child(1) { animation-delay: -0.32s; }
.pg-thinking-dot:nth-child(2) { animation-delay: -0.16s; }
.pg-thinking-dot:nth-child(3) { animation-delay: 0s; }

@keyframes pg-thinking-pulse {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

.pg-thinking-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    opacity: 0.7;
    margin-left: 6px;
}

.pg-streaming-timer {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    opacity: 0.5;
}

.pg-streaming-content {
    min-height: 20px;
}

.pg-streaming-cursor {
    width: 8px;
    height: 14px;
    background: #a5b4fc;
    display: inline-block;
    animation: pg-cursor-blink 1s step-end infinite;
    margin-top: 4px;
    border-radius: 1px;
}

@keyframes pg-cursor-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* ============================================
   Generative UI: Thinking Block
   ============================================ */

.pg-thinking-block {
    margin: 8px 0;
    border: 1px solid rgba(168, 85, 247, 0.2);
    border-radius: 6px;
    background: rgba(168, 85, 247, 0.05);
    overflow: hidden;
}

body.dark-mode .pg-thinking-block {
    background: rgba(168, 85, 247, 0.08);
    border-color: rgba(168, 85, 247, 0.25);
}

.pg-thinking-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 6px 10px;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    opacity: 0.8;
    transition: opacity var(--transition-fast);
}

.pg-thinking-toggle:hover {
    opacity: 1;
}

.pg-thinking-toggle-icon {
    font-size: 0.6rem;
    color: #a78bfa;
}

.pg-thinking-toggle-label {
    color: #a78bfa;
    font-weight: 600;
    letter-spacing: 0.5px;
}

body:not(.dark-mode) .pg-thinking-toggle-icon,
body:not(.dark-mode) .pg-thinking-toggle-label {
    color: #7c3aed;
}

.pg-thinking-token-count {
    margin-left: auto;
    opacity: 0.5;
    font-size: 0.6rem;
}

.pg-thinking-content {
    padding: 6px 10px 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    line-height: 1.5;
    color: #a78bfa;
    opacity: 0.7;
    max-height: 150px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    border-top: 1px solid rgba(168, 85, 247, 0.15);
}

body:not(.dark-mode) .pg-thinking-content {
    color: #7c3aed;
}

/* Streaming response text below thinking */
.pg-streaming-response {
    margin-top: 8px;
}

.pg-streaming-response-label {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.55rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    opacity: 0.4;
    margin-bottom: 4px;
}

.pg-streaming-response-text {
    font-size: 0.85rem;
    line-height: 1.5;
    word-break: break-word;
}

/* ============================================
   Generative UI: Tool Call Cards
   ============================================ */

.pg-tool-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    margin: 4px 0;
    transition: all var(--transition-fast);
}

.pg-tool-card--running {
    background: rgba(102, 126, 234, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.2);
    color: #a5b4fc;
}

.pg-tool-card--success,
.pg-tool-card--complete {
    background: rgba(72, 187, 120, 0.08);
    border: 1px solid rgba(72, 187, 120, 0.2);
    color: var(--success-color);
}

.pg-tool-card--error {
    background: rgba(245, 101, 101, 0.08);
    border: 1px solid rgba(245, 101, 101, 0.2);
    color: var(--error-color);
}

.pg-tool-icon {
    font-size: 0.8rem;
}

.pg-tool-card--running .pg-tool-icon {
    animation: pg-spin 2s linear infinite;
}

@keyframes pg-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.pg-tool-label {
    flex: 1;
}

.pg-tool-status {
    opacity: 0.6;
    text-transform: uppercase;
    font-size: 0.6rem;
    letter-spacing: 0.5px;
}

/* ============================================
   Generative UI: State Badges
   ============================================ */

.pg-attempt-state-badge {
    display: inline-block;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    padding: 2px 8px;
    border-radius: 4px;
    margin-bottom: 6px;
}

.pg-state-match {
    background: rgba(72, 187, 120, 0.15);
    color: var(--success-color);
    border: 1px solid rgba(72, 187, 120, 0.3);
}

.pg-state-miss {
    background: rgba(245, 101, 101, 0.1);
    color: var(--error-color);
    border: 1px solid rgba(245, 101, 101, 0.2);
}

/* ============================================
   Generative UI: Response Card & Similarity
   ============================================ */

.pg-attempt-response-card {
    margin-top: 6px;
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 6px;
    border: 1px solid var(--glass-border);
}

body.dark-mode .pg-attempt-response-card {
    background: rgba(255, 255, 255, 0.03);
}

.pg-response-label {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.55rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    opacity: 0.4;
    margin-bottom: 4px;
}

.pg-similarity-meter {
    height: 4px;
    background: var(--glass-dark);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 8px;
}

.pg-similarity-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 2px;
    transition: width 0.6s ease;
}

.pg-similarity-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.6rem;
    opacity: 0.4;
    margin-top: 3px;
}

/* ============================================
   Generative UI: Animations
   ============================================ */

.pg-attempt--animate {
    animation: pg-slide-in 0.3s ease-out;
}

@keyframes pg-slide-in {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.pg-block--animate {
    animation: pg-block-pop 0.3s ease-out backwards;
}

@keyframes pg-block-pop {
    from { transform: scale(0); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.pg-results-emoji--animate {
    animation: pg-emoji-bounce 0.6s ease-out;
}

@keyframes pg-emoji-bounce {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

/* ============================================
   Coach Panel (Strands Agent)
   ============================================ */

.pg-coach-panel {
    position: fixed;
    right: 12px;
    bottom: 120px;
    width: 320px;
    max-height: 400px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    backdrop-filter: blur(var(--glass-heavy-blur));
    -webkit-backdrop-filter: blur(var(--glass-heavy-blur));
    box-shadow: 0 8px 32px var(--glass-shadow);
    display: flex;
    flex-direction: column;
    z-index: var(--z-dropdown);
    overflow: hidden;
}

body.dark-mode .pg-coach-panel {
    background: rgba(15, 15, 35, 0.92);
}

.pg-coach-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--glass-border);
}

.pg-coach-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.pg-coach-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.5;
    line-height: 1;
}

.pg-coach-close:hover { opacity: 1; }

.pg-coach-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 200px;
}

.pg-coach-msg {
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 0.8rem;
    line-height: 1.4;
    word-break: break-word;
    max-width: 90%;
    animation: pg-slide-in 0.2s ease-out;
}

.pg-coach-msg--user {
    align-self: flex-end;
    background: rgba(102, 126, 234, 0.15);
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.pg-coach-msg--assistant {
    align-self: flex-start;
    background: var(--glass-dark);
    border: 1px solid var(--glass-border);
}

.pg-coach-msg--streaming::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 12px;
    background: #a5b4fc;
    animation: pg-cursor-blink 1s step-end infinite;
    margin-left: 2px;
    vertical-align: text-bottom;
    border-radius: 1px;
}

.pg-coach-tool-card {
    padding: 4px 8px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
    margin: 2px 0;
}

.pg-coach-tool-card--running {
    background: rgba(102, 126, 234, 0.08);
    color: #a5b4fc;
}

.pg-coach-tool-card--success {
    background: rgba(72, 187, 120, 0.08);
    color: var(--success-color);
}

.pg-coach-input-area {
    display: flex;
    gap: 6px;
    padding: 8px 10px;
    border-top: 1px solid var(--glass-border);
}

.pg-coach-input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    background: var(--glass-dark);
    color: inherit;
    font-size: 0.8rem;
    outline: none;
}

.pg-coach-input:focus {
    border-color: rgba(102, 126, 234, 0.4);
}

.pg-coach-send {
    background: var(--gradient-primary);
    border: none;
    border-radius: 6px;
    color: #fff;
    padding: 6px 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
}

/* ============================================
   Input Shake Animation (anti-cheat feedback)
   ============================================ */

.pg-input--shake {
    animation: pg-shake 0.4s ease-in-out;
}

@keyframes pg-shake {
    0%, 100% { transform: translateX(0); }
    10%, 50%, 90% { transform: translateX(-4px); }
    30%, 70% { transform: translateX(4px); }
}

/* ============================================
   Golf Score & Overlap Display
   ============================================ */

.pg-golf-score {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    color: #48bb78;
    background: rgba(72, 187, 120, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid rgba(72, 187, 120, 0.25);
}

.pg-attempt-overlap {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
    opacity: 0.5;
}

/* ============================================
   How to Play Modal
   ============================================ */

.pg-help-content {
    font-size: 0.85rem;
    line-height: 1.6;
}

.pg-help-section {
    margin-bottom: var(--space-md);
}

.pg-help-section:last-child {
    margin-bottom: 0;
}

.pg-help-heading {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 6px;
    color: #a5b4fc;
}

body:not(.dark-mode) .pg-help-heading {
    color: #667eea;
}

.pg-help-list {
    margin: 6px 0;
    padding-left: 20px;
}

.pg-help-list li {
    margin-bottom: 4px;
}

.pg-help-tiers {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
}

/* ============================================
   Responsive: Tablet (768px)
   ============================================ */

@media (max-width: 768px) {
    .pg-container {
        padding: var(--space-xs) var(--space-xs) 120px;
    }

    .pg-title {
        font-size: 1.4rem;
    }

    .pg-target-text {
        font-size: 1.1rem;
    }

    .pg-modal {
        max-width: 95%;
        padding: var(--space-md);
    }

    .pg-coach-panel {
        width: 280px;
    }

    .pg-attempt-header {
        gap: 6px;
    }

    .pg-streaming-card {
        padding: 10px;
    }
}

/* ============================================
   Responsive: Phone (480px) — iPhone 13 Pro = 390px
   ============================================ */

@media (max-width: 480px) {

    /* ---- Layout ---- */
    .pg-container {
        padding: 6px 8px 110px;
        padding-bottom: calc(110px + env(safe-area-inset-bottom, 0px));
    }

    /* ---- Header: stack title above actions ---- */
    .pg-header {
        margin-bottom: 8px;
    }

    .pg-title-row {
        flex-direction: column;
        gap: 6px;
    }

    .pg-title {
        font-size: 1.2rem;
    }

    .pg-header-actions {
        position: static;
        gap: 8px;
        justify-content: center;
    }

    .pg-icon-btn {
        padding: 8px;
        min-width: 40px;
        min-height: 40px;
    }

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

    .pg-subtitle {
        font-size: 0.72rem;
        margin-top: 2px;
    }

    /* ---- Model Status Bar ---- */
    .pg-model-bar {
        padding: 8px 12px;
        margin-bottom: 8px;
    }

    .pg-model-status {
        font-size: 0.72rem;
    }

    /* ---- Target Card ---- */
    .pg-target-card {
        padding: 12px 10px;
        margin-bottom: 10px;
        border-radius: var(--radius-md);
    }

    .pg-target-card:hover {
        transform: none; /* no hover lift on touch */
    }

    .pg-target-label {
        font-size: 0.6rem;
        letter-spacing: 1.5px;
        margin-bottom: 4px;
    }

    .pg-target-text {
        font-size: 0.95rem;
        line-height: 1.35;
    }

    .pg-target-meta {
        font-size: 0.68rem;
        margin-top: 6px;
    }

    /* ---- Attempts ---- */
    .pg-attempts {
        gap: 6px;
        margin-bottom: 6px;
    }

    .pg-attempt {
        padding: 8px 10px;
        border-radius: var(--radius-sm);
    }

    .pg-attempt:hover:not(.pg-attempt--empty) {
        transform: none; /* no hover lift on touch */
    }

    .pg-attempt-state-badge {
        font-size: 0.5rem;
        padding: 1px 6px;
        margin-bottom: 4px;
    }

    .pg-attempt-header {
        gap: 4px;
    }

    .pg-attempt-num {
        font-size: 0.68rem;
        min-width: 20px;
    }

    .pg-golf-score {
        font-size: 0.65rem;
        padding: 1px 5px;
    }

    .pg-attempt-len {
        font-size: 0.68rem;
    }

    .pg-attempt-tier {
        font-size: 0.6rem;
    }

    .pg-attempt-overlap {
        font-size: 0.58rem;
    }

    .pg-attempt-blocks {
        gap: 2px;
    }

    .pg-block {
        width: 14px;
        height: 14px;
        border-radius: 3px;
    }

    .pg-attempt-prompt {
        font-size: 0.72rem;
        padding: 3px 6px;
        margin-top: 4px;
    }

    .pg-attempt-response {
        font-size: 0.72rem;
    }

    .pg-attempt-response-card {
        padding: 6px 8px;
        margin-top: 4px;
    }

    .pg-response-label {
        font-size: 0.5rem;
    }

    .pg-similarity-label {
        font-size: 0.55rem;
    }

    /* Tool cards inside attempts */
    .pg-tool-card {
        font-size: 0.68rem;
        padding: 4px 8px;
        gap: 6px;
    }

    .pg-tool-status {
        display: none;
    }

    .pg-tool-icon {
        font-size: 0.72rem;
    }

    /* ---- Actions Bar ---- */
    .pg-actions-bar {
        margin-bottom: 6px;
        gap: 6px;
    }

    .pg-action-btn {
        font-size: 0.65rem;
        padding: 8px 12px;
        min-height: 36px;
    }

    /* ---- Streaming Area ---- */
    .pg-streaming-card {
        padding: 8px;
        border-radius: var(--radius-sm);
    }

    .pg-streaming-header {
        margin-bottom: 6px;
    }

    .pg-thinking-label {
        font-size: 0.65rem;
    }

    .pg-streaming-timer {
        font-size: 0.65rem;
    }

    .pg-thinking-block {
        margin: 6px 0;
    }

    .pg-thinking-content {
        max-height: 120px;
        font-size: 0.65rem;
        padding: 4px 8px 6px;
    }

    .pg-streaming-response-text {
        font-size: 0.78rem;
    }

    /* ---- Input Area (fixed bottom bar) ---- */
    .pg-input-area {
        padding: 8px 10px;
        padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
        gap: 8px;
    }

    .pg-input {
        font-size: 16px; /* prevents iOS zoom on focus */
        padding: 10px;
        border-radius: 8px;
    }

    .pg-input-footer {
        padding: 3px 1px 0;
    }

    .pg-char-count,
    .pg-attempts-left {
        font-size: 0.62rem;
    }

    .pg-submit-btn {
        padding: 10px 14px;
        font-size: 0.75rem;
        border-radius: 8px;
        min-height: 44px; /* iOS minimum touch target */
    }

    .pg-submit-btn svg {
        display: none;
    }

    /* ---- Modals: near-fullscreen on phone ---- */
    .pg-modal-overlay {
        padding: 0;
        align-items: flex-end; /* slide up from bottom */
    }

    .pg-modal {
        max-width: 100%;
        width: 100%;
        margin: 0;
        padding: 16px 14px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        max-height: 92vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.4);
    }

    .pg-modal-close {
        top: 8px;
        right: 10px;
        min-width: 44px;
        min-height: 44px;
    }

    .pg-modal-title {
        font-size: 1rem;
        margin-bottom: 12px;
    }

    /* ---- Results Modal ---- */
    .pg-results-emoji {
        font-size: 3rem;
        margin-bottom: 8px;
    }

    .pg-results-title {
        font-size: 1.15rem;
    }

    .pg-results-score {
        font-size: 0.95rem;
    }

    .pg-results-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .pg-stat-val {
        font-size: 1.1rem;
    }

    .pg-stat-label {
        font-size: 0.6rem;
    }

    .pg-share-preview {
        padding: 10px;
    }

    .pg-share-text {
        font-size: 0.68rem;
    }

    .pg-results-actions {
        gap: 6px;
        flex-wrap: wrap;
    }

    .pg-btn {
        padding: 10px 16px;
        font-size: 0.75rem;
        min-height: 44px;
    }

    /* ---- Stats Modal ---- */
    .pg-stats-best {
        font-size: 0.78rem;
    }

    .pg-chart-title {
        font-size: 0.72rem;
    }

    .pg-chart-bar-track {
        height: 16px;
    }

    /* ---- Help Modal ---- */
    .pg-help-content {
        font-size: 0.8rem;
        line-height: 1.5;
    }

    .pg-help-heading {
        font-size: 0.68rem;
    }

    .pg-help-list {
        padding-left: 16px;
    }

    .pg-help-list li {
        margin-bottom: 3px;
    }

    .pg-help-tiers {
        font-size: 0.68rem;
        gap: 3px;
    }

    /* ---- Settings Modal ---- */
    .pg-setting-label {
        font-size: 0.65rem;
    }

    .pg-select,
    .pg-text-input {
        font-size: 16px; /* prevents iOS zoom on focus */
        padding: 10px 12px;
    }

    .pg-btn--sm {
        min-height: 36px;
        padding: 8px 12px;
    }

    /* ---- Coach Panel: full-width sheet ---- */
    .pg-coach-panel {
        position: fixed;
        right: 0;
        left: 0;
        bottom: 0;
        width: 100%;
        max-height: 55vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        z-index: var(--z-modal);
    }

    .pg-coach-messages {
        min-height: 120px;
    }

    .pg-coach-msg {
        font-size: 0.75rem;
    }

    .pg-coach-input {
        font-size: 16px; /* prevents iOS zoom on focus */
    }

    /* ---- Toasts: above input bar ---- */
    .pg-warning-toast,
    .pg-hint-toast,
    .pg-error-toast {
        bottom: calc(100px + env(safe-area-inset-bottom, 0px));
        font-size: 0.78rem;
        padding: 8px 14px;
        max-width: 94%;
    }
}

/* ============================================
   Reduced Motion
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    .pg-submit-btn,
    .pg-btn--primary,
    .pg-model-progress-bar,
    .pg-chart-bar,
    .pg-similarity-fill,
    .pg-tool-card {
        transition: none;
    }

    .pg-hint-toast,
    .pg-error-toast {
        transition: opacity 0.1s;
    }

    .pg-thinking-dot,
    .pg-streaming-cursor,
    .pg-coach-msg--streaming::after,
    .pg-tool-card--running .pg-tool-icon {
        animation: none;
    }

    .pg-attempt--animate,
    .pg-block--animate,
    .pg-results-emoji--animate,
    .pg-coach-msg,
    .pg-input--shake {
        animation: none;
    }
}
