/* Connect the Clues: ARQIV add-on styles. Loaded after the game's own stylesheet. */

/* ---- layout: header, note, board, points table, piece controls, tray */
.aqc-root > header { order: 1; }
.aqc-root > header + div { order: 2; }
.aqc-root > main { order: 3; position: relative; }
#aqc-score { order: 4; }
.aqc-root > section { order: 5; }
.aqc-root > footer { order: 6; }

#aqc-score {
  width: 100%; flex: 0 0 auto; box-sizing: border-box; overflow-y: auto; touch-action: pan-y;
  padding: 4px 12px 4px; background: #0f172a; border-top: 1px solid #1e293b; color: #e2e8f0; font-size: 13px; line-height: 1.3; z-index: 25;
}
#aqc-score h3 { margin: 0 0 2px; font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: #67e8f9; }
#aqc-score table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
#aqc-score th, #aqc-score td { padding: 2px 6px; text-align: right; font-size: 13px; border-bottom: 1px solid #1e293b; }
#aqc-score th:first-child, #aqc-score td:first-child { text-align: left; }
#aqc-score thead th { color: #94a3b8; font-size: 12px; font-weight: 700; }
#aqc-score tbody th { font-weight: 600; color: #f1f5f9; }
#aqc-score .aqc-plain th, #aqc-score .aqc-plain td { color: #94a3b8; font-weight: 400; }
#aqc-score .aqc-loose th, #aqc-score .aqc-loose td { color: #fcd34d; font-weight: 600; }
#aqc-score th, #aqc-score td { height: 16px; line-height: 16px; white-space: nowrap; }
#aqc-score tfoot th, #aqc-score tfoot td { border-bottom: 0; border-top: 2px solid #334155; font-weight: 800; font-size: 14px; color: #fff; }
#aqc-score tfoot td.aqc-top { color: #67e8f9; }
#aqc-status { margin: 2px 0 0; font-size: 12px; line-height: 16px; color: #cbd5e1; min-height: 16px; }
#aqc-predict { margin-top: 6px; padding: 8px; border: 2px solid #22d3ee; border-radius: 12px; background: #083344; box-sizing: border-box; }
#aqc-predict[hidden] { display: none; }
#aqc-predict.aqc-sheet { position: fixed; z-index: 30; margin: 0; border-radius: 0; border-width: 2px 0 0; display: flex; flex-direction: column; justify-content: center; padding: 8px 12px; }
#aqc-predict p { margin: 0 0 6px; font-size: 13px; font-weight: 700; color: #ecfeff; }
.aqc-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }

