/* ════════════════════════════════════════
   ACCESSIBILITY
   ════════════════════════════════════════ */
  @import url('https://fonts.googleapis.com/css2?family=Pixelify+Sans:wght@400;700&display=swap');
:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ════════════════════════════════════════
   DESIGN TOKENS
   ════════════════════════════════════════ */
:root {
  --works-max-width: 1400px;
  --grid-columns:    3;
  --card-gap:        24px;
  --card-aspect:     16 / 9;
  --card-radius:     20px;

  --bg:              #158829ac;
  --title-color:     #000000;
  --section-color:   #15267a;
  --card-bg:         #f2f5ff;
  --card-border:     #15267a;
  --button-bg:       #e0fdff;
  --button-border:   #c8eaff;
  --button-color:    #15267a;
  --button-hover-bg: skyblue;
  --button-hover-border: mediumPurple;

  --game-toggle-bg:  #15267a;
  --hint-bg:         rgba(224, 253, 255, 0.92);
  --hint-border:     #c8eaff;
  --hint-color:      #15267a;

  --nav-w: 180px;
}

/* ════════════════════════════════════════
   BASE
   ════════════════════════════════════════ */
* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 40px 40px 40px calc(var(--nav-w) + 20px);
  font-family:'Pixelify Sans', sans-serif;
  background: var(--bg);
  cursor: url('images/cursor.png') 18 12, auto;
  user-select: none;
}

/* ════════════════════════════════════════
   LAYOUT
   ════════════════════════════════════════ */
header { text-align: center; }

.title {
  color: var(--title-color);
  margin-bottom: 4px;
  font-weight: 500;
  font-size: clamp(22px, 4vw, 42px);
}

.underline {
  width: 200px;
  height: 2px;
  background: var(--title-color);
  margin: 0 auto 50px;
}

.section-title {
  color: var(--section-color);
  margin: 8px 0 18px 0;
  font-size: clamp(20px, 3.5vw, 36px);
  font-weight: 600;
  text-align: center;
}

/* ════════════════════════════════════════
   WORKS GRID
   ════════════════════════════════════════ */
.works {
  max-width: var(--works-max-width);
  margin: 0 auto 40px;
}

.works-grid {
  display: grid;
  /* auto-fit: cards min 260px, fewer columns on narrower screens */
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
  gap: var(--card-gap);
  justify-items: center;
}

.work-card {
  background: transparent;
  border: none;
  border-radius: var(--card-radius);
  box-shadow: none;
 transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.work-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
}

.work-media {
  display: block;
  aspect-ratio: var(--card-aspect);
  background: var(--card-bg);
  position: relative;
  border-radius: var(--card-radius);
  border: none; 
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4); 
  cursor: url('images/cursor-button.png') 18 12, pointer;
}

.media-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #7b8abc;
  font-size: 14px;
  letter-spacing: 2px;
}

.work-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: var(--card-radius);
}

.work-meta  { display: none; }
.work-title { margin: 0 0 6px; font-size: 16px; color: #1b2559; }
.work-desc  { margin: 0; font-size: 13px; color: #5b6aa6; }

/* ════════════════════════════════════════
   MAIN BUTTON
   ════════════════════════════════════════ */
.main-button {
  display: block;
  margin: 80px auto 150px;
  padding: 20px 80px;
  background: var(--button-bg);
  border-top:    3px solid var(--card-border);
  border-left:   1.5px solid var(--button-border);
  border-right:  1.5px solid var(--button-border);
  border-bottom: 1.5px solid var(--button-border);
  border-radius: 10px;
  font-size: 18px;
  color: var(--button-color);
  cursor: url('images/cursor-button.png') 18 12, pointer;
  transition: background 0.25s ease, border-color 0.25s ease;
}

.main-button:hover {
  background:   var(--button-hover-bg);
  border-color: var(--button-hover-border);
}

/* ════════════════════════════════════════
   FOOTER
   ════════════════════════════════════════ */
footer { text-align: center;
  padding: 20px 0;
  color: #555;
  font-family: Arial, sans-serif;
  position: fixed;     
  bottom: 0;
  left: var(--nav-w);   
  right: 0;
  z-index: 100; }

/* ════════════════════════════════════════
   GAME OVERLAY
   ════════════════════════════════════════ */
#game-canvas {
  position: fixed;
  top: 0; left: 0;
  pointer-events: none;
  z-index: 9999;
  image-rendering: pixelated;
  /* size fully controlled by JS to keep CSS and canvas buffer in sync */
}

body.game-active,
body.game-active * { cursor: default !important; }
body.game-active.dragging,
body.game-active.dragging * { cursor: grabbing !important; }

#controls-hint {
  position: fixed;
  bottom: 20px; left: 50%;
  transform: translateX(-50%);
  z-index: 10001;
  font-size: 12px;
  color: var(--hint-color);
  background: var(--hint-bg);
  border: 1.5px solid var(--hint-border);
  border-radius: 20px;
  padding: 7px 18px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s;
  white-space: nowrap;
}
#controls-hint.show { opacity: 1; }

