/* ===== games.taxzy.dev — shared styles (cartoon box theme) ===== */
@import url("https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&display=swap");

:root {
  --paper: #fbf3e2;
  --ink: #141414;
  --card: #ffffff;
  --card2: #fff3c4;      /* pale yellow fill */
  --bg2: #f2ead4;        /* recessed fill */
  --line: #141414;       /* cartoon borders */
  --text: #141414;
  --muted: #5c5647;

  --yellow: #ffd23f;
  --pink: #ff8fab;
  --mint: #6ee7c7;
  --sky: #8fd3ff;
  --orange: #ff9f43;
  --purple: #b69df8;

  /* compat aliases used by game pages */
  --p1: #b69df8;
  --p2: #0fb5a6;
  --good: #22c55e;
  --bad: #ef4444;
  --warn: #b45309;
  --radius: 16px;
  --shadow: 5px 5px 0 var(--ink);
  --shadow-lg: 8px 8px 0 var(--ink);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: "Fredoka", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background-color: var(--paper);
  background-image: radial-gradient(rgba(20, 20, 20, 0.10) 1.6px, transparent 1.6px);
  background-size: 24px 24px;
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; }

button {
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: 12px;
  padding: 8px 16px;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.12s ease;
}
button:hover { background: var(--card2); }
button:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
button.primary {
  background: var(--yellow);
  font-weight: 700;
}
button.primary:hover { background: #ffdd66; }

/* ===== hub ===== */
.container { width: min(1180px, 100% - 40px); margin: 0 auto; }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 0 8px;
}
.logo {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo .dot {
  width: 44px; height: 44px;
  border-radius: 14px;
  background: var(--yellow);
  border: 3px solid var(--ink);
  box-shadow: var(--shadow);
  display: grid; place-items: center;
  font-size: 1.3rem;
}
.logo .dot:hover { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 var(--ink); }
.site-header .sub {
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 6px 14px;
  box-shadow: 3px 3px 0 var(--ink);
  transform: rotate(1.5deg);
}

.hero { padding: 36px 0 8px; text-align: center; }
.hero h1 { font-size: clamp(2rem, 5.5vw, 3.4rem); line-height: 1.15; font-weight: 700; }
.hero .hl {
  display: inline-block;
  background: var(--yellow);
  border: 3px solid var(--ink);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 0 16px 4px;
  transform: rotate(-1.5deg);
}
.hero p { color: var(--muted); margin-top: 16px; font-size: 1.05rem; font-weight: 500; }

.hub-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: center;
  margin: 28px auto 6px; /* auto margins keep the row centered (container margin is overridden here) */
}
.hub-controls input[type="search"] {
  background: var(--card);
  border: 3px solid var(--ink);
  box-shadow: var(--shadow);
  color: var(--ink);
  border-radius: 14px;
  padding: 11px 18px;
  font: inherit;
  font-weight: 500;
  width: min(340px, 100%);
  outline: none;
}
.hub-controls input[type="search"]:focus { background: #fffdf5; transform: translate(-1px, -1px); }
.chip {
  border: 3px solid var(--ink);
  background: var(--card);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
}
.chip:hover { background: var(--card2); }
.chip:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.chip.active { background: var(--ink); color: var(--paper); }

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(235px, 1fr));
  gap: 22px;
  padding: 20px 0 46px;
}
.game-card {
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 18px 16px;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.game-card:nth-child(odd)  { transform: rotate(-0.5deg); }
.game-card:nth-child(even) { transform: rotate(0.5deg); }
.game-card:hover { transform: translate(-3px, -3px) rotate(0deg); box-shadow: var(--shadow-lg); }
.game-card .logo {
  width: 100%;
  height: 110px;
  object-fit: contain;
  margin-bottom: 10px;
  transform: rotate(-1.5deg);
  transition: transform 0.12s ease;
}
.game-card:hover .logo { transform: rotate(0deg) scale(1.05); }
.game-card h3 { font-size: 1.15rem; font-weight: 700; }
.game-card .desc { color: var(--muted); font-size: 0.88rem; font-weight: 500; flex: 1; }
.game-card .meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  font-size: 0.78rem;
}
.game-card .tag {
  background: var(--paper);
  border: 2px solid var(--ink);
  color: var(--ink);
  font-weight: 600;
  padding: 3px 11px;
  border-radius: 999px;
}
.game-card .best { color: var(--warn); font-weight: 700; }

.empty-note {
  text-align: center;
  color: var(--muted);
  font-weight: 500;
  padding: 30px 0 50px;
  display: none;
}

.site-footer {
  margin-top: auto;
  padding: 20px 0 26px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
  text-align: center;
}
.site-footer a { color: var(--ink); font-weight: 700; text-decoration: underline wavy var(--yellow) 3px; }

