/* =========================================================
   ODYS MENTORS — brand colors. Change these to rebrand.
   Pulled from the odysmentors.com palette:
   fresh green, cream background, charcoal CTAs.
   ========================================================= */
:root {
  --brand-primary:    #4ea65b;  /* Odys green — maze walls            */
  --brand-secondary:  #2f7d43;  /* deep green — gradients / shadows   */
  --brand-background: #edefce;  /* cream — page background            */
  --brand-accent:     #8fe05a;  /* bright green — Pac-Man             */

  /* Derived / neutral tones (usually no need to edit) */
  --charcoal:   #232b24;        /* near-black brand CTA color         */
  --card-bg:    #ffffff;        /* clean white game card              */
  --maze-bg:    #1d241e;        /* dark maze so the game pops         */
  --dot-color:  #edefce;        /* cream pellets                      */
  --text:       #232b24;        /* charcoal text on light card        */
  --text-muted: #6f7a6c;        /* muted label text                  */
  --radius:     22px;
  --shadow:     0 24px 60px rgba(35, 43, 36, 0.18);
}

/* Animatable angle used for Pac-Man's chomping mouth */
@property --mouth {
  syntax: "<angle>";
  inherits: false;
  initial-value: 45deg;
}

/* =========================================================
   LAYOUT — center everything; clean modern premium look.
   ========================================================= */
* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  font-family: "Poppins", system-ui, -apple-system, sans-serif;
  color: var(--text);
  /* Soft green glow on the cream background */
  background:
    radial-gradient(900px 520px at 50% -8%, rgba(78, 166, 91, 0.22), transparent 62%),
    var(--brand-background);
}

/* The card / container holding the game */
.card {
  position: relative;
  width: 100%;
  max-width: 460px;
  background: var(--card-bg);
  border: 1px solid rgba(35, 43, 36, 0.06);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px;
}

/* =========================================================
   TOP SECTION — "odys | mentors" lockup + title
   ========================================================= */
.branding { text-align: center; margin-bottom: 18px; }

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

/* Odys logo mark (PNG image, with SVG fallback set by script.js) */
.logo-mark {
  width: 34px;
  height: 34px;
  object-fit: contain;
  display: block;
}

.logo-text {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1;
}
.logo-odys { color: var(--charcoal); font-weight: 800; }
.logo-div  { color: rgba(35, 43, 36, 0.3); margin: 0 7px; font-weight: 400; }
.logo-sub  { color: var(--charcoal); font-weight: 500; }

.title {
  margin: 14px 0 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--brand-secondary);
}

.tagline {
  margin: 6px 0 0;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
}

/* =========================================================
   MIDDLE SECTION — HUD (score, status, lives)
   ========================================================= */
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 20px 0 16px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 64px;
  padding: 8px 12px;
  border-radius: 14px;
  background: rgba(78, 166, 91, 0.10);
}

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  color: var(--text-muted);
}

.stat-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--brand-secondary);
}

.status {
  flex: 1;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

/* =========================================================
   GAME BOARD — responsive maze grid (--cols set by JS)
   ========================================================= */
.board-wrap { position: relative; display: flex; justify-content: center; }

.board {
  position: relative;            /* anchor for the absolutely-placed sprites */
  display: grid;
  grid-template-columns: repeat(var(--cols, 10), 1fr);
  gap: 2px;
  width: 100%;
  aspect-ratio: var(--cols, 10) / var(--rows, 10);
  padding: 8px;
  border-radius: 16px;
  background: var(--maze-bg);
  border: 1px solid rgba(35, 43, 36, 0.08);
}

/* =========================================================
   SPRITES — persistent wrappers that glide between cells.
   JS sets their size + transform; the transition makes the
   move smooth. Duration matches the step speed (set by JS).
   ========================================================= */
.sprite {
  position: absolute;
  top: 0;
  left: 0;
  will-change: transform;
}
.player-sprite { z-index: 3; transition: transform var(--player-move, 260ms) linear; }
.ghost-sprite  { z-index: 2; transition: transform var(--ghost-move, 340ms) linear; }

/* A single maze cell */
.cell { position: relative; }

/* Wall cell — Odys green */
.cell.wall {
  background: linear-gradient(180deg, var(--brand-primary), var(--brand-secondary));
  border-radius: 4px;
  box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.25);
}

/* Dot — a small cream pellet centered in the cell */
.cell.dot::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 24%;
  height: 24%;
  border-radius: 50%;
  background: var(--dot-color);
  box-shadow: 0 0 5px rgba(237, 239, 206, 0.7);
  animation: pop 0.2s ease-out;
}

