/* /puzzle styles — lobby + play + win modal.
   Keeping it self-contained so the page works even when a layout
   wrapper isn't loaded.
   Co-Authored-By: Claude Opus 4.7 (1M context) <81847+claude@users.noreply.github.com>
   Co-Authored-By: Cursor <126759922+cursor@users.noreply.github.com>
   Co-Authored-By: MarkSoftAI <thomas@marksoft.ro> */

* { box-sizing: border-box; }

.puzzle-body {
  margin: 0;
  font: 14px/1.5 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: #e8edf5;
  background: radial-gradient(1200px 800px at 30% -10%, #1a2240 0%, #0a0f1f 60%) #07091a;
  min-height: 100vh;
}
a { color: #8aa6ff; text-decoration: none; }
a:hover { text-decoration: underline; }

.puzzle-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 22px 80px;
}

.puzzle-hero { text-align: center; padding: 8px 0 30px; position: relative; }
.puzzle-hero .back {
  position: absolute; left: 0; top: 8px;
  font-size: 13px; opacity: .8;
}
.puzzle-hero h1 {
  font-size: 38px; margin: 6px 0 6px;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #ffd45c, #ffb86b);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.puzzle-hero .tag { color: #97a3b8; margin: 0; }

.card {
  background: linear-gradient(180deg, rgba(20,26,44,.85), rgba(14,18,32,.85));
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 14px;
  padding: 22px 22px;
  margin-bottom: 20px;
  box-shadow: 0 12px 40px rgba(0,0,0,.35);
}
.card h2 { font-size: 18px; margin: 0 0 14px; letter-spacing: -0.01em; }

/* DISCLAIMER */
.disclaimer-card {
  background: linear-gradient(180deg, rgba(255,184,107,.10), rgba(255,184,107,.04));
  border: 1px solid rgba(255,184,107,.35);
  border-radius: 14px;
  padding: 20px 22px;
  margin-bottom: 20px;
}
.disclaimer-card h2 { margin: 0 0 8px; font-size: 17px; color: #ffd9a8; }
.disclaimer-card p  { margin: 0 0 10px; color: #d6dceb; }
.disclaimer-card ul { margin: 0 0 12px 18px; color: #c4cce0; }
.disclaimer-card .check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.disclaimer-card .check input { transform: scale(1.2); accent-color: #ffd45c; }

/* CREATE FORM */
.create-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 720px) { .create-grid { grid-template-columns: 1fr; } }

.upload-drop {
  display: flex; align-items: center; justify-content: center;
  position: relative;
  height: 240px;
  background: rgba(255,255,255,.03);
  border: 2px dashed rgba(255,255,255,.18);
  border-radius: 12px;
  cursor: pointer;
  overflow: hidden;
  transition: border-color .15s, background .15s;
}
.upload-drop:hover { border-color: rgba(255,184,107,.55); background: rgba(255,184,107,.05); }
.upload-drop.drag  { border-color: #ffd45c; background: rgba(255,212,92,.10); }
.upload-prompt { text-align: center; color: #c4cce0; }
.upload-icon { font-size: 30px; margin-bottom: 6px; }
.upload-sub { color: #8a92a8; font-size: 12px; margin-top: 4px; }
.upload-drop img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; display: none;
}
.upload-status { font-size: 12px; color: #97a3b8; margin-top: 8px; min-height: 18px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 12px; color: #97a3b8; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.field input[type=text] {
  background: #0a0d18; border: 1px solid rgba(255,255,255,.12);
  color: #eaeef5; border-radius: 8px; padding: 9px 12px; font: 13px 'Inter', system-ui;
}
.field.check-field { flex-direction: row; align-items: center; gap: 10px; }
.field.check-field span { text-transform: none; letter-spacing: 0; font-weight: normal; color: #c4cce0; }

.diff-row { display: flex; flex-wrap: wrap; gap: 6px; }
.diff-btn {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.12);
  color: #c4cce0; padding: 7px 12px; border-radius: 8px;
  font: 600 12px 'Inter'; cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.diff-btn:hover { border-color: rgba(255,212,92,.45); color: #ffd9a8; }
.diff-btn[data-active="1"] {
  background: rgba(255,212,92,.16);
  border-color: rgba(255,212,92,.6);
  color: #ffd45c;
}

.custom-row { display: flex; align-items: center; gap: 8px; }
.custom-row input[type=number] {
  width: 70px; background: #0a0d18;
  border: 1px solid rgba(255,255,255,.12);
  color: #eaeef5; border-radius: 8px;
  padding: 8px 10px; font: 700 13px ui-monospace, monospace;
  text-align: center;
}
.custom-row .x { color: #97a3b8; font-weight: 700; }
.custom-total { color: #ffd45c; font: 700 12px 'Inter'; margin-left: 4px; }

button.primary, .primary {
  background: linear-gradient(180deg, #ffd45c 0%, #ffb86b 100%);
  border: 0; color: #1a1408; padding: 11px 20px; border-radius: 10px;
  font: 800 14px 'Inter'; cursor: pointer;
  transition: transform .1s, box-shadow .15s;
  letter-spacing: -0.01em;
}
button.primary:hover, .primary:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(255,184,107,.35); }
button.primary:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

button.ghost, .ghost {
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.16);
  color: #eaeef5; padding: 8px 14px; border-radius: 8px;
  font: 600 12.5px 'Inter'; cursor: pointer;
  text-decoration: none;
}
button.ghost:hover, .ghost:hover { background: rgba(255,255,255,.10); }

.create-error { color: #ff9090; font-size: 12px; margin-top: 8px; min-height: 16px; }
.auth-hint { color: #c4cce0; }

/* JOIN BY CODE */
.join-row { display: flex; gap: 8px; }
.join-row input {
  flex: 0 0 140px;
  background: #0a0d18; border: 1px solid rgba(255,255,255,.12);
  color: #ffd45c; border-radius: 10px;
  padding: 12px 14px; font: 800 22px ui-monospace, monospace;
  text-align: center; letter-spacing: .25em;
}
.join-row input:focus { outline: none; border-color: rgba(255,212,92,.55); }
.join-hint { font-size: 12px; color: #8a92a8; margin-top: 8px; }

/* IMAGE LIBRARY */
.library-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.library-head h2 { margin: 0; }
.library-tabs { display: flex; gap: 6px; }
.lib-tab {
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.12);
  color: #97a3b8; padding: 6px 12px; border-radius: 7px;
  font: 600 11.5px 'Inter'; cursor: pointer;
}
.lib-tab.active { background: rgba(255,212,92,.16); border-color: rgba(255,212,92,.6); color: #ffd45c; }
.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.lib-card {
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 12px;
  overflow: hidden;
  display: flex; flex-direction: column;
}
.lib-thumb {
  height: 130px;
  position: relative;
  background-size: cover; background-position: center;
  background-color: #0a0d18;
}
.lib-del {
  position: absolute; top: 6px; right: 6px;
  width: 28px; height: 28px;
  background: rgba(0,0,0,.55);
  border: 1px solid rgba(255,90,90,.45);
  color: #ff9a9a; border-radius: 6px;
  cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  opacity: .85; transition: opacity .12s, background .12s;
}
.lib-del:hover { opacity: 1; background: rgba(255,60,60,.30); }
.lib-meta { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 5px; }
.lib-title { font-size: 13.5px; font-weight: 700; }
.lib-by    { font-size: 11px; color: #8a92a8; }
.lib-stats { display: flex; gap: 10px; font-size: 11px; color: #97a3b8; flex-wrap: wrap; margin-top: 2px; }
.lib-actions { display: flex; gap: 5px; margin-top: 6px; }
.lib-actions .ghost { padding: 5px 9px; font-size: 11.5px; flex: 1; text-align: center; }

.empty { color: #8a92a8; padding: 16px; text-align: center; }

/* RECENT RECORDS */
.records-list { display: flex; flex-direction: column; gap: 10px; }
.record-row {
  display: flex; gap: 12px; align-items: center;
  padding: 10px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 10px;
}
.rec-thumb { width: 64px; height: 48px; border-radius: 6px; background-size: cover; background-position: center; background-color: #0a0d18; flex: 0 0 64px; }
.rec-info { display: flex; flex-direction: column; gap: 2px; }
.rec-time { font-weight: 800; color: #ffd45c; }
.rec-meta { font-size: 11.5px; color: #8a92a8; }

/* ────────────────── PLAY PAGE ────────────────── */
.puzzle-play-body { overflow: hidden; }
.play-shell { display: flex; flex-direction: column; height: 100vh; }
.play-head {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 18px;
  background: rgba(0,0,0,.35);
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.play-head .back { font-size: 13px; }
.code-pill {
  background: rgba(255,212,92,.12);
  border: 1px solid rgba(255,212,92,.45);
  color: #ffd45c; padding: 5px 12px; border-radius: 999px;
  font: 700 13px 'Inter';
}
.code-pill #codeBig { font: 800 16px ui-monospace, monospace; letter-spacing: .15em; }
.timer {
  font: 800 22px ui-monospace, monospace;
  color: #eaeef5; flex: 1; text-align: center;
}
.head-actions { display: flex; gap: 8px; align-items: center; }

.play-main {
  flex: 1; display: flex; min-height: 0;
}
.players-panel {
  width: 280px; flex: 0 0 280px;
  background: rgba(0,0,0,.30);
  border-right: 1px solid rgba(255,255,255,.07);
  padding: 14px 14px 16px;
  overflow-y: auto;
}
.players-panel h3 {
  font-size: 12px; color: #97a3b8;
  text-transform: uppercase; letter-spacing: .08em;
  margin: 0 0 10px; font-weight: 700;
}
.players-list { display: flex; flex-direction: column; gap: 10px; }
.pl-row {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 9px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 9px;
}
.pl-row.me { border-color: rgba(95,205,120,.45); background: rgba(95,205,120,.06); }
.pl-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,.10);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #c4cce0; flex: 0 0 36px;
  overflow: hidden;
}
.pl-avatar img { width: 100%; height: 100%; object-fit: cover; }
.pl-info { flex: 1; min-width: 0; }
.pl-name { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.self-tag { color: #5fcd78; font-weight: 600; font-size: 11px; }
.pl-bar {
  height: 6px; background: rgba(255,255,255,.08);
  border-radius: 3px; margin-top: 5px; overflow: hidden;
}
.pl-bar-fill {
  height: 100%; background: linear-gradient(90deg, #ffd45c, #ffb86b);
  transition: width .25s;
}
.pl-stats { font-size: 11px; color: #97a3b8; margin-top: 4px; }

.legend { margin-top: 20px; font-size: 11px; color: #6b7691; line-height: 1.6; }

.canvas-wrap {
  flex: 1; position: relative; min-width: 0;
  background: #0c1120;
  overflow: hidden;
}
#puzzleCanvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
#puzzleCanvas:active { cursor: grabbing; }

.canvas-toast {
  position: absolute; left: 50%; top: 22px; transform: translateX(-50%) translateY(-8px);
  background: rgba(20,26,44,.92);
  border: 1px solid rgba(255,212,92,.45);
  color: #ffd45c; padding: 8px 16px; border-radius: 999px;
  font: 700 13px 'Inter';
  opacity: 0; pointer-events: none;
  transition: opacity .15s, transform .15s;
}
.canvas-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.canvas-controls {
  position: absolute; right: 14px; bottom: 36px;
  display: flex; flex-direction: column; gap: 6px;
}
.canvas-controls .ghost {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  font: 700 18px 'Inter'; padding: 0;
  background: rgba(20,26,44,.85);
}
.canvas-hint {
  position: absolute; left: 14px; bottom: 12px;
  font-size: 11px; color: #6b7691;
  background: rgba(0,0,0,.30); padding: 4px 9px; border-radius: 5px;
  pointer-events: none;
}

/* WIN MODAL */
.win-modal {
  position: fixed; inset: 0;
  background: rgba(5,8,18,.78);
  backdrop-filter: blur(6px);
  z-index: 50;
  display: flex; align-items: center; justify-content: center;
}
.win-modal[hidden] { display: none; }
.win-card {
  background: linear-gradient(180deg, rgba(28,34,56,.96), rgba(16,20,36,.96));
  border: 1px solid rgba(255,212,92,.45);
  padding: 36px 40px; border-radius: 16px;
  text-align: center; max-width: 420px;
  box-shadow: 0 20px 80px rgba(0,0,0,.7);
}
.win-card h2 { margin: 0 0 8px; font-size: 26px; color: #ffd45c; }
.win-time {
  font: 900 48px ui-monospace, monospace;
  color: #eaeef5; margin: 8px 0 4px; letter-spacing: -0.02em;
}
.win-grid { color: #97a3b8; font-size: 13px; margin-bottom: 22px; }
.win-actions { display: flex; gap: 10px; justify-content: center; }
