/* Pasijou-Duko - mobile-first template. Theme colors are set from THEME in game.js
   via CSS variables, so this file rarely needs editing for reskins. */
:root {
  --bg1: #ffe8d6;
  --bg2: #ffd1dc;
  --ink: #4a2c2a;
  --accent: #ff8fab;
  --accent-ink: #fff;
  --card: #fffaf5;
  --line: #4a2c2a;
  --bad: #e5484d;
  --board: min(94vw, 62dvh, 480px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  font-family: 'Nunito', 'Segoe UI Rounded', 'Arial Rounded MT Bold', system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg1), var(--bg2));
}

#app {
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px calc(env(safe-area-inset-bottom, 0px) + 10px);
}

header { text-align: center; }
#title { font-size: clamp(26px, 8vw, 38px); font-weight: 900; letter-spacing: .5px; }
#subtitle { font-size: 13px; font-weight: 700; opacity: .7; }
#subtitle:empty { display: none; }

#topbar { display: flex; gap: 8px; width: var(--board); justify-content: space-between; }
.pill {
  border: 0;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  font-size: 15px;
  padding: 8px 14px;
  border-radius: 999px;
  box-shadow: 0 2px 0 rgba(0,0,0,.15);
}
button.pill:active { transform: translateY(2px); box-shadow: none; }

#board-wrap { flex: 0 0 auto; }
#board {
  width: var(--board);
  height: var(--board);
  display: grid;
  border: 3px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--card);
  box-shadow: 0 6px 18px rgba(0,0,0,.2);
}
#board.shake { animation: shake .35s; }

.cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0 solid var(--line);
  font-size: calc(var(--board) / var(--n) * .6);
  line-height: 1;
  cursor: pointer;
}
.cell.bt { border-top-width: 3px; }
.cell.bl { border-left-width: 3px; }
.cell:not(.bt):not(.bl) { box-shadow: none; }
.cell::after {
  content: '';
  position: absolute;
  inset: 0;
  border-right: 1px solid rgba(0,0,0,.12);
  border-bottom: 1px solid rgba(0,0,0,.12);
  pointer-events: none;
}
.cell.mark { font-size: calc(var(--board) / var(--n) * .38); opacity: .55; }
.cell.bad { background-image: repeating-linear-gradient(45deg, rgba(229,72,77,.55) 0 6px, rgba(229,72,77,.15) 6px 12px); }
.cell.pop > span { animation: pop .25s; }
.cell.hinted { outline: 3px solid #fff; outline-offset: -3px; }

#tools { display: flex; gap: 10px; width: var(--board); }
.tool {
  flex: 1;
  border: 0;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  font-size: 13px;
  padding: 8px 4px;
  border-radius: 14px;
  box-shadow: 0 3px 0 rgba(0,0,0,.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.tool .ico { font-size: 20px; }
.tool:active { transform: translateY(3px); box-shadow: none; }
.tool:disabled { opacity: .4; }

#rules { width: var(--board); font-size: 13px; font-weight: 700; text-align: center; opacity: .75; line-height: 1.35; }

/* Overlays */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(40, 20, 20, .5);
  padding: 20px;
}
.hidden { display: none; }
.card {
  width: min(100%, 380px);
  max-height: 90dvh;
  overflow: auto;
  background: var(--card);
  border-radius: 22px;
  padding: 22px 18px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
  animation: pop .3s;
}
.card h2 { font-size: 24px; font-weight: 900; margin-bottom: 8px; }
.card p { font-weight: 700; margin-bottom: 14px; opacity: .8; }
#win-emoji { font-size: 64px; animation: bounce .8s infinite alternate; }

.big-btn, .small-btn {
  display: block;
  width: 100%;
  border: 0;
  font: inherit;
  font-weight: 900;
  border-radius: 14px;
  box-shadow: 0 3px 0 rgba(0,0,0,.2);
}
.big-btn { background: var(--accent); color: var(--accent-ink); font-size: 18px; padding: 12px; margin-top: 10px; }
.small-btn { background: transparent; color: var(--ink); font-size: 14px; padding: 10px; margin-top: 6px; box-shadow: none; }
.big-btn:active { transform: translateY(3px); box-shadow: none; }

#level-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 12px 0 6px; }
#level-grid button {
  aspect-ratio: 1;
  border: 0;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 900;
  font-size: 16px;
  box-shadow: 0 2px 0 rgba(0,0,0,.15);
}
#level-grid button.done { background: var(--accent); color: var(--accent-ink); }
#level-grid button.current { outline: 3px solid var(--ink); }
#level-grid button:disabled { opacity: .35; }

@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 70% { transform: scale(1.15); } 100% { transform: scale(1); opacity: 1; } }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes bounce { to { transform: translateY(-10px) rotate(6deg); } }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; }
}