/* ===== game pages (shared chrome) ===== */
.game-topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 16px 0;
}
.game-topbar .back {
  color: var(--ink);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 8px 15px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: var(--card);
  box-shadow: 3px 3px 0 var(--ink);
}
.game-topbar .back:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.game-topbar h1 {
  font-size: 1.4rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: 12px;
  box-shadow: 3px 3px 0 var(--ink);
  padding: 6px 16px;
  transform: rotate(-1deg);
}

.score-strip { display: flex; gap: 10px; flex-wrap: wrap; margin-left: auto; }
.score-chip {
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: 12px;
  box-shadow: 3px 3px 0 var(--ink);
  padding: 7px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}
.score-chip b { color: var(--ink); font-size: 1rem; font-weight: 700; }

.game-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center; /* vertical centring on big screens */
  gap: 20px;
  padding: 14px 16px 30px;
}

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(251, 243, 226, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  border-radius: inherit;
  z-index: 5;
  padding: 20px;
}
.overlay h2 { font-size: 1.6rem; font-weight: 700; }
.overlay p { color: var(--muted); font-weight: 500; }
.overlay[hidden] { display: none; }

.controls-hint {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
  text-align: center;
  max-width: 480px;
}
.controls-hint kbd {
  background: var(--card);
  border: 2px solid var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
  border-radius: 6px;
  padding: 1px 7px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
}

/* on-screen d-pad for touch devices */
.dpad {
  display: grid;
  grid-template-columns: repeat(3, 58px);
  grid-template-rows: repeat(3, 58px);
  gap: 8px;
  user-select: none;
  touch-action: manipulation;
}
.dpad button { font-size: 1.25rem; border-radius: 14px; }
.dpad .up    { grid-area: 1 / 2; }
.dpad .left  { grid-area: 2 / 1; }
.dpad .mid   { grid-area: 2 / 2; pointer-events: none; opacity: 0.4; background: var(--bg2); }
.dpad .right { grid-area: 2 / 3; }
.dpad .down  { grid-area: 3 / 2; }
@media (hover: hover) and (pointer: fine) {
  .dpad { display: none; }
}

/* game page: side info panels flanking the stage */
.game-layout {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 26px;
  width: 100%;
  max-width: 1560px;
  margin: 0 auto;
  padding: 0 20px 26px;
}
.game-layout .game-stage { flex: 0 1 auto; }
.side-info {
  width: 262px;
  flex-shrink: 0;
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.side-info.left { transform: rotate(-0.8deg); }
.side-info.right { transform: rotate(0.8deg); }
.side-info h3 {
  font-size: 1.02rem;
  font-weight: 700;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 3px solid var(--yellow);
  display: inline-block;
}
.side-info p { font-size: 0.88rem; font-weight: 500; color: var(--muted); line-height: 1.55; }
.side-info ul { list-style: none; display: flex; flex-direction: column; gap: 7px; }
.side-info li {
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.45;
  padding-left: 22px;
  position: relative;
}
.side-info li::before {
  content: "➜";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--ink);
  font-weight: 700;
  font-size: 0.8rem;
}
.side-info .tip {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--card2);
  border: 2px solid var(--ink);
  border-radius: 10px;
  color: var(--ink);
  font-size: 0.84rem;
}
@media (max-width: 1150px) {
  .game-layout { flex-direction: column; gap: 18px; }
  .side-info { width: min(560px, 94vw); transform: none; }
  .game-layout .side-info.left { order: 2; }
  .game-layout .game-stage { order: 1; }
  .game-layout .side-info.right { order: 3; }
}

/* difficulty selector + confetti */
.diff-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 2px 0 0;
}
.diff-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.diff-btn {
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 0.85rem;
  box-shadow: 2px 2px 0 var(--ink);
}
.diff-btn.active {
  background: var(--ink);
  color: var(--paper);
}
.mg-confetti {
  position: fixed;
  top: -34px;
  z-index: 999;
  pointer-events: none;
  animation: mgFall linear forwards;
}
@keyframes mgFall {
  from { transform: translateY(0) rotate(0deg); }
  to { transform: translateY(115vh) rotate(560deg); }
}

canvas.game-canvas {
  border: 3px solid var(--ink);
  border-radius: 14px;
  box-shadow: var(--shadow);
  max-width: 100%;
  max-height: 62vh;      /* scale up to fill the viewport, keep aspect ratio */
  width: auto;
  height: auto;
  touch-action: none;
  background: #1d1f2e;
}

/* chunkify board containers defined in game pages */
.ms-board, .mem-grid, .ttt-board, .board {
  border: 3px solid var(--ink) !important;
  box-shadow: var(--shadow) !important;
}
.panel-box {
  border: 3px solid var(--ink) !important;
  box-shadow: 4px 4px 0 var(--ink) !important;
  background: var(--card) !important;
}

@media (max-width: 560px) {
  .score-strip { margin-left: 0; }
}
