/* Auction-house look: deep wine background, gold accents, serif headings.
   No external fonts, so it also works offline on a laptop. */
:root {
  --bg: #1d0a10;
  --bg-2: #2b1018;
  --panel: #361620;
  --panel-2: #44202b;
  --line: #5a2c38;
  --text: #fbf1e1;
  --muted: #c7aab0;
  --gold: #d9a93f;
  --gold-2: #f3cf72;
  --ink: #2a1500;
  --red: #c8102e;
  --ok: #4cc38a;
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, 'Times New Roman', serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-family: var(--sans);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; color: var(--text); }
body {
  background: radial-gradient(ellipse at 30% 0%, var(--bg-2) 0%, var(--bg) 60%) fixed, var(--bg);
  -webkit-tap-highlight-color: transparent;
}
h1, h2 { font-family: var(--serif); font-weight: 700; letter-spacing: .01em; }
button { font: inherit; cursor: pointer; border: 0; border-radius: 12px; touch-action: manipulation; }
button:disabled { opacity: .35; cursor: default; }
input { font: inherit; padding: 14px; border-radius: 12px; border: 2px solid var(--line); width: 100%;
  background: var(--bg); color: var(--text); }
input:focus { outline: none; border-color: var(--gold); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

.banner { display: none; position: fixed; top: 0; left: 0; right: 0; padding: 8px; text-align: center;
  background: var(--red); color: white; z-index: 20; font-weight: 600; }
body.offline .banner.offline-msg { display: block; }
body.unauthorized .banner.auth-msg { display: block; }
body.unauthorized .banner.offline-msg { display: none; }

.primary { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: var(--ink); font-weight: 800;
  padding: 14px 22px; width: 100%; margin-top: 12px; box-shadow: 0 3px 0 #8a6416; }
.primary:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 #8a6416; }

/* ---------- Bidder phone ---------- */
.phone { max-width: 480px; margin: 0 auto; padding: 28px 16px 40px; min-height: 100vh; display: flex; flex-direction: column; }
.phone h1 { font-size: 1.7rem; margin: 8px 0 16px; }
.phone label { display: block; margin: 16px 0 6px; color: var(--muted); }
.phone .hello { margin: 0; }
.phone .lot-line { text-align: center; color: var(--gold); font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; font-size: .95rem; margin-top: 12px; }
.phone .price { font-family: var(--serif); font-size: 3rem; font-weight: 700; text-align: center; margin: 4px 0;
  font-variant-numeric: tabular-nums; }
.phone .last { text-align: center; min-height: 1.4em; }
.phone-status { text-align: center; font-size: 1.15rem; margin-top: 6px; color: var(--gold-2); font-weight: 600; }
.steps { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 20px; }
.steps button { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: var(--ink);
  font-size: 1.7rem; font-weight: 900; padding: 22px 0; box-shadow: 0 4px 0 #8a6416; transition: opacity .15s; }
.steps button:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #8a6416; }
.steps button:disabled { opacity: .3; box-shadow: none; }
.cooldown { height: 8px; border-radius: 4px; background: var(--panel); margin-top: 18px; overflow: hidden; }
.cooldown div { height: 100%; width: 0; background: var(--gold); }
.feedback { text-align: center; min-height: 1.4em; margin-top: 12px; font-weight: 600; }
.phone .rules { margin-top: auto; padding-top: 24px; font-size: .9rem; }

/* ---------- Main display (laptop / TV) ---------- */
.display { padding: 3vh 3vw; min-height: 100vh; }
.display h1 { font-size: clamp(2.4rem, 4vw, 4rem); margin: 0 0 8px; color: var(--gold-2); }
.subtitle { font-size: 1.4rem; margin: 0 0 32px; }

.lobby { display: grid; grid-template-columns: auto 1fr; gap: 56px; align-items: start; }
.qr { background: white; padding: 16px; border-radius: 16px; width: min(34vw, 380px); box-shadow: 0 0 0 6px var(--gold); }
.qr img { width: 100%; display: block; }
.qr-caption { font-size: 1.3rem; text-align: center; margin-top: 18px; }
.lobby h2 { font-size: 2rem; margin: 0 0 16px; }
.players { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 12px; font-size: 1.7rem; }
.players li { background: var(--panel); padding: 10px 20px; border-radius: 999px; border: 1px solid var(--line); }
.players li::before { content: '●'; color: var(--ok); margin-right: 10px; }
.players li.away { opacity: .55; }
.players li.away::before { color: var(--muted); }
.lobby-rules { margin: 32px 0 0; padding: 0; list-style: none; font-size: 1.3rem; display: grid; gap: 8px; }
.lobby-rules li::before { content: '✦'; color: var(--gold); margin-right: 12px; }
.hammer-box { display: flex; gap: 16px; align-items: center; margin-top: 32px; }
.hammer-box .qr { width: 120px; padding: 6px; box-shadow: none; }
.start { width: auto; margin-top: 32px; font-size: 1.4rem; }

/* Lot */
.lot { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) 270px; gap: 3vw; align-items: center;
  min-height: calc(100vh - 6vh); }
.lot-art { position: relative; display: flex; justify-content: center; }
.frame { position: relative; padding: 14px; background: linear-gradient(135deg, #8a6416, var(--gold-2) 40%, #8a6416);
  border-radius: 4px; box-shadow: 0 10px 28px rgba(0,0,0,.45); max-width: 100%; }
.frame img { display: block; max-width: 100%; max-height: 74vh; object-fit: contain; background: var(--bg);
  outline: 6px solid #1a0c06; }
.letter { position: absolute; top: -28px; left: -28px; width: 120px; height: 120px; border-radius: 50%;
  background: var(--red); color: white; font-family: var(--serif); font-size: 5rem; font-weight: 700;
  display: grid; place-items: center; border: 5px solid var(--gold-2); box-shadow: 0 8px 24px rgba(0,0,0,.5); z-index: 2; }
.countdown { position: absolute; inset: 14px; display: grid; place-items: center; pointer-events: none;
  background: rgba(20, 4, 8, .55); font-family: var(--serif); font-size: min(32vh, 22vw); font-weight: 700;
  color: white; text-shadow: 0 0 40px var(--red), 0 0 12px var(--red); }
.countdown.tick { animation: tick 1s ease-out; }
@keyframes tick { from { transform: scale(1.25); opacity: .4; } to { transform: scale(1); opacity: 1; } }

.lot-number { font-size: 1.4rem; color: var(--gold); font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.art-title { font-family: var(--serif); font-size: clamp(2rem, 3vw, 3.2rem); font-weight: 700; margin-top: 8px; line-height: 1.1; }
.art-artist { font-size: 1.6rem; margin-top: 6px; }
.price-row { display: flex; align-items: flex-start; gap: 6px; margin-top: 5vh; }
.lot-price { font-family: var(--serif); font-size: clamp(4rem, 6.5vw, 7.5rem); font-weight: 700; line-height: 1;
  font-variant-numeric: tabular-nums; color: var(--gold-2); }
.lot-price.bump { animation: bump .5s ease-out; }
@keyframes bump { 0% { transform: scale(1.08); color: white; } 100% { transform: scale(1); } }
.edit-btn { background: transparent; color: var(--muted); font-size: .9rem; opacity: .35; padding: 2px 4px; }
.edit-btn:hover { opacity: 1; }
.edit-form { display: flex; gap: 8px; margin-top: 12px; }
.edit-form input { width: 240px; font-size: 1.4rem; }
.edit-form .primary { width: auto; margin: 0; }
.edit-form button[type=button] { padding: 0 16px; background: var(--panel); color: var(--text); }
.lot-last { font-size: 2.2rem; margin-top: 14px; min-height: 1.3em; }
.lot-last .bid-amount { color: var(--gold); font-weight: 700; margin-right: 10px; }
.lot-status { font-size: 1.4rem; min-height: 1.3em; margin-top: 4px; }
.lot-actions { margin-top: 5vh; display: flex; gap: 12px; align-items: center; }
.sold-btn { background: transparent; border: 1px solid var(--line); color: var(--muted); padding: 6px 14px; font-size: .9rem; }
.next-btn { width: auto; font-size: 1.4rem; margin: 0; }
.sold-banner { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-6deg); background: var(--red);
  color: white; padding: 24px 64px; border-radius: 12px; text-align: center; font-size: 2.4rem; pointer-events: none;
  border: 6px solid var(--gold-2); box-shadow: 0 20px 60px rgba(0,0,0,.6); animation: stamp .35s cubic-bezier(.2,1.6,.4,1); z-index: 5; }
@keyframes stamp { from { transform: translate(-50%, -50%) rotate(-6deg) scale(2.2); opacity: 0; } }
.sold-word { font-family: var(--serif); font-size: 7rem; font-weight: 700; letter-spacing: .06em; line-height: 1; }

/* Price ladder */
.ladder-box { align-self: stretch; display: flex; flex-direction: column; padding: 8px 0; }
.ladder-title { font-size: .95rem; text-transform: uppercase; letter-spacing: .15em; margin-bottom: 10px; color: var(--gold); }
.ladder { position: relative; flex: 1; min-height: 400px; }
.ladder-row, .ladder-marker { position: absolute; left: 0; right: 0; display: flex; align-items: center; gap: 10px;
  transition: top .35s ease; }
.ladder-row { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding-right: 12px; overflow: hidden; }
.ladder-row img { height: 100%; aspect-ratio: 1; object-fit: cover; }
.ladder-row.current { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }
.ladder-letter { font-family: var(--serif); font-weight: 700; font-size: 1.3rem; color: var(--gold-2); width: 1.2em; }
.ladder-price { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 1.1rem; }
.ladder-marker { justify-content: center; border: 2px dashed var(--gold-2); border-radius: 8px; color: var(--gold-2);
  font-weight: 800; font-size: 1.25rem; background: rgba(217,169,63,.1); }
.ladder-empty { font-size: 1.05rem; }

/* Hidden controls */
.corner { position: fixed; bottom: 12px; right: 12px; display: flex; gap: 8px; align-items: center; z-index: 6; }
.corner .menu-btn { background: transparent; color: var(--muted); font-size: 1.4rem; padding: 6px 10px; opacity: .4; }
.menu { position: fixed; bottom: 56px; right: 12px; background: var(--panel); border: 1px solid var(--line); padding: 12px;
  border-radius: 12px; display: flex; flex-direction: column; gap: 8px; z-index: 6; }
.menu button { background: var(--bg); color: var(--text); padding: 10px 16px; text-align: left; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--panel-2);
  border: 1px solid var(--line); padding: 12px 20px; border-radius: 12px; font-size: 1.2rem; z-index: 7; }

/* Results */
.results-sub { font-size: 1.3rem; margin: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(78px, 1fr)); gap: 8px; margin: 28px 0 20px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px; text-align: center;
  border-bottom: 6px solid var(--line); transition: background .3s, border-color .3s; }
.tile img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; }
.tile-letter { font-family: var(--serif); font-size: 3rem; font-weight: 700; line-height: 1.15; }
.tile-price { font-size: .95rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.tile-move { min-height: 28px; display: flex; justify-content: center; gap: 4px; margin-top: 4px; }
.tile-move button { background: var(--bg); color: var(--text); padding: 2px 8px; }
.tile.in-order { border-bottom-color: var(--ok); }
.tile.exact { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: var(--ink); }
.tile.exact .tile-price { color: #5a3a00; }
.hint-legend { font-size: 1.4rem; display: flex; flex-direction: column; gap: 8px; min-height: 2em; }
.hint-legend .key { padding: 0 6px; border-radius: 4px; }
.hint-legend .key.in-order { border-bottom: 4px solid var(--ok); }
.hint-legend .key.exact { background: var(--gold); color: var(--ink); }
.slots { font-family: ui-monospace, monospace; letter-spacing: .1em; margin-right: 1.5em; }
.results-controls { display: flex; gap: 16px; align-items: center; margin-top: 24px; flex-wrap: wrap; }
.results-controls .primary { width: auto; margin: 0; }
.guess-form { display: flex; gap: 8px; }
.guess-form input { width: 380px; text-transform: uppercase; }
.reveal-btn { margin-left: auto; background: transparent; border: 1px solid var(--line); color: var(--muted); padding: 8px 14px; }
.guesses { list-style: none; padding: 0; font-size: 1.4rem; font-family: ui-monospace, monospace; }
.guesses .right { color: var(--ok); font-weight: 800; font-size: 2rem; }
.guesses .wrong { color: var(--muted); }

/* Reveal */
.phrase { font-family: var(--serif); font-size: clamp(3rem, 6vw, 6rem); letter-spacing: .12em; color: var(--gold-2);
  text-align: center; margin: 8px 0 24px; animation: stamp .6s ease-out; }
.reveal-table { width: 100%; border-collapse: collapse; font-size: 1.2rem; }
.reveal-table th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 10px; }
.reveal-table th:nth-child(n+4) { text-align: right; }
.reveal-table td { padding: 4px 10px; border-top: 1px solid var(--line); }
.reveal-table img { width: 48px; height: 48px; object-fit: cover; border-radius: 4px; display: block; }
.reveal-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.reveal-table .rv-letter { font-family: var(--serif); font-weight: 700; font-size: 1.8rem; color: var(--gold-2); }
.reveal-table tr.right td:last-child { color: var(--ok); font-weight: 700; }

/* ---------- Hammer phone ---------- */
.hammer { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 24px; padding: 16px; text-align: center; }
.hammer h1 { font-size: 2rem; margin: 0; color: var(--gold-2); }
.hammer #status { font-size: 1.2rem; min-height: 3em; }
.hammer-btn { width: min(78vw, 340px); aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff4d63, var(--red) 55%, #7a0018); color: white;
  font-family: var(--serif); font-size: 2.4rem; font-weight: 700; border: 8px solid var(--gold-2);
  box-shadow: 0 10px 0 #5a0010, 0 20px 40px rgba(0,0,0,.5); }
.hammer-btn:active:not(:disabled) { transform: translateY(8px); box-shadow: 0 2px 0 #5a0010; }
.hammer-btn:disabled { opacity: .3; }
.hammer .big { width: min(78vw, 340px); font-size: 1.6rem; padding: 22px; }

/* ---------- Phone setup: who are you, name, photo ---------- */
.ask-q { font-family: var(--serif); font-size: 2.4rem; text-align: center; margin: 40px 0 24px; color: var(--gold-2); }
.ask-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.ask-buttons .primary { font-size: 2rem; padding: 28px 0; margin: 0; }
.primary.alt { background: var(--panel-2); color: var(--text); box-shadow: 0 3px 0 #1a070c; }
.link-btn { background: none; color: var(--muted); text-decoration: underline; margin: 16px auto 0; display: block; padding: 8px; }
.camera { position: relative; width: min(100%, 360px); aspect-ratio: 1; margin: 16px auto; border-radius: 16px;
  overflow: hidden; background: #000; }
.camera video, .camera canvas { width: 100%; height: 100%; object-fit: cover; display: block; }
.camera video { transform: scaleX(-1); }
.face-frame { position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 34% 44% at 50% 47%, transparent 98%, rgba(29,10,16,.65) 100%); }
.face-frame::after { content: ''; position: absolute; left: 16%; right: 16%; top: 3%; bottom: 9%;
  border: 4px dashed var(--gold-2); border-radius: 50%; }
.photo-buttons { display: grid; gap: 10px; }
.photo-buttons .primary { margin: 0; }
.file-btn { display: block; text-align: center; cursor: pointer; }
.file-btn input { display: none; }
.me-row { display: flex; align-items: center; gap: 12px; }

/* ---------- Faces on the main display ---------- */
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--panel-2); color: var(--gold-2);
  display: inline-grid; place-items: center; font-family: var(--serif); font-weight: 700; overflow: hidden;
  border: 2px solid var(--gold); flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.big { width: 120px; height: 120px; font-size: 3.5rem; border-width: 4px; }
.players li { display: inline-flex; align-items: center; gap: 10px; padding: 6px 20px 6px 6px; }
.players li::before { display: none; }
.players li.away { opacity: .45; }
.dim-box { display: flex; gap: 16px; align-items: center; margin-top: 32px; font-size: 1.3rem; }
.dim-box .avatar { width: 72px; height: 72px; font-size: 2rem; }
.bid-pop { display: flex; align-items: center; gap: 16px; font-size: 2rem; font-weight: 700; margin-top: 12px; }
.bid-pop.show { animation: pop .3s cubic-bezier(.2,1.6,.4,1); }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }
.next-hint { font-size: 1.2rem; }
