:root {
  --aq-bg: #f7f5f0;
  --aq-surface: #fff;
  --aq-text: #171717;
  --aq-muted: #66635e;
  --aq-border: #dedcd6;
  --aq-accent: #8b2f35;
  --aq-positive: #315f4c;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--aq-bg); }
body { margin: 0; }

body.host-artquiz {
  min-height: 100vh;
  background: var(--aq-bg);
  color: var(--aq-text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button { font-family: inherit; }

.host-artquiz .aq {
  width: min(100%, 1200px);
  margin: 0 auto;
  padding: calc(34px + env(safe-area-inset-top)) clamp(20px, 4vw, 56px) calc(132px + env(safe-area-inset-bottom));
}

.aq-header {
  display: flex;
  align-items: center;
  gap: clamp(18px, 3vw, 44px);
  padding-bottom: 24px;
  border-bottom: 1px solid var(--aq-border);
}

.aq-title { margin-right: auto; }
.aq-title h1 {
  margin: 0;
  color: var(--aq-text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(27px, 3vw, 38px);
  font-weight: 400;
  letter-spacing: -0.045em;
  line-height: 1;
}
.aq-title p { margin: 8px 0 0; color: var(--aq-muted); font-size: 12px; line-height: 1.5; }
.aq-scoreboard { display: flex; align-items: center; gap: clamp(16px, 2.5vw, 36px); }
.aq-stat { display: flex; align-items: baseline; gap: 7px; white-space: nowrap; }
.aq-stat-label { color: var(--aq-muted); font-size: 12px; }
.aq-stat-value { color: var(--aq-text); font-size: 14px; font-weight: 600; }
.aq-strike-dots { color: var(--aq-accent); font-size: 18px; letter-spacing: 2px; line-height: 1; }
.aq-footer a:hover { color: var(--aq-accent); }

.aq-view { min-height: 50vh; }
.aq-view-header { max-width: 720px; padding: clamp(32px, 5vw, 64px) 0 18px; }
.aq-view-header h2 { margin: 10px 0; font: 400 clamp(36px, 5vw, 54px)/1.15 Georgia, "Times New Roman", serif; }
.aq-view-header p { color: var(--aq-muted); font-size: 14px; line-height: 1.6; }
.aq-quick-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 30px; padding: 20px 0; border-bottom: 1px solid var(--aq-border); }
.aq-quick-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.aq-quick-controls .aq-mode { padding: 8px 12px; min-height: 40px; }
.aq[data-view="explore"] .aq-scoreboard, .aq[data-view="stats"] .aq-scoreboard, .aq[data-view="settings"] .aq-scoreboard { display: none; }

.aq-app-nav {
  position: fixed;
  z-index: 100;
  left: 50%; bottom: 0;
  transform: translateX(-50%);
  display: flex;
  justify-content: space-around;
  width: min(100%, 620px);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  border: 1px solid var(--aq-border);
  border-bottom: 0;
  background: rgba(255,255,255,.97);
}
.aq-app-nav a { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; min-height: 52px; gap: 2px; color: var(--aq-muted); font-size: 11px; text-decoration: none; }
.aq-app-nav a span { font-size: 20px; line-height: 1; }
.aq-app-nav a[aria-current="page"] { color: var(--aq-accent); font-weight: 650; }
.aq-app-nav a:hover { color: var(--aq-accent); }
.aq-app-nav a:focus-visible { outline: 2px solid var(--aq-accent); outline-offset: -2px; }

.aq-explore-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 38px 24px; margin: 24px 0; }
.aq-explore-grid h3 { grid-column: 1 / -1; margin: 12px 0 -16px; font: 400 22px Georgia, "Times New Roman", serif; }
.aq-explore-item { min-width: 0; padding: 10px; border: 1px solid transparent; background: none; color: var(--aq-text); text-align: left; cursor: pointer; }
.aq-explore-item:hover, .aq-explore-item:focus-visible { border-color: var(--aq-border); background: var(--aq-surface); }
.aq-explore-item img { display: block; width: 100%; height: 230px; object-fit: contain; }
.aq-explore-item strong { display: block; margin-top: 12px; font: 400 18px/1.25 Georgia, "Times New Roman", serif; }
.aq-explore-item span { display: block; margin-top: 5px; color: var(--aq-muted); font-size: 12px; }
.aq-explore-detail { max-width: 850px; margin: 22px auto 48px; }
.aq-explore-detail img { display: block; max-width: 100%; max-height: 65vh; width: auto; margin: 22px auto; object-fit: contain; }
.aq-explore-detail h3 { font: 400 30px/1.2 Georgia, "Times New Roman", serif; margin: 14px 0 8px; }
.aq-explore-detail p { color: var(--aq-muted); line-height: 1.6; }
.aq-stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 24px; margin: 24px 0 56px; }
.aq-stats-grid div { padding: 20px 0; border-top: 1px solid var(--aq-border); }
.aq-stats-grid span { display: block; color: var(--aq-muted); font-size: 13px; }
.aq-stats-grid strong { display: block; margin-top: 12px; font: 400 35px Georgia, "Times New Roman", serif; }
.aq-settings-about { max-width: 65ch; color: var(--aq-muted); font-size: 13px; line-height: 1.6; }
.aq-settings-section { margin: 32px 0 20px; border-top: 1px solid var(--aq-border); }
.aq-settings-section h3 { margin: 20px 0 12px; color: var(--aq-muted); font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; }
.aq-install-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; width: 100%; min-height: 72px; padding: 12px 0; border: 0; background: transparent; color: var(--aq-text); cursor: pointer; text-align: left; }
.aq-install-row strong, .aq-install-row span span { display: block; }
.aq-install-row strong { font-size: 16px; font-weight: 600; }
.aq-install-row span span { margin-top: 5px; color: var(--aq-muted); font-size: 13px; line-height: 1.5; }
.aq-install-row > span:last-child { color: var(--aq-accent); font-size: 20px; }
.aq-install-row:hover strong { color: var(--aq-accent); }
.aq-install-row:focus-visible, .aq-install-panel button:focus-visible { outline: 2px solid var(--aq-accent); outline-offset: 3px; }
.aq-install-sheet { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 20px; }
.aq-install-sheet[hidden] { display: none; }
.aq-install-backdrop { position: absolute; inset: 0; background: rgba(25, 22, 20, .63); }
.aq-install-panel { position: relative; width: min(100%, 460px); padding: 30px; background: var(--aq-surface); border: 1px solid var(--aq-border); box-shadow: 0 16px 50px rgba(24, 22, 19, .18); }
.aq-install-panel h2 { margin: 10px 0 20px; font: 400 30px/1.2 Georgia, "Times New Roman", serif; }
.aq-install-panel ol { margin: 0; padding-left: 24px; line-height: 1.8; }
.aq-install-panel li { padding-left: 6px; }
.aq-install-panel p { color: var(--aq-muted); font-size: 13px; line-height: 1.6; }
.aq-install-panel .aq-btn { margin-top: 12px; }

