:root {
  --bg: #eef1f7;
  --panel: #ffffff;
  --muted: #6b7280;
  --accent: #2563eb;
  --ad: #f7f8fb;
  --shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
  --radius: 22px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #111827;
  background: linear-gradient(180deg, #f5f7fb 0%, #e9edf5 100%);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.page {
  min-height: 100%;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
  max-width: 1200px;
  margin: 0 auto;
}
.ad-slot {
  /* border: 2px dashed #c9d2e3; */
  /* background: var(--ad); */
  /* border-radius: 18px; */
  display: block;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.ad-slot-top{
  display: block;
}
.ad-slot-bottom{
  display: block;
}
.header {
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(10px);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: grid;
  gap: 10px;
}
.title-header {
  align-items: start;
}
.controls-header {
  padding-top: 10px;
  padding-bottom: 10px;
}
.header-ad {
  margin: 2px 0;
}
h1 {
  margin: 0;
  font-size: clamp(20px, 3vw, 28px);
}
.subtitle {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}
.title-card-image {
  display: block;
  width: min(100%, 420px);
  height: auto;
  margin-top: 10px;
  border-radius: 12px;
}
.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.button-group {
  display: flex;
  gap: 8px;
}
.page button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 11px 15px;
  font-size: 14px;
  font-weight: 700;
  background: #111827;
  color: white;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(17, 24, 39, 0.18);
  transition: background 0.18s, color 0.18s, box-shadow 0.18s, transform 0.12s;
}

.page button:hover, .page button:focus-visible {
  background: #1e293b;
  color: #fff;
  box-shadow: 0 12px 28px rgba(17, 24, 39, 0.22);
  transform: scale(1.06);
}

.page button:active {
  background: #0f172a;
  color: #fff;
  box-shadow: 0 4px 10px rgba(17, 24, 39, 0.12);
  transform: scale(0.96);
}
.page button.secondary {
  background: #ffffff;
  color: #111827;
  border: 1px solid #d8deea;
  box-shadow: none;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s, transform 0.12s, border 0.18s;
}
.page button.secondary:hover, .page button.secondary:focus-visible {
  background: #f3f6fb;
  color: #2563eb;
  border: 1.5px solid #2563eb;
  box-shadow: 0 6px 18px rgba(37,99,235,0.10);
  transform: scale(1.06);
}
.page button.secondary:active {
  background: #e0e7ef;
  color: #1e293b;
  border: 1.5px solid #1e293b;
  box-shadow: 0 2px 6px rgba(37,99,235,0.06);
  transform: scale(0.96);
}
.meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.chip {
  background: #f3f6fb;
  border: 1.5px solid #dbe4f0;
  color: #334155;
  font-size: 1em;
  font-weight: 600;
  padding: 9px 20px;
  border-radius: 8px;
  box-shadow: none;
  letter-spacing: 0.04em;
  cursor: default;
  user-select: none;
  transition: none;
}
.content {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}
.board-wrap {
  background: rgba(255,255,255,0.95);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 10px;
  display: grid;
  place-items: center;
  min-height: 340px;
  position: relative;
  overflow: hidden;
}
canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 22px;
  background: #eef1f7;
  touch-action: manipulation;
}
.toast {
  position: absolute;
  left: 50%;
  top: 18px;
  transform: translateX(-50%);
  background: rgba(91, 94, 102, 0.9);
  color: white;
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 13px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.toast.show { opacity: 1; }
.footer-note {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  padding-bottom: 8px;
}
@media (min-width: 980px) {
  .content {
    grid-template-columns: minmax(0, 1fr) 240px;
  }
  .side-ad {
    display: block;
    min-height: 100%;
  }
  .ad-slot-top{
    display: none;
  }
  .ad-slot-bottom{
    display: block;
  }
  .controls{
    width: 100%;
    justify-content: space-between;
    align-items: center;
  }
  .button-group {
    gap: 2em;
  }
}
@media (max-width: 979px) {
  .side-ad { display: none; }
  .ad-slot-top{
    display: block;
  }
  .ad-slot-bottom{
    display: none;
  }
  .page{
    padding: max(12px, env(safe-area-inset-top)) 0 max(12px, env(safe-area-inset-bottom));
  }
  .controls{
    width: 100%;
    justify-content: space-between;
    align-items: center;
  }
  .button-group {
    gap: 8px;
  }
}
