/* Jeweler's Companion web shell. Walnut and gold on paper. No external resources. */
:root {
  --walnut: #2B2118;
  --gold: #8A6A1C;
  --gold-light: #D4A73A;
  --paper: #FBF6EC;
  --ink: #2B2118;
  --ad-h: 62px;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  overflow: hidden;
}
a { color: var(--gold); }

#stage { position: fixed; inset: 0; display: flex; flex-direction: column; }
#app { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; background: var(--paper); }
#app canvas { display: block; }

/* Loading / messages */
#loading, #unsupported, #failed, #nojs {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; padding: 24px; gap: 8px;
}
#unsupported, #failed, #nojs { background: var(--paper); }
#unsupported[hidden], #failed[hidden], #loading[hidden] { display: none; }
#unsupported h1, #failed h1 { font-size: 1.4rem; margin: 0; color: var(--walnut); }
#unsupported p, #failed p, #nojs p { max-width: 32em; margin: 4px 0; }
#loading p { margin: 0; color: var(--gold); font-weight: 600; }
.spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 4px solid #e6dcc6; border-top-color: var(--gold-light);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* Ad bar */
#ad {
  flex: 0 0 auto; display: flex; align-items: center; gap: 10px;
  min-height: var(--ad-h);
  padding: 6px 12px calc(6px + env(safe-area-inset-bottom)) 12px;
  padding-left: calc(12px + env(safe-area-inset-left)); padding-right: calc(12px + env(safe-area-inset-right));
  background: var(--walnut); color: var(--paper);
  border-top: 2px solid var(--gold-light);
}
#ad-slot { flex: 1 1 auto; min-width: 0; display: none; height: 50px; overflow: hidden; }
#ad.adsense #ad-slot { display: block; }
#ad.adsense #ad-house { display: none; }
#ad-house { flex: 1 1 auto; min-width: 0; font-size: 0.85rem; line-height: 1.3; }
#ad-house p { margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
#ad-house strong { color: var(--gold-light); }
#ad-actions { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
#ad-actions a { color: var(--gold-light); font-size: 0.75rem; }
#remove-ads {
  font: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer;
  background: var(--gold-light); color: var(--walnut);
  border: 0; border-radius: 6px; padding: 8px 12px; min-height: 36px;
}
#remove-ads:hover { background: #e3b94c; }
:focus-visible { outline: 3px solid var(--gold-light); outline-offset: 2px; }

/* No-ads mode */
.noads #ad { display: none; }

/* Dialog */
dialog {
  border: 2px solid var(--gold); border-radius: 12px; padding: 20px;
  background: var(--paper); color: var(--ink); width: min(92vw, 380px);
}
dialog::backdrop { background: rgba(43, 33, 24, 0.6); }
dialog h2 { margin: 0 0 8px; color: var(--walnut); font-size: 1.25rem; }
dialog p { margin: 0 0 12px; }
dialog label { display: block; font-weight: 600; margin-bottom: 4px; }
dialog input {
  width: 100%; font: inherit; font-size: 1.1rem; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 10px; border: 2px solid var(--gold); border-radius: 8px; background: #fff; color: var(--ink);
}
#redeem-error { color: #9b1c1c; font-weight: 600; margin-top: 10px; }
#redeem-error[hidden] { display: none; }
dialog .row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
dialog button {
  font: inherit; font-weight: 600; cursor: pointer; min-height: 40px; padding: 8px 16px;
  border-radius: 8px; border: 2px solid var(--walnut); background: var(--walnut); color: var(--paper);
}
dialog button.secondary { background: transparent; color: var(--walnut); }
dialog button:disabled { opacity: 0.6; cursor: wait; }
dialog .fine { font-size: 0.8rem; margin: 12px 0 0; color: #5a4a36; }

#thanks {
  position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--walnut); color: var(--paper); border: 2px solid var(--gold-light);
  padding: 10px 18px; border-radius: 10px; font-weight: 600; z-index: 10; max-width: 92vw; text-align: center;
}
#thanks[hidden] { display: none; }

@media (max-width: 420px) {
  #ad-house { font-size: 0.78rem; }
  #remove-ads { padding: 8px 10px; }
}