#footer { width: var(--board); margin-top: auto; font-size: 11px; font-weight: 800; text-align: center; letter-spacing: .3px; opacity: .65; }

#help-list { list-style: none; text-align: left; margin: 10px 0 4px; display: grid; gap: 9px; }
#help-list li { font-size: 14px; font-weight: 700; line-height: 1.35; padding: 8px 10px; background: rgba(0,0,0,.05); border-radius: 12px; }
#topbar { gap: 6px; }

.icon { width: 1em; height: 1em; object-fit: contain; vertical-align: -0.15em; pointer-events: none; }
.cell > span { display: flex; width: 78%; height: 78%; align-items: center; justify-content: center; }
.cell .icon { width: 100%; height: 100%; }
.cell.mark { opacity: .8; }
#help-list .icon { width: 1.5em; height: 1.5em; vertical-align: middle; }
.cell.mark > span { width: 62%; height: 62%; }

#btn-help { font-size: 13px; white-space: nowrap; }
#btn-help.attention { background: var(--accent); color: #fff; animation: helpPulse 1.4s ease-out infinite; }
#btn-help.attention::before { content: '👉'; position: absolute; left: -26px; top: 50%; transform: translateY(-50%); animation: nudge .7s ease-in-out infinite alternate; }
#btn-help { position: relative; }
@keyframes helpPulse { 0% { box-shadow: 0 0 0 0 rgba(14,154,167,.7); } 70%, 100% { box-shadow: 0 0 0 14px rgba(14,154,167,0); } }
@keyframes nudge { to { transform: translate(5px, -50%); } }

/* ---------- Background image mode ----------
   The artwork is split into a top piece and a bottom piece that stick to the
   top and bottom of the screen, with plain sand in between. That way tall
   phones, short phones and desktop windows all show the logo and the beach. */
.has-bg #app {
  position: relative;
  overflow: hidden;
  --art-w: min(100vw, 560px);
  --board: min(90vw, 41dvh, 460px);
  background: #fbf1e3;
}
.has-bg #app::before, .has-bg #app::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  background-image: var(--bg-img);
  background-size: 100% auto;
  background-repeat: no-repeat;
  pointer-events: none;
  z-index: 0;
}
.has-bg #app::before {
  top: 0;
  height: calc(var(--art-w) * .68);
  background-position: center top;
  -webkit-mask-image: linear-gradient(#000 82%, transparent);
  mask-image: linear-gradient(#000 82%, transparent);
}
.has-bg #app::after {
  bottom: 0;
  height: calc(var(--art-w) * .56);
  background-position: center bottom;
  -webkit-mask-image: linear-gradient(transparent, #000 22%);
  mask-image: linear-gradient(transparent, #000 22%);
}
.has-bg #app > *:not(header):not(.overlay) { position: relative; z-index: 1; }
.has-bg.bg-title #app { padding-top: calc(env(safe-area-inset-top, 0px) + var(--art-w) * .42); }
.has-bg.bg-title header { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.has-bg #rules, .has-bg #footer {
  background: rgba(255, 250, 240, .82);
  border-radius: 12px;
  padding: 6px 10px;
  opacity: 1;
  backdrop-filter: blur(3px);
}
.has-bg #footer { font-size: 10px; margin-top: auto; }
.has-bg #board { box-shadow: 0 6px 18px rgba(0,0,0,.3); }
