/* Skip Stones - Aesthetic Minimalist Styling */
/* Section 9 Visual Direction & Section 13 Usability */

:root {
    --primary: #0284c7;
    --primary-light: #38bdf8;
    --primary-hover: #0369a1;
    --gold: #f59e0b;
    --gold-light: #fef08a;
    --bg-dark: #0f172a;
    --card-bg: rgba(15, 23, 42, 0.82);
    --card-border: rgba(255, 255, 255, 0.18);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --touch-min: 44px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    background: #021424;
    color: var(--text-main);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    overflow: hidden;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 480px;
    max-height: 920px;
    aspect-ratio: 9 / 16;
    background: #0f172a;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

@media (min-width: 540px) {
    #game-wrapper {
        border-radius: var(--radius-lg);
        height: 94vh;
        border: 1px solid rgba(255, 255, 255, 0.1);
    }
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

/* UI Overlay Layers */
.ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 20, 32, 0.78);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 24px;
    pointer-events: auto;
    z-index: 20;
    transition: opacity 0.25s ease;
}

.hidden {
    display: none !important;
}

/* Typography & Headings */
h1.title {
    font-size: 2.4rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #ffffff 30%, #38bdf8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 6px;
    text-align: center;
}

p.subtitle {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 24px;
    text-align: center;
}

h2 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 18px;
    color: #ffffff;
}

/* Buttons (Accessibility minimum >= 44px) */
.btn {
    min-height: var(--touch-min);
    min-width: var(--touch-min);
    padding: 12px 28px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: linear-gradient(135deg, #38bdf8, #0284c7);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(2, 132, 199, 0.4);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #60a5fa, #0369a1);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-main);
    border: 1px solid var(--card-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.4);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.35);
}

.btn-icon {
    padding: 10px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--card-border);
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

/* Glass Cards */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

/* HUD Styling */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    z-index: 15;
}

.hud-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.hud-skips {
    font-size: 1.8rem;
    font-weight: 800;
    color: #ffffff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
    line-height: 1;
}

.hud-score {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gold-light);
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7);
}

.hud-distance {
    font-size: 0.95rem;
    color: #bae6fd;
    font-weight: 600;
}

.hud-combo {
    align-self: flex-start;
    padding: 3px 10px;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 800;
    border-radius: 20px;
    margin-top: 4px;
    letter-spacing: 0.05em;
    animation: bounceCombo 0.4s ease;
}

@keyframes bounceCombo {
    0% { transform: scale(0.8); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1.0); }
}

.hud-right {
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: auto;
}

.hud-best-badge {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    background: rgba(15, 23, 42, 0.6);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--card-border);
}

/* Stone Picker in Menu */
.stone-section {
    margin: 16px 0;
    width: 100%;
}

.stone-section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stone-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.stone-chip {
    min-height: var(--touch-min);
    padding: 8px 14px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--card-border);
    color: var(--text-main);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.15s ease;
}

.stone-chip.selected {
    background: rgba(56, 189, 248, 0.25);
    border-color: #38bdf8;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

.stone-chip.locked {
    opacity: 0.45;
    cursor: not-allowed;
}

.stone-preview {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: inline-block;
}

/* Menu Stats Card */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
    text-align: center;
}

.stat-box {
    background: rgba(255, 255, 255, 0.05);
    padding: 10px 6px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}

.stat-val {
    font-size: 1.1rem;
    font-weight: 700;
    color: #ffffff;
}

/* Results Screen */
.result-box {
    margin: 18px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 8px;
}

.result-score-highlight {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--gold-light);
}

.new-best-badge {
    align-self: center;
    background: linear-gradient(135deg, #ec4899, #f43f5e);
    color: #ffffff;
    font-weight: 800;
    font-size: 0.85rem;
    padding: 4px 14px;
    border-radius: 20px;
    box-shadow: 0 0 15px rgba(244, 63, 94, 0.5);
    animation: pulseBest 0.8s infinite alternate;
}

@keyframes pulseBest {
    from { transform: scale(0.95); }
    to { transform: scale(1.05); }
}

/* Settings Form */
.settings-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 16px 0;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: var(--touch-min);
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #334155;
    transition: .25s;
    border-radius: 28px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .25s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #0284c7;
}

input:checked + .slider:before {
    transform: translateX(22px);
}

/* Tutorial Animation Demo */
.tutorial-gesture-container {
    width: 180px;
    height: 120px;
    margin: 16px auto;
    position: relative;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.05);
    border: 1px dashed rgba(255, 255, 255, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
}

.demo-hand {
    position: absolute;
    font-size: 28px;
    animation: dragDemo 2.2s infinite ease-in-out;
}

@keyframes dragDemo {
    0% { transform: translate(-35px, 20px) scale(0.9); opacity: 0.4; }
    20% { transform: translate(-35px, 20px) scale(1.1); opacity: 1; }
    60% { transform: translate(35px, -15px) scale(1.1); opacity: 1; }
    80% { transform: translate(35px, -15px) scale(0.9); opacity: 0; }
    100% { transform: translate(-35px, 20px) scale(0.9); opacity: 0; }
}

.tutorial-hints {
    font-size: 0.95rem;
    line-height: 1.5;
    color: #bae6fd;
    text-align: center;
    margin-bottom: 20px;
}

/* Real-time Debug Panel */
#debug-panel {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: rgba(0, 0, 0, 0.85);
    border: 1px solid rgba(56, 189, 248, 0.4);
    border-radius: var(--radius-sm);
    padding: 10px;
    font-family: monospace;
    font-size: 11px;
    color: #38bdf8;
    pointer-events: none;
    z-index: 30;
    min-width: 170px;
}

.debug-row {
    display: flex;
    justify-content: space-between;
    margin: 2px 0;
}

.telemetry-ok {
    color: #4ade80;
    font-weight: bold;
}

.telemetry-warn {
    color: #f87171;
    font-weight: bold;
}