.aqc-btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; padding: 8px 12px; box-sizing: border-box;
  border: 1px solid #475569; border-radius: 12px; background: #1e293b; color: #f1f5f9; font-family: inherit; font-size: 15px; font-weight: 700; line-height: 1.2; text-decoration: none; cursor: pointer;
}
.aqc-btn:hover { background: #334155; }
.aqc-btn.aqc-primary { background: #22d3ee; border-color: #67e8f9; color: #0f172a; }
.aqc-btn.aqc-primary:hover { background: #67e8f9; }

/* wide screens: points table beside the board */
@media (min-width: 900px) and (min-height: 521px) {
  .aqc-root { display: grid !important; grid-template-columns: minmax(0, 1fr) 340px; grid-template-rows: auto auto minmax(0, 1fr) auto auto; align-items: stretch; justify-items: stretch; }
  .aqc-root > header { grid-column: 1 / -1; grid-row: 1; }
  .aqc-root > header + div { grid-column: 1 / -1; grid-row: 2; }
  .aqc-root > main { grid-column: 1; grid-row: 3; }
  #aqc-score { grid-column: 2; grid-row: 3; max-height: none; border-top: 0; border-left: 1px solid #1e293b; padding: 14px 16px; }
  #aqc-score th, #aqc-score td { padding: 5px 6px; font-size: 14px; }
  .aqc-root > section { grid-column: 1 / -1; grid-row: 4; padding-right: 48px; }
  .aqc-root > footer { grid-column: 1 / -1; grid-row: 5; padding-right: 48px; }
}
/* short landscape (phones on their side): board on the left, everything else on the right */
@media (orientation: landscape) and (max-height: 520px) {
  .aqc-root { display: grid !important; grid-template-columns: minmax(0, 1fr) min(46vw, 380px); grid-template-rows: auto auto minmax(0, 1fr) auto auto; align-items: stretch; justify-items: stretch; }
  .aqc-root > header { grid-column: 1 / -1; grid-row: 1; padding-top: 2px; padding-bottom: 2px; }
  .aqc-root > main { grid-column: 1; grid-row: 2 / 6; }
  .aqc-root > header + div { grid-column: 2; grid-row: 2; }
  .aqc-root > header + div p { font-size: 12px !important; }
  #aqc-score { grid-column: 2; grid-row: 3; max-height: none; min-height: 0; }
  #aqc-status { display: none; }
  .aqc-root > section { grid-column: 2; grid-row: 4; }
  .aqc-root > section > div:first-child { display: none; }
  .aqc-root > section > div:last-child { width: 100%; justify-content: flex-end; }
  .aqc-root > footer { grid-column: 2; grid-row: 5; }
}

/* ---- board sockets as buttons */
#aqc-cells { position: absolute; pointer-events: none; }
.aqc-cell { position: absolute; pointer-events: auto; margin: 0; padding: 0; border: 0; border-radius: 14px; background: transparent; cursor: pointer; touch-action: none; -webkit-tap-highlight-color: transparent; }
.aqc-cell:disabled { cursor: default; }
.aqc-cell:focus-visible { outline: 3px solid #fff; outline-offset: -2px; box-shadow: 0 0 0 6px rgba(34, 211, 238, .55); }
#root button:focus-visible, #root a:focus-visible, #aqc-dialog :focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

/* ---- tray: starts at the left and scrolls; centred when it fits */
#root footer > div:first-child { justify-content: flex-start; touch-action: pan-x; scroll-padding: 8px; align-items: stretch; }
#root footer > div:first-child > button:first-child { margin-left: auto; }
#root footer > div:first-child > button:last-child { margin-right: auto; }
#root footer > div:first-child > button { height: auto; min-height: 76px; background-color: #172033; }
#root footer > div:first-child > button > div:nth-child(2) > span { font-size: 12px; white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.15; }
#root footer > div:first-child > button > div:first-child > span { font-size: 12px; padding: 0 5px; }
#root footer > div:first-child > button > span:last-child { font-size: 12px; }

/* narrow screens: keep the board big. Short labels, smaller tray tiles, no second heading */
@media (max-width: 899px), (max-height: 520px) {
  #aqc-score h3 { display: none; }
  #root header + div h2 { display: none; }
  #root header + div { padding-top: 4px; padding-bottom: 4px; }
  #root footer > div:first-child > button { width: 7.25rem; min-height: 56px; justify-content: center; gap: 2px; }
  #root footer > div:first-child > button > div:first-child { display: none; }
  #root footer > div:first-child > button > div:nth-child(2) { padding-right: 0; justify-content: center; }
  #root footer > div:first-child > button > div:nth-child(2) > span { white-space: nowrap !important; }
  #root footer > div:first-child > button svg { height: 22px; }
  #root footer { padding-top: 6px; padding-bottom: 6px; }
  #root section > div:first-child > span.italic { display: none; }
  #root section { padding-top: 4px; padding-bottom: 4px; }
  #root footer > div:first-child > button > span:last-child { display: none; }
  #root footer > div:last-child > button > span { display: none; }
  #root header { padding-top: 4px; padding-bottom: 4px; }
  #root section > div:first-child > span { line-height: 1.2; }
}
@media (min-width: 900px) and (min-height: 521px) { #root footer > div:first-child > button { width: 8.4rem; } }

/* ---- touch targets and small text */
#root header button { min-width: 44px; min-height: 44px; }
#root section button, #root footer > div:last-child > button { min-width: 44px; min-height: 44px; }
#root header + div p { font-size: 13px; line-height: 1.3; max-width: 62rem; }
#root header + div h2 { font-size: 14px; }
@media (max-width: 520px) { #root header + div p { font-size: 12px; } #root header, #root section, #root footer { padding-left: 10px; padding-right: 10px; } }

/* ---- reveal and end dialog */
#aqc-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#aqc-dialog { position: fixed; inset: 0; z-index: 90; display: flex; overflow-y: auto; padding: 16px; box-sizing: border-box; background: rgba(2, 6, 23, .86); touch-action: pan-y; font-family: Inter, system-ui, sans-serif; }
#aqc-dialog[hidden] { display: none; }
.aqc-box { margin: auto; width: 100%; max-width: 440px; box-sizing: border-box; padding: 22px; border: 2px solid #22d3ee; border-radius: 18px; background: #0f172a; color: #e2e8f0; text-align: center; }
.aqc-box.aqc-wrong { border-color: #fbbf24; }
.aqc-box h2 { margin: 0 0 8px; font-size: 24px; line-height: 1.15; font-weight: 800; color: #67e8f9; }
.aqc-box.aqc-wrong h2 { color: #fcd34d; }
.aqc-box p { margin: 0 0 10px; font-size: 15px; line-height: 1.45; }
.aqc-pic { width: 104px; height: 104px; object-fit: contain; border-radius: 50%; background: #fff; border: 4px solid #22d3ee; margin: 0 auto 10px; display: block; }
.aqc-wrong .aqc-pic { border-color: #fbbf24; }
.aqc-totals { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.aqc-totals span { padding: 4px 10px; border-radius: 999px; background: #1e293b; border: 1px solid #334155; font-weight: 700; font-variant-numeric: tabular-nums; }
.aqc-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }

/* ---- reduced motion */
@media (prefers-reduced-motion: reduce) {
  #root *, #aqc-dialog * { animation: none !important; transition: none !important; }
}
