:root {
  --bg: #1a211c;
  --bg-2: #232b25;
  --panel: #2a342d;
  --line: #3d4a40;
  --text: #e8efe6;
  --muted: #9aab9c;
  --accent: #c6f25b;
  --accent-dim: #8fb83a;
  --warn: #ffb454;
  --danger: #ff6b6b;
  --ok: #5ddea6;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  --radius: 18px;
  --font: "IBM Plex Sans SC", "PingFang SC", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}

.desk-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 500px at 10% -10%, rgba(198, 242, 91, 0.12), transparent 60%),
    radial-gradient(700px 400px at 100% 0%, rgba(93, 222, 166, 0.08), transparent 55%),
    linear-gradient(180deg, #151a16, #1a211c 40%, #121612);
}
.desk-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.04;
  background-image: linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 48px 48px;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 20px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid rgba(61, 74, 64, 0.6);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(26, 33, 28, 0.85);
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--accent), var(--accent-dim));
  color: #152016;
  font-size: 20px;
  font-weight: 700;
}
.brand strong { display: block; font-size: 1.05rem; letter-spacing: 0.02em; }
.brand em { display: block; font-style: normal; color: var(--muted); font-size: 0.78rem; }
.top-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.stat {
  display: flex; flex-direction: column; align-items: flex-end;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-2);
}
.stat span { font-size: 0.7rem; color: var(--muted); }
.stat b { font-family: var(--mono); color: var(--accent); font-size: 1.05rem; }

.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  border-radius: 999px;
  padding: 10px 16px;
  background: var(--accent);
  color: #152016;
  transition: transform 0.15s ease, filter 0.15s ease;
}
.btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
.btn:active { transform: translateY(0); }

main { padding: 28px clamp(16px, 4vw, 40px) 80px; max-width: 1100px; margin: 0 auto; }

.hero { margin-bottom: 28px; max-width: 640px; }
.eyebrow {
  display: inline-block;
  margin: 0 0 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}
.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}
.hero h1 span { color: var(--accent); }
.lead { margin: 14px 0 0; color: var(--muted); font-size: 1.05rem; line-height: 1.6; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.card {
  text-align: left;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(42, 52, 45, 0.95), rgba(28, 36, 31, 0.95));
  color: inherit;
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  font-family: inherit;
  display: grid;
  gap: 8px;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  min-height: 150px;
}
.card:hover {
  border-color: rgba(198, 242, 91, 0.45);
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}
.card-ico { font-size: 1.6rem; }
.card-name { font-size: 1.15rem; font-weight: 700; }
.card-desc { color: var(--muted); font-size: 0.9rem; line-height: 1.45; }

.foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 18px clamp(16px, 4vw, 40px);
  border-top: 1px solid rgba(61, 74, 64, 0.6);
  color: var(--muted);
  font-size: 0.82rem;
}
kbd {
  font-family: var(--mono);
  font-size: 0.78em;
  padding: 1px 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--accent);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(8, 12, 9, 0.72);
  display: grid;
  place-items: center;
  padding: 16px;
  backdrop-filter: blur(6px);
}
.modal.hidden, .camouflage.hidden { display: none; }
.modal-panel {
  width: min(720px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal-bar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.modal-bar h2 { margin: 0; font-size: 1.2rem; }
.modal-hint { margin: 4px 0 0; color: var(--muted); font-size: 0.85rem; }
.modal-actions { display: flex; gap: 8px; flex-shrink: 0; }
.game-stage {
  min-height: 360px;
  display: grid;
  place-items: center;
  padding: 16px;
  background: #1c241f;
}
.score-bar {
  display: flex;
  justify-content: space-between;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--muted);
}
.score-bar b { color: var(--accent); }

/* Camouflage */
.camouflage {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: #f4f6f8;
  color: #1f2933;
  display: grid;
  place-items: center;
  padding: 24px;
  cursor: pointer;
  font-family: "Segoe UI", "PingFang SC", sans-serif;
}
.sheet {
  width: min(860px, 100%);
  background: #fff;
  border: 1px solid #d9e2ec;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  padding: 20px 24px 16px;
}
.sheet-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  font-weight: 600;
  color: #334e68;
}
.sheet-live {
  font-size: 0.75rem;
  color: #0c6b58;
  background: #e3fcef;
  padding: 4px 8px;
  border-radius: 999px;
}
.sheet table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.sheet th, .sheet td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid #e4e7eb;
}
.sheet th { color: #627d98; font-weight: 600; }
.up { color: #0c6b58; font-weight: 600; }
.down { color: #9b1c1c; font-weight: 600; }
.sheet-hint { margin: 14px 0 0; color: #829ab1; font-size: 0.82rem; }

/* Shared game widgets */
.game-wrap { width: 100%; display: grid; gap: 12px; justify-items: center; }
canvas.game-canvas {
  background: #121812;
  border: 1px solid var(--line);
  border-radius: 12px;
  max-width: 100%;
  image-rendering: pixelated;
}
.soft-btn-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.chip {
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  font-family: inherit;
  cursor: pointer;
}
.chip:hover { border-color: var(--accent-dim); }

/* 2048 */
.board-2048 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: min(360px, 92vw);
  padding: 10px;
  background: #141b16;
  border-radius: 14px;
  border: 1px solid var(--line);
}
.cell-2048 {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #243028;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1.35rem;
  color: var(--text);
}
.n2 { background: #2f3d33; }
.n4 { background: #35503a; }
.n8 { background: #3f6b2f; color: #f3ffe0; }
.n16 { background: #5a8f28; color: #f3ffe0; }
.n32 { background: #7db82a; color: #152016; }
.n64 { background: #a6e035; color: #152016; }
.n128, .n256, .n512, .n1024, .n2048 {
  background: linear-gradient(145deg, var(--accent), #8fd14b);
  color: #152016;
  font-size: 1.1rem;
}

/* Memory */
.memory-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: min(380px, 92vw);
}
.mem-card {
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #243028;
  font-size: 1.6rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.15s;
}
.mem-card.back { color: transparent; background: linear-gradient(160deg, #2c3a31, #1a221d); }
.mem-card.back::after { content: "?"; color: var(--muted); font-family: var(--mono); }
.mem-card.matched { opacity: 0.45; pointer-events: none; }
.mem-card:not(.back):not(.matched) { background: #33453a; }

/* Reaction */
.react-arena {
  width: min(420px, 92vw);
  height: 260px;
  border-radius: 16px;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 20px;
  cursor: pointer;
  user-select: none;
  background: #2a3140;
  transition: background 0.05s;
}
.react-arena.wait { background: #7a2430; }
.react-arena.go { background: #1f6b45; }
.react-arena .big { font-size: 1.4rem; font-weight: 700; }

/* Catch */
.catch-area {
  position: relative;
  width: min(420px, 92vw);
  height: 320px;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(#152018, #1c261f);
}
.catch-item {
  position: absolute;
  font-size: 1.4rem;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.catch-paddle {
  position: absolute;
  bottom: 12px;
  width: 78px;
  height: 14px;
  border-radius: 999px;
  background: var(--accent);
  transform: translateX(-50%);
}

/* Mines */
.mines-board {
  display: grid;
  gap: 3px;
  background: #101510;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid var(--line);
}
.mine-cell {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 4px;
  background: #2a372f;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}
.mine-cell.open { background: #1a221d; cursor: default; }
.mine-cell.boom { background: var(--danger); }
.mine-cell.flag { background: #3d3420; color: var(--warn); }

@media (max-width: 640px) {
  .top { align-items: flex-start; flex-direction: column; }
  .modal-bar { flex-direction: column; }
  .mine-cell { width: 26px; height: 26px; }
}
