/* 免費工具頁 /tools/*（不含抽獎轉盤，它有自己的 lucky-wheel.css）：在 site.css 之上，
   和轉盤同一套粗框、硬陰影、品牌色。 */
/* 有 display 的元素加上 hidden 也要真的隱藏 */
.tool [hidden] { display: none !important; }
.tool-head { padding-block: 40px 0; }
.tool-content { padding-top: 8px; }

.tool {
  width: min(1180px, calc(100% - 48px));
  margin: 32px auto 0;
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 28px;
  align-items: start;
}
.tool-panel { padding: 24px; border: var(--line); border-radius: 4px; background: var(--white); }
.tool-stage { min-height: 320px; padding: 24px; border: var(--line); border-radius: 4px; background: var(--white); box-shadow: 9px 9px 0 var(--blue); }

.tool-label, .tool-panel legend { display: block; margin: 0 0 8px; padding: 0; font-weight: 900; font-size: 18px; }
.tool-panel fieldset { margin: 18px 0 0; padding: 0; border: 0; min-width: 0; }
.tool-items {
  display: block; width: 100%; min-height: 200px; padding: 12px 14px; resize: vertical;
  border: var(--line); border-radius: 4px; background: var(--paper); color: var(--ink);
  font: inherit; font-size: 16px; line-height: 1.6;
}
.tool-note { margin: 8px 0 0; color: var(--muted); font-size: 14px; font-weight: 700; }
.tool-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }
.tool-sub { margin: 18px 0 0; color: var(--muted); font-size: 14px; font-weight: 800; }

/* 按鈕 */
.tool-btn {
  min-height: 48px; padding: 8px 16px;
  border: var(--line); border-radius: 4px; background: var(--white); color: var(--ink);
  font: inherit; font-size: 15px; font-weight: 800; cursor: pointer;
}
.tool-btn:hover { background: var(--lime); }
.tool-btn:disabled, .tool-go:disabled { opacity: 0.55; cursor: not-allowed; }
.tool-btn:disabled:hover { background: var(--white); }
.tool-chip { min-height: 44px; padding: 6px 14px; border: var(--line); border-radius: 999px; background: var(--paper); color: var(--ink); font: inherit; font-size: 15px; font-weight: 750; cursor: pointer; }
.tool-chip:hover { background: var(--lime); }
.tool-go { font: inherit; font-size: 20px; font-weight: 850; cursor: pointer; }
.tool-go:disabled { transform: none; box-shadow: none; }
.tool-actions { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-top: 20px; }

/* 選項：單選做成並排的大按鈕 */
.tool-choice { display: flex; flex-wrap: wrap; gap: 10px; }
.tool-choice label { position: relative; display: inline-flex; min-height: 48px; padding: 8px 16px; align-items: center; border: var(--line); border-radius: 4px; background: var(--white); font-weight: 800; cursor: pointer; }
.tool-choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tool-choice label:has(input:checked) { background: var(--ink); color: var(--lime); }
.tool-choice label:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.tool-field { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-top: 14px; font-weight: 750; }
.tool-field input[type="number"], .tool-field input[type="text"], .tool-field select {
  min-height: 48px; padding: 6px 10px; border: var(--line); border-radius: 4px;
  background: var(--white); color: var(--ink); font: inherit; font-size: 16px; font-weight: 750;
}
.tool-field input[type="number"] { width: 6.5em; }
.tool-field input[type="text"] { flex: 1 1 12em; min-width: 0; }
.tool-check { display: inline-flex; gap: 10px; align-items: center; min-height: 48px; margin-top: 8px; font-weight: 750; cursor: pointer; }
.tool-check input { width: 22px; height: 22px; accent-color: var(--ink); }
.tool-error { margin: 10px 0 0; color: #b3261e; font-weight: 800; }

.tool-empty { margin: 0; color: var(--muted); font-weight: 700; }
.tool-status { margin: 0 0 14px; font-weight: 900; font-size: 18px; }
.tool-stage-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; }
.tool-stage-head .tool-status { margin: 0; }

.tool-promo { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: center; justify-content: space-between; padding: 16px 22px; border: var(--line); border-radius: 4px; background: var(--lime); }
.tool-promo p { margin: 0; font-weight: 650; }
.tool-promo a { display: inline-flex; min-height: 48px; align-items: center; font-weight: 900; }

/* 隨機分組 */
.groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin: 16px 0 0; padding: 0; list-style: none; }
.groups > li { padding: 14px 16px; border: var(--line); border-radius: 4px; background: var(--paper); }
.groups > li:nth-child(4n+1) { box-shadow: 5px 5px 0 var(--coral); }
.groups > li:nth-child(4n+2) { box-shadow: 5px 5px 0 var(--lime); }
.groups > li:nth-child(4n+3) { box-shadow: 5px 5px 0 var(--blue); }
.groups > li:nth-child(4n) { box-shadow: 5px 5px 0 var(--ink); }
.groups h3 { margin: 0 0 6px; font-size: 18px; font-weight: 900; }
.groups h3 span { margin-left: 6px; color: var(--muted); font-size: 14px; font-weight: 700; }
.groups ol { margin: 0; padding-left: 1.5em; }