/* Dot collection pop animation */
@keyframes pop {
  from { transform: scale(0.2); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* =========================================================
   PAC-MAN — bright green circle with an animated mouth.
   ========================================================= */
.player {
  position: absolute;
  inset: 6%;
  border-radius: 50%;
  z-index: 3;
  background: conic-gradient(
    from 90deg,
    transparent 0 var(--mouth),
    var(--brand-accent) var(--mouth) calc(360deg - var(--mouth)),
    transparent calc(360deg - var(--mouth)) 360deg
  );
  filter: drop-shadow(0 0 6px rgba(143, 224, 90, 0.7));
  transition: transform 0.15s linear;
}

/* Chomp open/close while playing */
.player.chomping { animation: chomp 0.35s steps(1, end) infinite; }
@keyframes chomp {
  0%, 100% { --mouth: 48deg; }  /* mouth open  */
  50%      { --mouth: 4deg;  }  /* mouth closed */
}

/* Rotate Pac-Man to face the travel direction */
.player.dir-right { transform: rotate(0deg); }
.player.dir-down  { transform: rotate(90deg); }
.player.dir-left  { transform: rotate(180deg); }
.player.dir-up    { transform: rotate(270deg); }

/* =========================================================
   GHOST — rounded top, simple body, two eyes
   ========================================================= */
.ghost {
  position: absolute;
  inset: 8%;
  border-radius: 50% 50% 14% 14%;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
}
.ghost::before,
.ghost::after {
  content: "";
  position: absolute;
  top: 28%;
  width: 26%;
  height: 32%;
  background: #fff;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px var(--charcoal);
}
.ghost::before { left: 16%; }
.ghost::after  { right: 16%; }

/* =========================================================
   FULL-SCREEN OVERLAY — Game Over / Win, brand styled
   ========================================================= */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  background: rgba(29, 36, 30, 0.94);
  border-radius: 16px;
  text-align: center;
  z-index: 10;
}
.overlay.hidden { display: none; }

.overlay-title {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #fff;
  animation: fadepulse 1.6s ease-in-out infinite;
}
.overlay-title.win { color: var(--brand-accent); }

.overlay-score {
  font-size: 15px;
  font-weight: 600;
  color: var(--dot-color);
  letter-spacing: 1px;
}
.overlay-score span { color: var(--brand-accent); font-weight: 800; }

@keyframes fadepulse { 50% { opacity: 0.55; } }

/* Brand-style "Try Again" button (matches Odys dark CTA, inverted) */
.arcade-link {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.3px;
  padding: 13px 28px;
  border-radius: 14px;
  color: var(--charcoal);
  background: var(--brand-accent);
  transition: transform 0.1s ease, opacity 0.2s ease;
}
.arcade-link:hover { transform: scale(1.05); }

/* =========================================================
   BUTTONS — primary mirrors the Odys charcoal CTA
   ========================================================= */
.controls {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 18px 0 4px;
}

.btn {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.3px;
  padding: 13px 28px;
  border-radius: 14px;
  transition: transform 0.1s ease, opacity 0.2s ease;
}
.btn:active { transform: translateY(1px); }
.btn:hover { opacity: 0.9; }

.btn-primary {
  background: var(--charcoal);
  color: #fff;
}
.btn-secondary {
  background: #fff;
  color: var(--charcoal);
  border: 1.5px solid rgba(35, 43, 36, 0.18);
}

/* =========================================================
   MOBILE D-PAD — four-button directional control (3x3 grid)
   ========================================================= */
.dpad {
  display: grid;
  grid-template-columns: repeat(3, 54px);
  grid-template-rows: repeat(3, 54px);
  gap: 8px;
  justify-content: center;
  margin-top: 18px;
}

.dbtn {
  border: 1.5px solid rgba(78, 166, 91, 0.4);
  background: rgba(78, 166, 91, 0.08);
  color: var(--brand-secondary);
  font-size: 16px;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.2s ease, color 0.2s ease;
}
.dbtn:active { transform: scale(0.92); background: var(--brand-primary); color: #fff; }

.dbtn-up    { grid-column: 2; grid-row: 1; }
.dbtn-left  { grid-column: 1; grid-row: 2; }
.dbtn-down  { grid-column: 2; grid-row: 3; }
.dbtn-right { grid-column: 3; grid-row: 2; }

/* Status color helpers (set by JS) */
.status.win  { color: var(--brand-secondary); }
.status.lose { color: #c0492f; }
