/* ============================================================
   Custom Whack! — Stylesheet
   Design System: Pacman Retro Arcade (DESIGN.md)
   Craft rules: typography.md, animation-discipline.md,
                accessibility-baseline.md, laws-of-ux.md
   ============================================================ */

:root {
    /* Warna Pacman */
    --primary: #2A3FE5;
    --secondary: #F4B9B0;
    --success: #16A34A;
    --warning: #D97706;
    --danger: #DC2626;
    --surface: #000000;
    --text: #111827;
    --neutral: #000000;

    /* Turunan */
    --bg-body: #0a0a1a;
    --border-color: #2A3FE5;
    --shadow-retro: 4px 4px 0 #111827;

    /* Tipografi */
    --font-pixel: 'Press Start 2P', 'Courier New', monospace;
    --font-mono: 'Space Mono', 'Courier New', monospace;

    /* Spacing 8pt baseline */
    --space-1: 8px;
    --space-2: 16px;
    --space-3: 24px;
    --space-4: 32px;
    --space-5: 48px;
    --space-6: 64px;

    --radius-sm: 0;
    --radius-md: 0;
    --radius-lg: 0;

    --duration-instant: 100ms;
    --duration-confirm: 150ms;
    --ease-m3-standard: cubic-bezier(0.2, 0, 0, 1);
    --touch-target-min: 48px;
}

/* ---------- Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .mole-task.active,
    .mole-image.active {
        animation: none;
        transform: none;
        opacity: 1;
    }

    .whack-burst {
        opacity: 0;
    }
}

/* ---------- Base Reset ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 100%;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: var(--font-mono);
    font-size: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
    line-height: 1.6;
    letter-spacing: 0;
    color: var(--text);
    background-color: var(--bg-body);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
}

/* ---------- Typography ---------- */
.game-title {
    font-family: var(--font-pixel);
    font-size: clamp(2rem, 1.5rem + 2.5vw, 3.5rem);
    letter-spacing: -0.025em;
    line-height: 1.1;
    color: var(--primary);
    text-shadow: 4px 4px 0 #000;
    text-align: center;
    margin-bottom: var(--space-1);
}

.game-subtitle {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    letter-spacing: 0.015em;
    color: var(--secondary);
    text-align: center;
}

.label {
    font-family: var(--font-pixel);
    font-size: 0.6875rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--secondary);
    display: block;
}

.value {
    font-family: var(--font-pixel);
    font-size: 1.5rem;
    letter-spacing: -0.015em;
    line-height: 1.2;
    color: white;
    display: block;
    margin-top: var(--space-1);
}

/* ---------- Buttons ---------- */
.btn {
    font-family: var(--font-pixel);
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: var(--space-2) var(--space-3);
    border: 3px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--duration-instant) var(--ease-m3-standard);
    min-height: var(--touch-target-min);
    min-width: var(--touch-target-min);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    user-select: none;
    background: black;
    color: white;
    box-shadow: var(--shadow-retro);
}

.btn:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

.btn:hover:not(:disabled) {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 #111827;
}

.btn:active:not(:disabled) {
    transform: translate(4px, 4px);
    box-shadow: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
    background: #333;
    border-color: #555;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 4px 4px 0 #1a2fb0;
}

.btn-primary:hover:not(:disabled) {
    background: #1f2fb0;
}

.btn-secondary {
    background: transparent;
    color: var(--secondary);
    border-color: var(--secondary);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--secondary);
    color: black;
}

.btn-ghost {
    background: transparent;
    box-shadow: none;
    border-color: transparent;
    color: var(--secondary);
}

.btn-ghost:hover:not(:disabled) {
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* ---------- Layout ---------- */
.game-container {
    width: 100%;
    max-width: 800px;
    padding: var(--space-3);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-4);
    margin-top: var(--space-3);
}

.game-header {
    padding: var(--space-4) var(--space-2) var(--space-2);
    width: 100%;
    text-align: center;
    border-bottom: 2px dashed var(--primary);
}

.game-footer {
    margin-top: auto;
    padding: var(--space-3);
    width: 100%;
    text-align: center;
    font-size: 0.75rem;
    color: var(--secondary);
    letter-spacing: 0.02em;
    border-top: 2px dashed var(--primary);
}

/* ---------- Settings Panel ---------- */
.settings-panel {
    width: 100%;
    background: var(--surface);
    border: 2px dashed var(--primary);
    padding: var(--space-2);
    color: var(--secondary);
}

