@import url('https://fonts.googleapis.com/css2?family=Pixelify+Sans:wght@400;700&display=swap');

:root{
    --cell-h: 4.8vh;
    --cell: min(4.5vw, var(--cell-h));
  --wall: #0b3b8b;
  --bg: #000;
  --dot: #f7c948;
  --power: #ff6b6b;
  --pac: #ffd43b;
  --ghost1: #ff4d4f;
  --ghost2: #7ed321;
  --ghost3: #5dade2;
  --ghost4: #a084d6;
    --dpad-size: 50px;
}


* {
    box-sizing: border-box; margin:0; padding:0;
}
body {
    font-family: 'Pixelify Sans', sans-serif;
    font-weight: 400;
    font-style: normal;
    background: radial-gradient(ellipse at top, #0b1533 0%, #000 60%);
    color: #eee;
    min-height: 100vh;
    display:flex;
    flex-direction:column;
    justify-content: center;
    align-items:center;
    gap:12px;
    padding:18px;
}

main {
    display: flex;
    flex-direction: column;
    align-items: center;
    /* This makes the main section take up all available vertical space */
    flex-grow: 1;
    /* Ensures main doesn't exceed screen size */
    overflow: hidden;
}

header h1 {
    font-size: 2.5em; /* Large title */
}

.hud > div {
    font-size: 1.1em;
    padding: 8px 12px; /* Slightly larger hit area */
}

.controls p {
    font-size: 1em;
}

header { text-align:center; }
.hud { display:flex; gap:12px; justify-content:center; margin-top:8px;}
.hud > div { background: rgba(255,255,255,0.04); padding:6px 10px; border-radius:6px; min-width:90px; text-align:center; }

.grid {
  display: grid;
  grid-template-columns: repeat(15, var(--cell));
  grid-auto-rows: var(--cell);
  gap: 2px;
  background: #081026;
  padding: 10px;
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.6);
}

.cell {
  width: var(--cell);
  height: var(--cell);
  background: var(--bg);
  border-radius: 4px;
  position:relative;
}

/* walls */
.wall {
    box-shadow: inset 0 -3px 6px rgba(255,255,255,0.02);
    border: 2px solid rgba(255,255,255,0.02);
    background: var(--wall) linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
    border-radius: 6px;
}

/* dot */
.dot::after {
  content: "";
  width: 6px;
  height: 6px;
  background: var(--dot);
  border-radius: 50%;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%,-50%);
  box-shadow: 0 0 6px rgba(247,201,72,0.6);
}
.power::after {
    content: "";
    width: 86%;
    height: 86%;
    /* Keep positioning properties */
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%,-50%);

    /* Ensure no conflicting styles from old dot/power pellet setup */
    background-color: transparent;
    border-radius: 0;
    box-shadow: none;
}
/* power pellet */
/* Custom Power Pellet Images */
.power-1::after {
    background-image: url('assets/img/flutter.png');
    background-size: contain;
    background-repeat: no-repeat;
}

.power-2::after {
    background-image: url('assets/img/kotlin.png');
    background-size: contain;
    background-repeat: no-repeat;
}

.power-3::after {
    background-image: url('assets/img/android.png');
    background-size: contain;
    background-repeat: no-repeat;
}

.power-4::after {
    background-image: url('assets/img/react.png');
    background-size: contain;
    background-repeat: no-repeat;
}
.power-5::after {
    background-image: url('assets/img/firebase.png');
    background-size: contain;
    background-repeat: no-repeat;
}

/* pacman */
.pacman {
    position:absolute;
    width: 100%; /* Use 100% of the cell size for the GIF */
    height: 100%;
    left: 0; /* Align perfectly in the cell */
    top: 0;
    /* --- GIF PROPERTIES --- */
    background-image: url('assets/img/pac-man.gif');
    background-size: contain; /* Ensures the whole GIF is visible */
    background-repeat: no-repeat;
    background-position: center;
    /* ---------------------- */

    border-radius: 0; /* No need for a circle border */
    background-color: transparent; /* Ensure the background is clear */
    box-shadow: none; /* Remove the yellow glow */
    z-index: 5;

    /* Keep the transform for rotation (direction) and transition for smoothness */
    transform: rotate(0deg);
    transition: transform 120ms linear;
}