#spawn-coin {
  background: none;
  border: 1.5px solid rgba(21, 38, 122, 0.35);
  border-radius: 50px;
  width: 56px; height: 56px;
  padding: 0;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s;
}
#spawn-coin img { width: 40px; height: 40px; image-rendering: pixelated; display: block; }
#spawn-coin:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(21,38,122,0.3); }
body.game-active #spawn-coin { display: flex; }

#coin-hud {
  position: fixed;
  top: 16px; right: 16px;
  z-index: 10001;
  display: none;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  padding: 0;
}
#coin-hud.has-coins { display: flex; }

#coin-count {
  font-family: 'Pixelify Sans', sans-serif;
  font-size: 18px;
  color: var(--section-color);
  min-width: 1ch;
}

/* ════════════════════════════════════════
   Side navigation
   ════════════════════════════════════════ */
.side-nav {
  position: fixed;
  top: 0; left: 0;
  width: var(--nav-w);
  height: 100vh;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  padding: 36px 20px;
  box-sizing: border-box;
}

.side-nav-logo {
  font-size: 40px;
  letter-spacing: 0.15em;
  color: var(--title-color);
  margin-bottom: 32px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}
.side-nav-logo > span {
  opacity: 0.45;
}
.side-nav-logo img {
  width: 1em; height: 1em;
  image-rendering: pixelated;
  flex-shrink: 0;
}

.side-nav ul {
  list-style: none;
  margin: 0; padding: 0;
  display: flex;
  flex-direction: column;
  gap: 50px;
}

.side-nav a {
  font-size: 24px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--title-color);
  opacity: 0.4;
  transition: opacity 0.2s;
  display: flex;
  align-items: center;
  gap: 10px;
}

.side-nav a[aria-current="page"]::before {
  content: '';
  display: inline-block;
  width: 48px;
  height: 64px;
  background-image: url('images/navigation.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  flex-shrink: 0;
}

.side-nav a:hover,
.side-nav a[aria-current="page"] { opacity: 1; }

body.game-active #game-toggle {
  pointer-events: auto;
  opacity: 0.6;
}

/* ── PLAY button (nav bottom) ── */
@keyframes breathe {
  0%, 100% {
    box-shadow: 0 0 6px 1px rgba(21, 38, 122, 0.2),
                0 0 0px 0px rgba(21, 38, 122, 0);
    opacity: 0.5;
  }
  50% {
    box-shadow: 0 0 18px 6px rgba(21, 38, 122, 0.55),
                0 0 32px 10px rgba(21, 38, 122, 0.15);
    opacity: 1;
  }
}

.nav-bottom-group {
  margin-top: auto;   /* push group to the bottom of the nav */
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

#game-toggle {
  background: none;
  color: var(--title-color);
  border: 1.5px solid rgba(21, 38, 122, 0.35);
  border-radius: 50px;
  padding: 10px 18px;
  font-size: 13px;
  font-family: 'Pixelify Sans', sans-serif;
  letter-spacing: 0.12em;
  cursor: pointer;
  animation: breathe 3s ease-in-out infinite;
  transition: opacity 0.2s;
}

#game-toggle:hover {
  animation: none;
  opacity: 1;
  box-shadow: 0 0 20px 6px rgba(21, 38, 122, 0.4);
}

/* EXIT style when game is active */
body.game-active #game-toggle {
  animation: none;
  opacity: 0.6;
}

/* Tablet / small desktop */
@media (max-width: 768px) {
  :root { --nav-w: 140px; }

  body { padding: 30px 24px 30px calc(var(--nav-w) + 16px); }

  .side-nav-logo { font-size: 28px; }
  .side-nav a    { font-size: 18px; }

  #game-toggle {
    font-size: 11px;
    padding: 8px 12px;
  }
}

/* Large screen — enlarge cards and spacing */
@media (min-width: 1200px) {
  :root {
    --card-gap: 32px;
  }
  .works-grid {
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  }
}