/* 抽籤 */
.pick-show { display: grid; place-items: center; min-height: 180px; margin: 0; padding: 20px; border: var(--line); border-radius: 4px; background: var(--paper); text-align: center; }
.pick-show p { margin: 0; }
.pick-names { display: flex; flex-wrap: wrap; gap: 6px 20px; justify-content: center; font-size: clamp(30px, 6vw, 56px); font-weight: 900; line-height: 1.2; }
.pick-names.is-many { font-size: clamp(22px, 3.6vw, 32px); }
.pick-show.is-rolling .pick-names { color: var(--muted); }
.pick-list { max-height: 260px; margin: 8px 0 0; padding-left: 2.4em; overflow-y: auto; font-size: 16px; }
.pick-list li + li { margin-top: 2px; }
.pick-history { margin-top: 20px; padding-top: 14px; border-top: var(--line); }
.pick-history h2 { margin: 0; font-size: 18px; font-weight: 900; }
.tool-link { min-height: 44px; padding: 0 8px; border: 0; background: none; color: var(--ink); font: inherit; font-size: 14px; font-weight: 800; text-decoration: underline; text-underline-offset: 4px; cursor: pointer; }

/* 賓果卡 */
.bingo-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; margin-top: 16px; }
.bingo-card { margin: 0; padding: 12px; border: var(--line); border-radius: 4px; background: var(--white); break-inside: avoid; }
.bingo-card figcaption { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 8px; font-weight: 900; }
.bingo-card figcaption span { color: var(--muted); font-size: 14px; }
.bingo-card table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.bingo-card td { height: 0; padding: 0; border: var(--line); text-align: center; vertical-align: middle; font-weight: 850; line-height: 1.2; overflow-wrap: anywhere; }
.bingo-card td > span { display: flex; aspect-ratio: 1; align-items: center; justify-content: center; padding: 3px; }
.bingo-card.is-5 td { font-size: 17px; }
.bingo-card.is-3 td { font-size: 26px; }
.bingo-card.is-words td { font-size: 13px; }
.bingo-card.is-words.is-3 td { font-size: 17px; }
.bingo-card td.is-free { background: var(--lime); font-size: 13px; }

/* 骰子 */
.dice-tray { display: flex; flex-wrap: wrap; gap: 18px; justify-content: center; align-items: center; min-height: 200px; padding: 24px 12px; border: var(--line); border-radius: 4px; background: var(--paper); }
.die { width: clamp(72px, 18vw, 112px); aspect-ratio: 1; }
.die rect { fill: var(--white); stroke: var(--ink); stroke-width: 4; }
.die circle { fill: var(--ink); }
.die.is-one circle { fill: var(--coral); }
.dice-tray.is-rolling .die { animation: die-tumble 520ms cubic-bezier(.3, .7, .4, 1); }
@keyframes die-tumble { 0% { transform: rotate(-160deg) scale(0.7); } 60% { transform: rotate(14deg) scale(1.05); } 100% { transform: none; } }
.dice-total { margin: 16px 0 0; text-align: center; font-size: 22px; font-weight: 900; }
.dice-total strong { font-size: 44px; }

@media (prefers-reduced-motion: reduce) { .dice-tray.is-rolling .die { animation: none; } }

@media (max-width: 900px) {
  .tool { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .tool { width: calc(100% - 32px); margin-top: 24px; gap: 20px; }
  .tool-head { padding-top: 24px; }
  .tool-panel { padding: 18px; }
  .tool-stage { padding: 18px 14px; box-shadow: 6px 6px 0 var(--blue); }
  .tool-items { min-height: 160px; }
  .tool-promo { padding: 14px 16px; }
  .tool-go { width: 100%; }
}

/* 列印：只印賓果卡，一頁兩張（5×5）或四張（3×3） */
@media print {
  @page { margin: 12mm; }
  body { background: none; }
  .site-skip, .site-nav, .site-language, .tool-head, .tool-panel, .tool-promo, .tool-content, .site-footer, .tool-stage-head, .tool-noprint { display: none !important; }
  .tool, .tool-stage { display: block; width: auto; margin: 0; padding: 0; border: 0; box-shadow: none; background: none; }
  .bingo-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10mm; margin: 0; }
  .bingo-cards.is-5 { grid-template-columns: 1fr; justify-items: center; }
  .bingo-cards.is-5 .bingo-card { width: 120mm; }
  .bingo-card { page-break-inside: avoid; }
  .bingo-card.is-5 td { font-size: 22pt; }
  .bingo-card.is-words.is-5 td { font-size: 11pt; }
}