/* Ghost styles */
.ghost {
    background-image: url('assets/img/ghost.gif');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
  position:absolute;
  width: 86%;
  height: 86%;
  left: 7%;
  top: 7%;
  border-radius: 40% 40% 8% 8% / 40% 40% 16% 16%;
  display:flex;
  align-items:center;
  justify-content:center;
  z-index:4;
  box-shadow: 0 6px 18px rgba(0,0,0,0.4);
  color: #fff;
  font-weight:700;
  text-shadow: 0 -1px 0 rgba(0,0,0,0.4);
  transition: filter 150ms linear;
}



/* frightened ghost */
.ghost.frightened {
    background-image: url('assets/img/ghost-fright.gif');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
  filter: brightness(1.1);
}

/* eaten ghost (eyes) */
.ghost.eaten {
  background: transparent;
  color: transparent;
  box-shadow:none;
}
.dpad-container {
    margin-top: 20px;
    display: none; /* Hidden by default (desktop) */
    width: 150px; /* Fixed size for the whole cross */
    height: 150px;
    touch-action: manipulation;
    background-color: var(--wall); /* Console casing color */
    border-radius: 15px;
    padding: 0;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5), 0 5px 15px rgba(0,0,0,0.5);
}
.dpad {
    display: grid;
    /* 3x3 grid with no gap to make the cross cohesive */
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
    width: 100%;
    height: 100%;
    gap: 0;
    justify-content: stretch;
    align-items: stretch;
}
.dpad-btn {
    /* Retro base style */
    background-color: var(--bg);
    color: var(--dot);
    /* 3D button effect: Light top/left, Dark bottom/right */
    border-radius: 0; /* Ensures the segments form a sharp cross */
    font-family: 'Pixelify Sans', sans-serif;
    font-size: 1.8em;
    font-weight: 700;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    user-select: none;
    box-shadow: none;
    transition: all 0.05s ease-out;
}

/* --- Grid Area Assignment and Alignment Fixes --- */

/* UP: Top-center segment. Remove bottom border for cohesion with center. */
.dpad-up {
    grid-area: 1 / 2 / 2 / 3;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
}
/* LEFT: Center-left segment. Remove right border for cohesion with center. */
.dpad-left {
    grid-area: 2 / 1 / 3 / 2;
    border-right: none;
    border-radius: 6px 0 0 6px;
}
/* RIGHT: Center-right segment. Remove left border for cohesion with center. */
.dpad-right {
    grid-area: 2 / 3 / 3 / 4;
    border-left: none;
    border-radius: 0 6px 6px 0;
}
/* DOWN: Bottom-center segment. Remove top border for cohesion with center. */
.dpad-down {
    grid-area: 3 / 2 / 4 / 3;
    border-top: none;
    border-radius: 0 0 6px 6px;
}

/* Active state (when pressed - buttons look sunken) */
.dpad-btn:active {
    background-color: #5c5c5c;
    /* Invert borders for a realistic "pressed" look */
    border-top: 3px solid #505050;
    border-left: 3px solid #505050;
    border-right: 3px solid #b0b0b0;
    border-bottom: 3px solid #b0b0b0;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.4);
    transform: none;
}

/* FIX: When pressed, make the internal borders (where they meet the empty center) blend with the pressed background color */
.dpad-up:active { border-bottom: 3px solid #5c5c5c; }
.dpad-down:active { border-top: 3px solid #5c5c5c; }
.dpad-left:active { border-right: 3px solid #5c5c5c; }
.dpad-right:active { border-left: 3px solid #5c5c5c; }

/* small helper */
.controls { margin-top:10px; text-align:center; color: #cdd6f4; max-width:680px;}
footer { margin-top:8px; color: rgba(255,255,255,0.5); font-size:12px; }

@media (max-width: 600px) {
    /* GENERAL ADJUSTMENTS */
    body {
        padding: 10px 0; /* Reduce padding on body */
        gap: 8px; /* Reduce gap between sections */
    }
    main {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    .dpad-container {
        display: block;
    }
    .controls {
        display: none;
    }

    /* HEADER TEXT */
    header h1 {
        font-size: 1.8em; /* Shrink the main title */
    }

    /* HUD ELEMENTS */
    .hud {
        /* Allow HUD items to wrap/stack if necessary */
        flex-wrap: wrap;
        justify-content: space-around; /* Distribute items better */
        gap: 8px;
    }

    .hud > div {
        /* Slightly smaller font for HUD elements */
        font-size: 0.9em;
        padding: 6px 8px;
        min-width: 70px; /* Allow them to shrink more */
    }

    /* CONTROLS TEXT */
    .controls p {
        font-size: 0.85em; /* Shrink control instructions */
        padding: 0 10px; /* Add some side padding if text is wide */
    }

    /* FOOTER TEXT */
    footer small {
        font-size: 10px;
    }
}