:root{
  --bg: #f2f2f2;
  --panel: #ffffff;
  --text: #1f1f1f;
  --muted: #5b5b5b;

  --cell: #d9d9d9;
  --cellEmpty: #cfcfcf;
  --gap: 10px;

  --radius: 16px;
  --shadow: 0 10px 30px rgba(0,0,0,0.08);

  --btnBg: #e7e7e7;
  --btnText: #1f1f1f;
  --btnBorder: #cfcfcf;
  --primaryBg: #d8d8d8;
  --primaryBorder: #bdbdbd;

  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", "Liberation Sans", sans-serif;
}

* { box-sizing: border-box; }

body{
  margin: 0;
  font-family: var(--font);
  background: linear-gradient(#f6f6f6, #ededed);
  color: var(--text);
}

.app{
  max-width: 860px;
  margin: 0 auto;
  padding: 22px 16px 28px;
}

.topbar{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.title{
  margin: 0;
  font-size: 40px;
  letter-spacing: 0.5px;
}

.subtitle{
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.3;
  font-size: 14px;
}

.stats{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stat{
  background: var(--panel);
  border: 1px solid #e0e0e0;
  border-radius: var(--radius);
  padding: 12px 14px;
  min-width: 140px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.05);
}

.label{
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.value{
  font-weight: 800;
  font-size: 26px;
}

.boardWrap{
  position: relative;
  background: var(--panel);
  border: 1px solid #e0e0e0;
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}

.grid{
  width: 100%;
  max-width: 540px;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gap);
  padding: 6px;
  background: #f7f7f7;
  border-radius: calc(var(--radius) - 6px);
}

.cell{
  border-radius: 14px;
  background: var(--cellEmpty);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.tile{
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 14px;
  font-weight: 900;
  color: #1a1a1a;

  transform: translateZ(0);
  transition: transform 120ms ease, background-color 120ms ease, color 120ms ease;
}

.tile span{
  font-size: 30px;
  line-height: 1;
  padding: 0 8px;
}

@media (max-width: 460px){
  .title{ font-size: 34px; }
  .tile span{ font-size: 26px; }
}

.overlay{
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  padding: 18px;
}

.hidden{ display: none; }

.overlayCard{
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  width: min(440px, 100%);
  box-shadow: var(--shadow);
  text-align: center;
}

.overlayCard h2{
  margin: 6px 0 6px;
  font-size: 26px;
}

.overlayCard p{
  margin: 0 0 12px;
  color: var(--muted);
}

.overlayActions{
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn{
  appearance: none;
  border: 1px solid var(--btnBorder);
  background: var(--btnBg);
  color: var(--btnText);
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 80ms ease, background-color 120ms ease;
}

.btn:active{ transform: scale(0.98); }
.btn:disabled{
  opacity: 0.55;
  cursor: not-allowed;
}

.primary{
  background: var(--primaryBg);
  border-color: var(--primaryBorder);
}

.controls{
  margin-top: 12px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

kbd{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 8px;
  border: 1px solid #d3d3d3;
  background: #f6f6f6;
}
