:root {
  --bg: var(--tg-theme-bg-color, #fff);
  --fg: var(--tg-theme-text-color, #111);
  --sec: var(--tg-theme-secondary-bg-color, #eef2f4);
  --hint: var(--tg-theme-hint-color, #777);
  --btn: var(--tg-theme-button-color, #56b6c2);
  --btnfg: var(--tg-theme-button-text-color, #fff);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font: 16px system-ui, sans-serif; }
body { display: flex; justify-content: center; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
main { width: min(100%, 520px); padding: 8px; display: flex; flex-direction: column; gap: 8px; }
button { font: inherit; border: 0; border-radius: 8px; padding: 9px 12px; background: var(--sec); color: var(--fg); }
button.on { background: var(--btn); color: var(--btnfg); }
button.danger { color: #d33; }
#levels, #tools, #rtabs { display: flex; gap: 6px; }
#levels button, #tools button, #rtabs button { flex: 1; }
#levels button, #rtabs button { padding: 6px 4px; font-size: 13px; line-height: 1.25; }
#levels b { display: block; }
#levels small { display: block; visibility: hidden; font-size: 12px; }
#levels .on small { visibility: visible; }
#bar { display: flex; justify-content: space-between; align-items: center; font-variant-numeric: tabular-nums; }
#status { color: var(--hint); font-size: 14px; text-align: center; flex: 1; padding: 0 6px; }
#grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.c { aspect-ratio: 1; padding: 0; border-radius: 4px; background: #add8e6; line-height: 1; color: #fff; font-weight: 700; font-size: clamp(14px, 5vw, 24px); }
.c.open { background-color: #56b6c2; }
.c.flag, .c.mine { font-size: clamp(13px, 4.6vw, 22px); }
.c.boom { background-color: #fa0202; }
.c.ok { background-color: #76f1bc; }
.c.bad { background-color: #ffacb6; }
@media (hover: hover) { .c:not(.open):not(.boom):hover { background-color: #d3d3d3; } }
.hint { margin: 0; text-align: center; color: var(--hint); font-size: 13px; }
dialog { border: 0; border-radius: 12px; background: var(--bg); color: var(--fg); width: min(92vw, 420px); max-height: 85vh; }
dialog::backdrop { background: rgba(0, 0, 0, .5); }
.x { float: right; }
#rlist { padding-left: 24px; min-height: 80px; }
#profile { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--sec); margin-top: 8px; }
#profile input[type=text], #pname { width: 100%; padding: 8px; border-radius: 6px; border: 1px solid var(--hint); background: var(--bg); color: var(--fg); font: inherit; }
#pnote { margin: 0; color: var(--hint); font-size: 14px; }