/* Mobile — nav stays on the left, reduce width and font size */
@media (max-width: 600px) {
  :root {
    --card-gap: 14px;
    --nav-w: 110px;
  }

  body { padding: 20px 14px 40px calc(var(--nav-w) + 12px); }

  .side-nav {
    height: 100dvh;
    padding: 14px 12px;
    overflow: hidden;
  }
  .side-nav-logo { font-size: 18px; margin-bottom: 10px; letter-spacing: 0.05em; }
  .side-nav a    { font-size: 11px; gap: 4px; letter-spacing: 0.04em; }
  .side-nav ul   { gap: 14px; overflow-y: auto; flex-shrink: 1; scrollbar-width: none; }
  .side-nav ul::-webkit-scrollbar { display: none; }

  .side-nav a[aria-current="page"]::before {
    width: 28px;
    height: 36px;
  }

  .nav-bottom-group { gap: 6px; }
  #game-toggle      { font-size: 10px; padding: 7px 10px; }
  #spawn-coin img   { width: 30px; height: 30px; }
}

/* ════════════════════════════════════════
   Modal overlay
   ════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 20000;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--card-bg);
  border-radius: var(--card-radius);
  border: 1.5px solid rgba(21,38,122,0.15);
  width: min(680px, 90vw);
  max-height: 85vh;
  overflow-y: auto;
  scrollbar-width: none;
  padding: 32px;
  position: relative;
  transform: translateY(16px);
  transition: transform 0.25s;
}

.modal::-webkit-scrollbar { display: none; }
.modal-overlay.open .modal { transform: translateY(0); }

.modal-img {
  width: 100%;
  border-radius: 12px;
  display: block;
  margin-bottom: 24px;
}

.modal-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--section-color);
  margin: 0 0 12px;
}

.modal-desc {
  font-size: 14px;
  line-height: 1.8;
  color: #444;
  margin: 0;
}

/* ════════════════════════════════════════
   COLOR WHEEL
   ════════════════════════════════════════ */

/* thumbnail — always visible, bottom-right */
#cw-thumb {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: zoom-in;
  z-index: 99998;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  display: block;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}
#cw-thumb:hover {
  transform: scale(1.12);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}
/* hide thumbnail while panel is open */
#cw-thumb.cw-hidden {
  opacity: 0;
  transform: scale(0.6);
  pointer-events: none;
}

/* full picker panel — zooms out from thumbnail corner */
#color-wheel-popup {
  display: flex;           /* always flex; visibility controlled by transform+opacity */
  position: fixed;
  right: 20px;
  bottom: 20px;            /* anchored to same corner as thumbnail */
  z-index: 99999;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: var(--card-bg, #f2f5ff);
  border: 1.5px solid rgba(21, 38, 122, 0.2);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  font-family: 'Pixelify Sans', sans-serif;
  /* closed state: scaled down to thumbnail size, invisible */
  transform-origin: bottom right;
  transform: scale(0.22);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: transform 0.32s cubic-bezier(0.34, 1.4, 0.64, 1),
              opacity 0.22s ease,
              visibility 0s linear 0.22s;
}
/* open state: full size */
#color-wheel-popup.open {
  transform: scale(1);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: transform 0.32s cubic-bezier(0.34, 1.4, 0.64, 1),
              opacity 0.22s ease,
              visibility 0s linear 0s;
}

#cw-canvas {
  display: block;
  cursor: crosshair;
}
.cw-row {
  width: 160px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cw-label {
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--section-color, #15267a);
  opacity: 0.7;
}
.cw-range { width: 100%; cursor: pointer; }

/* ════════════════════════════════════════
   CARD PROXIMITY HINT
   ════════════════════════════════════════ */
#card-hint {
  position: fixed;
  z-index: 20000;
  background: rgba(13, 27, 62, 0.92);
  border: 1.5px solid rgba(200, 184, 122, 0.7);
  border-radius: 6px;
  padding: 7px 14px;
  font-family: 'Pixelify Sans', sans-serif;
  font-size: 13px;
  color: #d0eaff;
  letter-spacing: 0.06em;
  white-space: nowrap;
  pointer-events: none;
  transform: translateX(-50%) translateY(-100%);
  margin-top: -12px;
  opacity: 0;
  transition: opacity 0.15s;
}
#card-hint.show { opacity: 1; }
#card-hint .hint-name { color: #ffd966; font-weight: 700; margin-right: 8px; }
#card-hint kbd {
  display: inline-block;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 3px;
  padding: 0 5px;
  font-size: 12px;
  color: #a0ffc0;
  margin: 0 3px;
}

/* ════════════════════════════════════════
   SHOP PAGE
   ════════════════════════════════════════ */
#shop-scene {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 80px);
}

#shop-scene-img {
  display: block;
  max-width: 100%;
  image-rendering: pixelated;
}