.aq-card { padding: clamp(32px, 5vw, 66px) 0 32px; }
.aq-question-meta { margin-bottom: 14px; color: var(--aq-muted); font-size: 11px; letter-spacing: .09em; text-transform: uppercase; }
.aq-question h2 {
  margin: 0;
  color: var(--aq-text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(32px, 4.2vw, 54px);
  font-weight: 400;
  letter-spacing: -.035em;
  line-height: 1.15;
}
.aq-sub { margin: 12px 0 0; color: var(--aq-muted); font-size: 15px; line-height: 1.5; }
.aq-sub:empty { display: none; }

.aq-target { margin: 36px auto 0; max-width: 850px; }
.aq-target-img { display: flex; justify-content: center; cursor: zoom-in; }
.aq-target-img img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(62vh, 660px);
  object-fit: contain;
  background: var(--aq-surface);
  box-shadow: 0 2px 14px rgba(24, 22, 19, .09);
}
.aq-target-body { padding: 20px 0 0; }
.aq-target-title, .aq-explain-title {
  font-family: Georgia, "Times New Roman", serif;
  color: var(--aq-text);
  font-size: clamp(21px, 2.5vw, 29px);
  line-height: 1.25;
}
.aq-target-meta, .aq-explain-meta, .aq-profile-meta { margin-top: 6px; color: var(--aq-muted); font-size: 13px; line-height: 1.5; }
.aq-target-desc, .aq-explain-desc, .aq-profile-desc { margin-top: 12px; max-width: 70ch; color: #45423e; font-size: 14px; line-height: 1.7; }
.aq-target-source, .aq-explain-source, .aq-profile-source { margin-top: 12px; color: var(--aq-muted); font-size: 12px; }
.aq a { color: var(--aq-accent); text-underline-offset: 3px; }

.aq-profile { display: flex; align-items: center; gap: 24px; margin-top: 24px; }
.aq-profile-img { width: 96px; height: 96px; flex: 0 0 96px; }
.aq-profile-img:not(.is-placeholder) { cursor: zoom-in; }
.aq-profile-img img { display: block; width: 100%; height: 100%; object-fit: contain; }
.aq-profile-img.is-placeholder { opacity: .48; }
.aq-profile-title { font-family: Georgia, "Times New Roman", serif; font-size: 22px; }
.aq-profile-desc { max-height: 110px; overflow: auto; }

.aq-grid { display: grid; gap: 12px; margin: 36px auto 0; }
.aq-grid.is-label-grid { max-width: 850px; }
.aq-option { font: inherit; color: var(--aq-text); cursor: pointer; text-align: left; }
.aq-option.is-label {
  display: flex;
  align-items: center;
  gap: 18px;
  width: 100%;
  min-height: 60px;
  padding: 9px 18px;
  border: 1px solid var(--aq-border);
  border-radius: 2px;
  background: var(--aq-surface);
  transition: border-color .15s ease, background .15s ease;
}
.aq-option.is-label:not(:disabled):hover { border-color: var(--aq-accent); background: #faf8f5; }
.aq-option-avatar { flex: 0 0 40px; width: 40px; height: 40px; }
.aq-option-avatar img { display: block; width: 100%; height: 100%; object-fit: contain; }
.aq-option.is-placeholder .aq-option-avatar { opacity: .5; }
.aq-option-title { font-size: 16px; line-height: 1.35; }
.aq-option-meta { margin-top: 5px; color: var(--aq-muted); font-size: 12px; line-height: 1.4; }
.aq-grid.is-artwork-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: clamp(20px, 4vw, 56px);
  row-gap: 40px;
}
.aq-option.is-artwork {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
  border: 1px solid transparent;
  background: transparent;
  padding: 12px;
  transition: background .15s ease, border-color .15s ease;
}
.aq-option.is-artwork:not(:disabled):hover { background: #efede8; }
.aq-option.is-artwork img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: clamp(200px, 30vw, 380px);
  object-fit: contain;
  box-shadow: 0 2px 12px rgba(24, 22, 19, .09);
}
.aq-option.is-artwork .aq-option-body { align-self: stretch; margin-top: 14px; }
.aq-option.is-artwork .aq-option-title { font-family: Georgia, "Times New Roman", serif; font-size: 17px; }
.aq-option.correct { border-color: var(--aq-positive); background: #f1f6f2; }
.aq-option.wrong { border-color: var(--aq-accent); background: #fbf3f2; }
.aq-option.correct .aq-option-body::after, .aq-option.wrong .aq-option-body::after {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 600;
}
.aq-option.correct .aq-option-body::after { content: "✓ Correct answer"; color: var(--aq-positive); }
.aq-option.wrong .aq-option-body::after { content: "✕ Your answer"; color: var(--aq-accent); }
.aq-option:disabled { cursor: default; }
.aq-option:disabled:not(.correct):not(.wrong) { opacity: .7; }

.aq-explain {
  display: flex;
  align-items: flex-start;
  gap: 22px;
  margin: 34px auto 0;
  max-width: 850px;
  padding: 24px 0;
  border-top: 1px solid var(--aq-border);
  border-bottom: 1px solid var(--aq-border);
}
.aq-explain-thumb { flex: 0 0 88px; cursor: zoom-in; }
.aq-explain-thumb img { display: block; width: 88px; height: 88px; object-fit: contain; }
.aq-explain-body { min-width: 0; }
.aq-actions { display: flex; justify-content: flex-end; gap: 14px; margin: 26px auto 0; max-width: 850px; }
.aq-btn {
  min-height: 46px;
  padding: 10px 20px;
  border: 1px solid var(--aq-accent);
  border-radius: 2px;
  background: var(--aq-accent);
  color: white;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.aq-btn:hover:not(:disabled) { background: #6d262b; }
.aq-btn.secondary { background: transparent; color: var(--aq-accent); }
.aq-btn.secondary:hover { background: #f2eae7; }
.aq-btn:disabled { opacity: .45; cursor: default; }
.aq [hidden] { display: none !important; }

.aq-footer {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 24px 0 40px;
  border-top: 1px solid var(--aq-border);
  color: var(--aq-muted);
  font-size: 12px;
  line-height: 1.6;
}
.aq-footer a { color: inherit; }
.host-artquiz .site-footer { border-top: 1px solid var(--aq-border); }
.host-artquiz .site-footer a { color: var(--aq-accent) !important; }

.aq-lightbox { position: fixed; inset: 0; z-index: 9999; display: grid; place-items: center; padding: 20px; }
.aq-lightbox-backdrop { position: absolute; inset: 0; background: rgba(25, 22, 20, .63); }
.aq-lightbox-panel {
  position: relative;
  width: min(100%, 710px);
  max-height: 90dvh;
  overflow: auto;
  padding: clamp(20px, 3vw, 38px);
  border: 1px solid var(--aq-border);
  background: var(--aq-surface);
  box-shadow: 0 16px 50px rgba(24, 22, 19, .18);
}
.aq-game-mode-label { color: var(--aq-muted); font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; }
.aq-setting-copy p { margin: 7px 0 0; color: var(--aq-muted); font-size: 12px; }
.aq-lightbox-close {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border: 1px solid var(--aq-border);
  background: var(--aq-surface);
  color: var(--aq-text);
  font-size: 25px;
  cursor: pointer;
}
.aq-lightbox-close:hover { color: var(--aq-accent); border-color: var(--aq-accent); }
.aq-controls { margin-top: 26px; }
.aq-setting-row { display: grid; grid-template-columns: minmax(120px, 1fr) 2fr; gap: 20px; align-items: center; padding: 18px 0; border-top: 1px solid var(--aq-border); }
.aq-modes { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.aq-mode {
  min-height: 44px;
  padding: 9px 13px;
  border: 1px solid var(--aq-border);
  border-radius: 2px;
  background: var(--aq-surface);
  color: var(--aq-text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.aq-mode:hover { border-color: var(--aq-accent); }
.aq-mode.is-active, .aq-modes.aq-algo .aq-mode.is-active { border-color: var(--aq-accent); background: var(--aq-accent); color: white; }
.aq-order-mode { display: flex; flex-direction: column; align-items: flex-start; text-align: left; }
.aq-mode-sub { margin-top: 3px; font-size: 11px; opacity: .75; }

.aq-lightbox[hidden] { display: none; }
.aq-lightbox-panel { width: min(100%, 1000px); padding: 24px; }
.aq-lightbox-close { position: absolute; right: 10px; top: 10px; z-index: 1; }
.aq-lightbox-panel img { display: block; width: 100%; max-height: 75dvh; object-fit: contain; }
.aq-lightbox-caption { padding-top: 12px; color: var(--aq-muted); font-size: 13px; white-space: pre-wrap; }

.aq :is(button, a, .aq-target-img, .aq-profile-img, .aq-explain-thumb):focus-visible {
  outline: 2px solid var(--aq-accent);
  outline-offset: 3px;
}

@media (max-width: 850px) {
  .aq-header { flex-wrap: wrap; gap: 12px 24px; }
  .aq-title { width: 100%; }
  .aq-scoreboard { margin-right: auto; }
  .aq-option.is-artwork img { max-height: 38vw; }
  .aq-explore-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 600px) {
  .host-artquiz .aq { padding: calc(22px + env(safe-area-inset-top)) 16px calc(125px + env(safe-area-inset-bottom)); }
  .aq-quick-row { width: 100%; }
  .aq-quick-controls .aq-modes { gap: 4px; }
  .aq-quick-controls .aq-mode { font-size: 12px; padding: 8px 9px; }
  .aq-explore-grid { gap: 16px 8px; }
  .aq-explore-item { padding: 4px; }
  .aq-explore-item img { height: 37vw; }
  .aq-header { padding-bottom: 18px; }
  .aq-title p { margin-top: 5px; }
  .aq-scoreboard { gap: 18px; }
  .aq-stat { gap: 4px; }
  .aq-stat-label { font-size: 11px; }
  .aq-strike-dots { font-size: 15px; letter-spacing: 0; }
  .aq-card { padding-top: 34px; }
  .aq-question-meta { font-size: 10px; line-height: 1.5; }
  .aq-target { margin-top: 28px; }
  .aq-target-img img { max-height: 58vh; }
  .aq-grid { margin-top: 26px; }
  .aq-grid.is-artwork-grid { gap: 18px 10px; }
  .aq-option.is-artwork { padding: 6px; }
  .aq-option.is-artwork img { max-height: 46vw; }
  .aq-option.is-artwork .aq-option-title { font-size: 14px; }
  .aq-option.is-label { min-height: 56px; padding: 8px 12px; }
  .aq-option-title { font-size: 15px; }
  .aq-profile { gap: 14px; }
  .aq-profile-img { width: 60px; height: 60px; flex-basis: 60px; }
  .aq-footer { flex-direction: column; gap: 4px; }
  .aq-setting-row { grid-template-columns: 1fr; gap: 10px; }
  .aq-modes { justify-content: flex-start; }
  .aq-install-sheet { align-items: end; padding: 10px 10px max(10px, env(safe-area-inset-bottom)); }
  .aq-install-panel { padding: 24px; max-height: 90dvh; overflow: auto; }
  .aq-lightbox-panel { padding: 55px 12px 14px; }
}

@media (max-width: 380px) {
  .aq-header { gap: 6px 10px; }
  .aq-scoreboard { gap: 10px; }
  .aq-stat-label { font-size: 10px; }
  .aq-stat-value { font-size: 12px; }
}