.settings-summary {
    font-family: var(--font-pixel);
    font-size: 0.75rem;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.settings-summary::-webkit-details-marker {
    display: none;
}

.settings-content {
    margin-top: var(--space-2);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.mode-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

.mode-toggle label {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

.mode-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.mode-section label {
    font-size: 0.75rem;
    font-weight: bold;
}

.mode-section textarea {
    width: 100%;
    background: black;
    color: white;
    border: 2px solid var(--primary);
    padding: var(--space-1);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    resize: vertical;
}

.mode-section input[type="file"] {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--secondary);
    background: black;
    border: 2px solid var(--primary);
    padding: var(--space-1);
}

.image-preview {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    margin-top: var(--space-1);
}

.image-preview img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border: 2px solid var(--primary);
    background: black;
}

.hint {
    font-size: 0.625rem;
    opacity: 0.8;
}

/* ---------- Scoreboard ---------- */
.scoreboard {
    display: flex;
    justify-content: space-around;
    width: 100%;
    gap: var(--space-2);
    padding: var(--space-2);
    background: var(--surface);
    border: 2px dashed var(--primary);
    box-shadow: var(--shadow-retro);
}

.score-item {
    text-align: center;
    flex: 1;
}

#livesDisplay {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: var(--space-1);
}

#livesDisplay svg {
    width: 24px;
    height: 24px;
    filter: drop-shadow(2px 2px 0 #000);
}

/* ---------- Hole Grid ---------- */
.hole-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-3);
    width: 100%;
    max-width: 600px;
    padding: var(--space-3);
    background: var(--surface);
    border: 2px dashed var(--secondary);
}

@media (min-width: 600px) {
    .hole-grid {
        gap: var(--space-4);
        padding: var(--space-4);
    }
}

.hole {
    position: relative;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    min-width: var(--touch-target-min);
    min-height: var(--touch-target-min);
    width: 100%;
    height: 100%;
}

.hole-bg {
    position: absolute;
    width: 90%;
    height: 90%;
    background: radial-gradient(ellipse at center, #0a0a1a 0%, #0f3460 70%);
    border-radius: 50%;
    border: 3px solid var(--primary);
    box-shadow: inset 0 8px 15px rgba(0, 0, 0, 0.8), 0 0 10px rgba(42, 63, 229, 0.4);
    z-index: 1;
}

.mole-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 85%;
    height: 85%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    pointer-events: none;
}

.mole-task {
    font-family: var(--font-pixel);
    font-size: 0.5625rem;
    letter-spacing: -0.01em;
    line-height: 1.2;
    color: white;
    background: var(--primary);
    border: 2px solid white;
    padding: var(--space-1);
    text-align: center;
    max-width: 100%;
    word-break: break-word;
    box-shadow: 4px 4px 0 #1a2fb0;
    transform: translateY(100%) scale(0.5);
    opacity: 0;
    transition: opacity var(--duration-confirm) var(--ease-m3-standard);
    pointer-events: none;
}

.mole-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    border: 3px solid var(--primary);
    box-shadow: 4px 4px 0 #1a2fb0;
    background: black;
    transform: translateY(100%) scale(0.5);
    opacity: 0;
    transition: opacity var(--duration-confirm) var(--ease-m3-standard);
    pointer-events: none;
}

.mole-task.active,
.mole-image.active {
    animation: moleRise var(--duration-confirm) linear forwards;
    opacity: 1;
}

@keyframes moleRise {
    0% {
        transform: translateY(100%) scale(0.3);
        opacity: 0;
    }

    60% {
        transform: translateY(-20%) scale(1.1);
        opacity: 1;
    }

    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.whack-burst {
    position: absolute;
    width: 60%;
    height: 60%;
    z-index: 20;
    pointer-events: none;
    opacity: 0;
    transform: scale(0);
}

.whack-burst.show {
    animation: whackPop 0.3s ease-out forwards;
}

@keyframes whackPop {
    0% {
        opacity: 1;
        transform: scale(0.2);
    }

    100% {
        opacity: 0;
        transform: scale(1.5);
    }
}

.controls {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
    justify-content: center;
}

/* ---------- Game Over Alert ---------- */
.game-over-alert {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    transition: opacity var(--duration-confirm) ease-out;
    pointer-events: none;
}

.game-over-alert.show {
    opacity: 1;
    pointer-events: auto;
}

.game-over-content {
    background: var(--surface);
    border: 3px solid var(--primary);
    box-shadow: 6px 6px 0 #1a2fb0, 0 0 30px rgba(42, 63, 229, 0.5);
    padding: var(--space-4) var(--space-5);
    text-align: center;
    max-width: 360px;
    width: 90%;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.game-over-title {
    font-family: var(--font-pixel);
    font-size: 1.2rem;
    letter-spacing: -0.02em;
    color: var(--primary);
    text-shadow: 2px 2px 0 #000;
}

.game-over-score {
    font-family: var(--font-pixel);
    font-size: 0.9rem;
    color: white;
}

.game-over-message {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--secondary);
}

@media (prefers-reduced-motion: reduce) {
    .game-over-alert {
        transition: none;
    }
}