/* DongCheng Tile Match - game page styles (same palette as the main site) */
:root {
  --ink: #13283b;
  --ink-2: #1d3a54;
  --muted: #6f7f8f;
  --line: #dfe3e7;
  --paper: #efece6;
  --accent: #b07d2a;
  --accent-dark: #8e6420;
  --accent-tint: #f4ead8;
  --font-zh: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Hiragino Sans GB", sans-serif;
  --font-en: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --t: 56px; /* tile size, set by game.js */
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-en), var(--font-zh); color: var(--ink); background: var(--paper);
  display: flex; flex-direction: column; min-height: 100dvh; overflow-x: clip;
  -webkit-font-smoothing: antialiased; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
.zh { display: block; font-family: var(--font-zh); }
.en { display: block; font-size: .78em; color: var(--muted); }

/* Header */
.g-head {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
  padding: 8px 12px; background: var(--ink); color: #fff;
}
.g-head .en { color: #a9b7c4; }
.g-back, .g-icon-btn {
  display: inline-flex; align-items: center; gap: 4px; justify-self: start;
  color: #fff; text-decoration: none; background: none; border: 1px solid rgba(255,255,255,.25);
  border-radius: 8px; padding: 5px 9px; line-height: 1.15; font-size: 13px; white-space: nowrap;
}
.g-icon-btn { justify-self: end; }
.g-back:hover, .g-icon-btn:hover { background: rgba(255,255,255,.08); }
.g-title { text-align: center; line-height: 1.15; }
.g-title h1 { margin: 0; font-size: 18px; display: flex; gap: 6px; align-items: baseline; justify-content: center; }
.g-title h1 .zh, .g-title h1 .en { display: inline; }
.g-title h1 .en { font-size: 12px; font-weight: 500; }
.g-level { margin: 2px 0 0; font-size: 12px; color: #e6c98f; }

/* Main */
.g-main { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 8px 12px 14px; }
.g-help { margin: 0 0 4px; max-width: 520px; text-align: center; font-size: 12.5px; line-height: 1.35; color: var(--ink); }
.g-help .en { font-size: 12px; }
.g-left { margin: 2px 0 6px; font-size: 12px; color: var(--muted); }

/* Stage: every tile is absolutely positioned inside it, so moves animate with transform */
.g-stage { position: relative; flex: none; isolation: isolate; } /* keeps card stacking below the pop-ups */
.g-tray {
  position: absolute; border-radius: calc(var(--t) * .22);
  background: #6b4a16; box-shadow: inset 0 2px 6px rgba(0,0,0,.35), 0 1px 0 rgba(255,255,255,.5);
}
.g-tray-cell { position: absolute; border-radius: calc(var(--t) * .14); background: rgba(255,255,255,.1); }
.g-temp-zone {
  position: absolute; border: 1.5px dashed #c8bfae; border-radius: calc(var(--t) * .18);
}
.tile {
  position: absolute; left: 0; top: 0; width: calc(var(--t) * .96); height: calc(var(--t) * .96);
  padding: calc(var(--t) * .07); border: 1px solid #d9d2c4; border-radius: calc(var(--t) * .16);
  background: #fff; box-shadow: 0 calc(var(--t) * .07) 0 #cfc6b4, 0 calc(var(--t) * .09) calc(var(--t) * .12) rgba(19,40,59,.18);
  transition: transform .22s cubic-bezier(.3,.8,.3,1), filter .15s, opacity .2s;
  transform: var(--pos); will-change: transform;
}
.tile img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; user-select: none; -webkit-user-drag: none; }
.tile.covered { filter: brightness(.5) saturate(.5); cursor: default; }
.tile:not(.covered) { cursor: pointer; }
.tile.in-tray { box-shadow: 0 2px 0 #cfc6b4; }
.tile.pop { opacity: 0; transform: var(--pos) scale(.2) !important; }
.tile.hint { animation: shake .3s; }
@keyframes shake { 25% { margin-left: -3px; } 75% { margin-left: 3px; } }

/* Tools */
.g-tools { display: flex; gap: 8px; margin-top: 12px; }
.g-tool {
  position: relative; min-width: 92px; padding: 7px 12px; line-height: 1.15;
  border: 0; border-radius: 8px; background: var(--ink); color: #fff; font-size: 14px; font-weight: 600;
  box-shadow: 0 3px 0 #0a1722;
}
.g-tool .en { color: #b9c4cf; font-weight: 500; }
.g-tool:active { transform: translateY(2px); box-shadow: 0 1px 0 #0a1722; }
.g-tool:disabled { background: #9aa5af; box-shadow: 0 3px 0 #7d8891; cursor: not-allowed; }
.g-uses {
  position: absolute; top: -7px; right: -7px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 10px; background: var(--accent); color: #fff; font-size: 12px; line-height: 20px;
}
.g-tool:disabled .g-uses { background: #7d8891; }

/* Overlay */
.g-overlay {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px;
  background: rgba(19,40,59,.55);
}
.g-card {
  width: min(360px, 100%); padding: 22px 20px 18px; text-align: center;
  background: #fff; border-radius: 12px; box-shadow: 0 20px 50px rgba(0,0,0,.3);
}
.g-card h2 { margin: 0 0 6px; font-size: 21px; }
.g-card h2 .en { font-size: 13px; margin-top: 2px; }
.g-card p { margin: 0 0 16px; font-size: 14px; color: var(--ink); line-height: 1.45; }
.g-card p .en { font-size: 12px; }
.g-card-actions { display: grid; gap: 8px; }
.g-btn {
  display: block; padding: 10px 14px; border-radius: 8px; border: 0; font-weight: 600; line-height: 1.2;
  background: var(--accent); color: #fff; text-decoration: none; font-size: 15px;
}
.g-btn .en { color: #fff; font-weight: 500; } /* solid white: 85% white on #8e6420 was 4.3:1 */
.g-btn:hover { background: var(--accent-dark); }
.g-btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.g-btn.ghost .en { color: var(--muted); }
.g-btn.ghost:hover { background: #f6f4ef; }

.g-loading { position: fixed; inset: 0; display: grid; place-content: center; text-align: center; margin: 0; background: var(--paper); font-size: 15px; }

@media (max-width: 420px) {
  .g-back > span .en, .g-icon-btn > span .en { display: none; }
  .g-title h1 { font-size: 16px; flex-direction: column; gap: 0; }
  .g-tool { min-width: 0; flex: 1; padding: 7px 8px; font-size: 13px; }
  .g-tools { width: 100%; max-width: 380px; }
}

/* Coloured card faces: each product sits on its own colour (set per card by game.js) */
.tile {
  background: var(--card, #fff); border: 2px solid var(--edge, #d9d2c4);
  padding: calc(var(--t) * .045);
  box-shadow: 0 calc(var(--t) * .07) 0 var(--edge, #cfc6b4), 0 calc(var(--t) * .1) calc(var(--t) * .12) rgba(19,40,59,.22);
}
.tile.in-tray { box-shadow: 0 2px 0 var(--edge, #cfc6b4); }
.tile img { filter: drop-shadow(0 1px 1px rgba(0,0,0,.25)); }
.tile.covered { filter: brightness(.72) saturate(.9); }

/* Cards grow smoothly when the board is re-scaled (fewer cards left = bigger cards) */
.tile { transition: transform .28s cubic-bezier(.3,.8,.3,1), width .28s, height .28s, padding .28s, filter .15s, opacity .2s; }

/* Readability pass (2026-11-11): AA contrast and a 12px floor. */
:root { --muted: #5b6b7a; }
.g-back .en, .g-icon-btn .en, .g-tool .en, .g-help .en { font-size: 12px; }
.g-tool .en { color: #d3dbe2; }
.g-tool:disabled { background: #d5dbe0; color: #3c4e60; box-shadow: 0 3px 0 #b5bec6; }
.g-tool:disabled .en { color: #3c4e60; }
.g-tool:disabled .g-uses { background: #5d6b78; } /* white text >= 4.5:1 */
.g-uses, .g-btn { background: #8e6420; }
.g-btn:not(.ghost):hover { background: #74501a; }

/* Level start: cards are placed without transitions (see buildLevel in game.js) */
.no-anim .tile { transition: none !important; }
