/* Liar's Field. The SoSmarty look (base.css) on a grass ground; design rules live in the repo's CLAUDE.md.
   Grass is a covered square, cream a number the devil shows you (one lies), soil a square you dug (honest). */
:root { --grass: #8cbf5a; --soil: #d9b382; }
html, body { height: 100%; }
body {
  margin: 0; overflow: hidden; background: var(--grass);
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
.screen { position: fixed; inset: 0; }
body.touch .mouse-only, body.mouse .touch-only, body.touch .kbd { display: none; }

/* Title: stands still. The name, a sample of the field, the three rules, the way in */
.title {
  display: flex; flex-direction: column; gap: 20px; overflow-y: auto;
  padding: max(6vh, env(safe-area-inset-top)) max(6vw, 16px) max(4vh, env(safe-area-inset-bottom));
}
.title h1 { font-size: 64px; line-height: 0.95; }
.title h1 span { display: block; }
.tagline { margin: 12px 0 0; font-size: 20px; font-weight: 700; }
.sample { flex: 1 1 auto; display: flex; align-items: center; min-height: 0; }
.rules { margin: 0; padding-left: 22px; font-size: 18px; }
.rules li + li { margin-top: 4px; }
.title-bottom { display: flex; flex-direction: column; gap: 16px; }
.keys { margin: 0; font-size: 16px; }
@media (max-height: 720px) and (orientation: portrait) {
  .sample { display: none; }
  .title { gap: 14px; }
  .title h1 { font-size: 48px; }
  .rules { font-size: 16px; }
}
@media (min-width: 900px) and (min-height: 560px) {
  .title { display: grid; grid-template-columns: minmax(340px, 1fr) 1fr; grid-template-rows: auto 1fr; column-gap: 56px; }
  .title-top { grid-column: 1; grid-row: 1; }
  .title-bottom { grid-column: 1; grid-row: 2; align-self: end; }
  .sample { grid-column: 2; grid-row: 1 / 3; justify-content: center; }
  .sample .mini { --cell: 84px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .title { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto 1fr; column-gap: 24px; padding-top: 16px; }
  .title h1 { font-size: 32px; }
  .title h1 span { display: inline; }
  .title-top { grid-column: 1; }
  .title-bottom { grid-column: 2; grid-row: 1 / 3; }
  .sample { grid-column: 1; grid-row: 2; }
  .sample .mini { --cell: 40px; }
  .rules { font-size: 16px; }
}

/* The field: an ink frame, 3px ink lines between squares */
.board {
  --cell: 48px;
  display: grid; grid-template-columns: repeat(var(--w), var(--cell)); grid-auto-rows: var(--cell); gap: 3px; padding: 3px;
  width: max-content; background: var(--ink); border-radius: 4px; touch-action: manipulation;
}
.board .row { display: contents; }
.mini { --w: 4; --cell: 52px; }
.c {
  position: relative; display: flex; align-items: center; justify-content: center; width: var(--cell); height: var(--cell);
  margin: 0; padding: 0; border: 0; border-radius: 2px; background: var(--grass); color: var(--ink);
  font: calc(var(--cell) * 0.5)/1 var(--display); cursor: pointer; -webkit-touch-callout: none;
}
.c.open { background: var(--cream); }
.c.dug { background: var(--soil); cursor: default; }
.c.caught { background: var(--ink); color: var(--cream); cursor: default; }
/* A caught liar shows its true number and grows a pair of cream horns */
.c.caught::before, .c.caught::after {
  content: ''; position: absolute; top: 6%; border-bottom: calc(var(--cell) * 0.2) solid var(--cream);
  border-left: calc(var(--cell) * 0.07) solid transparent; border-right: calc(var(--cell) * 0.07) solid transparent;
}
.c.caught::before { left: 14%; transform: rotate(-20deg); }
.c.caught::after { right: 14%; transform: rotate(20deg); }
.c.sus { outline: 4px solid var(--ink); outline-offset: -8px; transform: rotate(-8deg); }
@media (hover: hover) { .c.cov:hover, .c.flag:hover { background: #9fcd70; } }
.c:focus-visible { outline: 3px solid var(--cream); outline-offset: -6px; }
.c.hint { outline: 4px dashed var(--cream); outline-offset: -7px; }
/* A flag: ink pole and pennant */
.c.flag::before { content: ''; position: absolute; left: 38%; top: 20%; width: 3px; height: 60%; background: var(--ink); }
.c.flag::after {
  content: ''; position: absolute; left: calc(38% + 3px); top: 20%;
  border-left: calc(var(--cell) * 0.32) solid var(--ink); border-top: calc(var(--cell) * 0.13) solid transparent; border-bottom: calc(var(--cell) * 0.13) solid transparent;
}
/* A mine that went off: an ink ball with a cream glint */
.c.boom { background: var(--cream); }
.c.boom::before { content: ''; width: 58%; height: 58%; border-radius: 50%; background: var(--ink); }
.c.boom::after { content: ''; position: absolute; left: 36%; top: 34%; width: 12%; height: 12%; border-radius: 50%; background: var(--cream); }

/* Cream panels: board select and the ending */
.panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px 16px; }
.key { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 16px 0 0; font-size: 16px; }
.swatch { display: inline-block; width: 20px; height: 20px; border: 3px solid var(--ink); border-radius: 2px; }
.swatch.caughtk { background: var(--grass); }
.swatch.clearedk { background: var(--soil); margin-left: 12px; }
.set { margin-top: 28px; padding-left: 16px; border-left: 8px solid var(--grass); }
.set h3 { margin-bottom: 10px; font-size: 20px; }
.lvls { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
@media (max-width: 640px) { .lvls { grid-template-columns: repeat(3, 1fr); } }
.lvl {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-height: 76px; padding: 10px;
  border: 3px solid var(--ink); border-radius: 4px; background: var(--ink); color: var(--cream);
  font: 16px/1.25 var(--body); text-align: left; cursor: pointer;
}
.lvl b { font: 20px/1 var(--display); font-weight: 400; }
.lvl.caught { background: var(--grass); color: var(--ink); }
.lvl.cleared { background: var(--soil); color: var(--ink); }
.lvl:disabled { background: transparent; color: rgba(26, 22, 18, 0.55); border-style: dashed; border-color: rgba(26, 22, 18, 0.4); cursor: default; }

/* Play: header, the devil, the field, the buttons */
.play {
  display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto;
  grid-template-areas: 'hud' 'talk' 'stage' 'tools';
  gap: 10px; max-width: 760px; margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.hud { grid-area: hud; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
/* Games link: no taller than the header (board 24 has no height to spare on an iPhone SE); its tap area reaches past it */
.home { position: relative; flex: none; font-size: 16px; padding: 3px 8px; min-height: 0; }
.home::after { content: ''; position: absolute; inset: -10px -6px; }
.lv { flex: 1 1 auto; margin: 0; min-width: 0; font-size: 20px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lv b { margin-right: 6px; font: 20px/1 var(--display); font-weight: 400; }
@media (max-width: 479px) { #lvName { display: none; } }
.count { display: flex; gap: 14px; margin: 0; flex: none; }
.count div { display: flex; align-items: baseline; gap: 6px; }
.count dt { font-size: 16px; font-weight: 700; }
.count dd { margin: 0; min-width: 1.2em; font: 20px/1 var(--display); }
.talk { grid-area: talk; display: flex; align-items: center; gap: 12px; min-height: 64px; }
.talk img { flex: none; width: 48px; height: 48px; }
.talk p {
  position: relative; flex: 1 1 auto; margin: 0; padding: 8px 12px; min-height: 48px;
  background: var(--cream); border: 3px solid var(--ink); border-radius: 4px; font-size: 16px; font-weight: 700; line-height: 1.3;
}
.talk p::before { content: ''; position: absolute; left: -11px; top: 14px; border: 8px solid transparent; border-right: 8px solid var(--ink); border-left: 0; }
.talk p.pop { animation: pop 0.22s ease-out; }
@keyframes pop { from { transform: scale(0.94); } to { transform: none; } }
.showme { flex: none; background: var(--cream); color: var(--ink); font-size: 16px; padding: 10px 12px; }
.stage { grid-area: stage; position: relative; display: flex; align-items: center; justify-content: center; min-height: 0; }
.stage.shake { animation: shake 0.4s; }
@keyframes shake {
  0%, 100% { transform: none; } 15% { transform: translate(-9px, 4px); } 30% { transform: translate(8px, -6px); }
  45% { transform: translate(-6px, -3px); } 60% { transform: translate(5px, 5px); } 80% { transform: translate(-2px, 2px); }
}
.stamp {
  position: absolute; left: 50%; top: 50%; margin: 0; padding: 10px 22px; transform: translate(-50%, -50%) rotate(-8deg);
  background: var(--ink); color: var(--cream); border-radius: 4px; font: 32px/1 var(--display); pointer-events: none;
}
.tools { grid-area: tools; justify-content: center; }
.tools .btn { font-size: 16px; padding: 10px 14px; }
#modeBtn { min-width: 92px; justify-content: center; }

/* Flying clods when a mine pops */
.bits { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.bits i { position: fixed; width: 10px; height: 10px; margin: -5px 0 0 -5px; background: var(--ink); border-radius: 2px; animation: fly 0.8s ease-out forwards; }
.bits i.cream { background: var(--cream); }
@keyframes fly { to { transform: translate(var(--dx), var(--dy)) rotate(200deg); opacity: 0; } }

/* Phones on their side: the field on the left, everything else in a column on the right */
@media (max-height: 520px) and (orientation: landscape) {
  .play {
    max-width: none; grid-template-columns: minmax(0, 1fr) minmax(240px, 300px); grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas: 'stage hud' 'stage talk' 'stage .' 'stage tools';
  }
  .tools { justify-content: flex-start; }
  .hud { flex-wrap: wrap; row-gap: 6px; }
  .lv { order: 1; flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .btn:hover, .btn:active, .lvl:hover:not(:disabled) { transform: none; }
  .talk p.pop, .stage.shake { animation: none; }
  .c.sus { transform: none; }
}
