:root{
  --lime-cream: #cbe896;
  --ash-grey: #aac0aa;
  --soft-peach: #fcdfa6;
  --dusty-taupe: #a18276;
  --light-caramel: #f4b886;

  --ink: #2a2a2a;
  --bg: #fbf7ef;
  --sage: #7aa39b;
  --coral: #e26f5f;
  --saffron: #f2c14e;

  --text: var(--ink);

  --maxw: 720px;
  --radius: 18px;
  --cardRadius: 18px;
  --shadow: 0 12px 28px rgba(31,31,34,.14);
  --shadowSoft: 0 6px 16px rgba(31,31,34,.10);
}

@media (min-width: 900px){
  :root{ --maxw: 560px; }
}

*{ box-sizing:border-box; }
html,body{ height:100%; margin:0; overscroll-behavior: none; }
html{
  background:
    radial-gradient(900px 600px at 15% 0%, rgba(203,232,150,.35), transparent 55%),
    radial-gradient(800px 600px at 85% 15%, rgba(252,223,166,.45), transparent 60%),
    radial-gradient(900px 700px at 20% 100%, rgba(244,184,134,.35), transparent 60%),
    linear-gradient(160deg, rgba(170,192,170,.30), rgba(252,223,166,.20), rgba(203,232,150,.20)),
    var(--bg);
  min-height: 100%;
  background-attachment: fixed;
}
body{
  font-family: "Iowan Old Style", "Palatino", "Palatino Linotype", "Book Antiqua", Georgia, "Times New Roman", serif;
  color: var(--text);
  background: transparent;
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow: hidden; /* no page scrolling */
}

.app{
  height: 100dvh;
  width: min(var(--maxw), 100%);
  margin: 0 auto;
  padding: 6px;
  padding-top: calc(6px + env(safe-area-inset-top));
  display:flex;
  flex-direction:column;
  gap: 4px;
}

.top{
  flex: 0 0 auto;
  display:flex;
  flex-direction:row;
  align-items:center;
  justify-content:space-between;
  gap: 6px;
}

.gameTitle{
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: .02em;
}

#dayLabel{
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .02em;
  color: rgba(31,31,34,.6);
}

.titleRow{
  display:flex;
  align-items:center;
  gap: 10px;
  min-width: 0;
}

.titleLogo{
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex: 0 0 auto;
}

.modeMenu{
  position: relative;
}

.modeMenuToggle{
  list-style: none;
  cursor: pointer;
  border: 1px solid rgba(31,31,34,.18);
  background: rgba(255,255,255,.9);
  border-radius: 999px;
  padding: 6px 10px;
  font-weight: 800;
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
  -webkit-tap-highlight-color: transparent;
}

.modeMenuToggle::-webkit-details-marker{
  display: none;
}

.modeMenu[open] .modeMenuToggle{
  border-color: rgba(31,31,34,.32);
}

#modeBar{
  position: absolute;
  right: 0;
  margin-top: 6px;
  display:flex;
  flex-direction:column;
  gap: 8px;
  padding: 10px;
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(31,31,34,.12);
  border-radius: 14px;
  box-shadow: var(--shadowSoft);
  z-index: 8;
  min-width: 240px;
}

#modeBar{
  display:flex;
  justify-content:center;
  gap: 10px;
}

#modeBar button{
  appearance:none;
  border: 1px solid rgba(46,40,42,.18);
  background: rgba(255,255,255,.86);
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 800;
  font-size: 14px;
  font-family: "Iowan Old Style", "Palatino", "Palatino Linotype", "Book Antiqua", Georgia, "Times New Roman", serif;
  cursor:pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}
#modeBar button:active{ transform: translateY(1px); }
#modeBar button:disabled{ opacity:.45; cursor:not-allowed; }

#dailyBtn.is-completed{
  background: #1f8f3a;
  color: #fff;
  border-color: rgba(31,143,58,.55);
}

.board{
  flex: 1 1 auto;
  min-height: 0;              /* important for children sizing */
  display:flex;
  flex-direction:column;
  gap: 6px;
}

/* Timeline area takes remaining space */
#timelineWrap{
  flex: 1 1 auto;
  min-height: 0;
  background: rgba(252,223,166,.18);
  border: 1px solid rgba(161,130,118,.18);
  border-radius: 14px;
  box-shadow: 0 2px 10px rgba(46,40,42,.06);
  padding: 6px;
  position: relative;

  overflow: hidden;
}

#currentCardFloating{
  position: absolute;
  top: 6px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  z-index: 3;
  pointer-events: none;
}

#currentCardFloating .card{
  pointer-events: auto;
  width: min(520px, 100%);
  box-shadow: 0 8px 18px rgba(42,42,42,.10);
  padding: 6px 10px;
  grid-template-columns: 46px 1fr;
  align-items: center;
}

#currentCardFloating .card-img{
  width: 46px;
  height: 46px;
}

#currentCardFloating .description{
  font-size: 14px;
  line-height: 1.25;
  max-height: none;
  overflow: hidden;
}

.edge-label{
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: rgba(31,31,34,.35);
  pointer-events: none;
  z-index: 1;
}

.edge-label.edge-top{
  top: 8px;
}

.edge-label.edge-bottom{
  bottom: 8px;
}

#timelineWrap::before{
  content:"";
  position:absolute;
  top: 26px;
  bottom: 26px;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: rgba(255,255,255,.9);
  pointer-events:none;
  border-radius: 2px;

  z-index: 0; /* behind the cards */
}

/* Timeline: fixed height by flex container, internal scroll OFF */
#timeline{
  height: 100%;
  width: 100%;
  display:flex;
  flex-direction:column;

  /* IMPORTANT: keep centered behavior without jumping */
  justify-content: center;

  gap: var(--timeline-gap, 10px);
  padding: 6px 0 10px; /* tighter to free space */

  overflow-y: auto;
  overscroll-behavior: contain;

  align-items: center;

  /* so the line sits behind */
  position: relative;
  z-index: 1;
}

/* Progressive compression as more cards are placed */
#timeline .card{
  transition: padding 140ms ease;
}

#timeline[data-count="1"]{ --timeline-gap: 10px; }
#timeline[data-count="2"]{ --timeline-gap: 9px; }
#timeline[data-count="3"]{ --timeline-gap: 8px; }
#timeline[data-count="4"]{ --timeline-gap: 7px; }
#timeline[data-count="5"]{ --timeline-gap: 6px; }
#timeline[data-count="6"]{ --timeline-gap: 6px; --placed-pad-y: 12px; }
#timeline[data-count="7"]{ --timeline-gap: 4px; --placed-pad-y: 11px; }
#timeline[data-count="8"]{ --timeline-gap: 2px; --placed-pad-y: 10px; }

#timeline .card.placed{
  margin-top: 0;
}
/* Cards */
.card{
  position: relative; /* anchor for the year label */

  width: min(520px, 100%);
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(46,40,42,.10);
  border-radius: var(--cardRadius);
  box-shadow: 0 6px 14px rgba(42,42,42,.08);

  /* extra top padding to make room for the pill */
  padding: 12px 12px 4px;

  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 10px;
  align-items: center;

  --img-size: 46px;
  --card-pad: 12px;
}

.card.clue{
  border-color: rgba(46,40,42,.10);
  box-shadow: var(--shadowSoft);
}

.card.placed{
  padding: var(--placed-pad-y, 10px) 12px 4px;
}

/* image: show full image */
.card-img{
  width: 46px;
  height: 46px;
  border-radius: 10px;
  background: rgba(46,40,42,.06);
  object-fit: contain;
}

/* text */
.description{
  font-size: 13px;
  line-height: 1.25;
  padding-bottom: 2px;
}

/* Current card area removed */

@media (max-width: 480px){
  .app{ padding: 4px; gap: 4px; }
  .top{ gap: 4px; }
  .board{ gap: 5px; }
  #timelineWrap{ padding: 5px; border-radius: 12px; }
  .controls{ padding: 5px; border-radius: 12px; }
  #timeline{ padding: 6px 0 8px; }
  #dayLabel{ font-size: 13px; }
  .gameTitle{ font-size: 20px; }
}

/* Placed cards: keep tidy and avoid collisions */
.card.placed .description{
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  line-height: 1.2;
  padding-bottom: 0;
}

#timeline[data-count="6"] .card.placed .description,
#timeline[data-count="7"] .card.placed .description,
#timeline[data-count="8"] .card.placed .description{
  -webkit-line-clamp: 3;
}

.year-label{
  position: absolute;

  top: 0;
  left: 50%;
  transform: translate(-50%, -50%); /* sit on the border */

  font-size: 13px;
  font-weight: 800;
  font-family: "Helvetica Neue", Helvetica, Arial, ui-sans-serif, system-ui, -apple-system, "Segoe UI";

  padding: 2px 8px;
  border-radius: 999px;

  color: white;
  background: rgba(46,40,42,.55);

  white-space: nowrap;

  /* keep it above card content */
  z-index: 2;

  display: none; /* shown on submit */
}

@keyframes year-pop {
  0% { transform: translate(-50%, -50%) scale(2.6); }
  100% { transform: translate(-50%, -50%) scale(1); }
}

.year-label.is-revealed{
  animation: year-pop 240ms cubic-bezier(.2,.8,.2,1);
}

.day-label{
  position: absolute;
  top: 0;
  left: var(--card-pad);
  transform: translate(0, -50%);
  font-size: 10px;
  font-weight: 700;
  font-family: "Helvetica Neue", Helvetica, Arial, ui-sans-serif, system-ui, -apple-system, "Segoe UI";
  padding: 4px 10px;
  border-radius: 999px;
  color: rgba(31,31,34,.8);
  background: #cfd2d4;
  white-space: nowrap;
  z-index: 2;
}

.year-correct{
  background: #1f8f3a;
}

.card.clue .year-label{
  background: var(--saffron);
  color: var(--ink);
}

.year-wrong{
  background: var(--coral);
}

/* Guess feedback (NYT Flashback-inspired snap) */
@keyframes correct-pop {
  0%   { transform: scale(1); box-shadow: var(--shadowSoft); }
  40%  { transform: scale(1.015); box-shadow: 0 16px 32px rgba(31,143,58,.22); }
  100% { transform: scale(1); box-shadow: var(--shadowSoft); }
}

@keyframes wrong-shake {
  0%   { transform: translateX(0); }
  20%  { transform: translateX(-6px); }
  40%  { transform: translateX(6px); }
  60%  { transform: translateX(-4px); }
  80%  { transform: translateX(4px); }
  100% { transform: translateX(0); }
}

.card.guess-correct{
  animation: correct-pop 320ms ease-out;
  border-color: rgba(31,143,58,.55);
}

.card.guess-wrong{
  animation: wrong-shake 320ms ease-out;
  border-color: rgba(226,111,95,.55);
}
/* Placeholder */
.placeholder{
  width: min(520px, 100%);
  height: 68px;
  border-radius: var(--cardRadius);
  border: 2px dashed rgba(46,40,42,.22);
  background: rgba(255,255,255,.30);
}

/* Edge placeholders (top/bottom) reserve space and fade in */
.edge-placeholder{
  opacity: 0;
  transition: opacity 120ms ease;
}

.edge-placeholder.is-on{
  opacity: 1;
}

/* Drag layer prevents “shooting” */
#dragLayer{
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
}

/* Dragging card style */
.card.is-dragging{
  pointer-events: none;
  box-shadow: 0 18px 48px rgba(46,40,42,.22);
  transform: scale(1.02);
}

/* Submit */
#submitBtn{
  width: auto;
  border: none;
  border-radius: 999px;
  padding: 4px 10px;
  font-weight: 800;
  font-size: 14px;
  background: #1f1f22;
  color: white;
  cursor: pointer;
  position: absolute;
  left: 50%;
  top: 0;
  transform: translate(-50%, -50%);
  z-index: 10000;
  box-shadow: var(--shadowSoft);
  transition: opacity 140ms ease;
  opacity: 0;
  pointer-events: none;
}

#submitBtn.is-hidden{
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%);
  visibility: hidden;
}

@keyframes submit-ebb {
  0% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.04); }
  100% { transform: translate(-50%, -50%) scale(1); }
}

#submitBtn.submit-attn{
  animation: submit-ebb 900ms ease-in-out infinite;
}
#submitBtn:disabled{
  opacity: .45;
  cursor: default;
}

#result{
  margin-top: 10px;
  text-align:center;
  font-weight: 900;
  font-size: 18px;
}

@keyframes result-reveal {
  0%   { opacity: 0; transform: translateY(6px) scale(0.96); filter: blur(2px); }
  60%  { opacity: 1; transform: translateY(-1px) scale(1.02); filter: blur(0); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

#result.result-reveal{
  animation: result-reveal 520ms cubic-bezier(.2,.8,.2,1);
}

.daily-check{
  display: none;
  margin-left: 8px;
  color: #fff;
  font-weight: 900;
}

#dailyBtn.is-completed .daily-check{
  display: inline;
}

/* Result modal */
.result-modal{
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(46,40,42,.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  z-index: 9998;
}

/* Confirm modal */
.confirm-modal{
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(46,40,42,.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  z-index: 9998;
}

.confirm-modal.is-open{
  opacity: 1;
  pointer-events: auto;
}

.confirm-card{
  width: min(520px, calc(100% - 32px));
  background: rgba(255,255,255,.98);
  border: 1px solid rgba(46,40,42,.12);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px 16px;
  text-align: center;
  transform: translateY(8px) scale(0.98);
  transition: transform 220ms ease;
}

.confirm-modal.is-open .confirm-card{
  transform: translateY(0) scale(1);
}

.confirm-card p{
  margin: 0 0 14px;
  font-size: 15px;
  white-space: pre-line;
}

.confirm-actions{
  display: flex;
  gap: 10px;
  justify-content: center;
}

.confirm-actions button{
  appearance: none;
  border: 1px solid rgba(46,40,42,.18);
  background: rgba(255,255,255,.95);
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.confirm-actions button:active{
  transform: translateY(1px);
}

.confirm-actions #confirmYesBtn{
  background: var(--sage);
  color: white;
  border-color: rgba(122,163,155,.6);
}

.result-modal.is-open{
  opacity: 1;
  pointer-events: auto;
}

.result-card{
  width: min(520px, calc(100% - 32px));
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(46,40,42,.12);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px 16px;
  text-align: center;
  transform: translateY(8px) scale(0.98);
  transition: transform 220ms ease;
}

.result-modal.is-open .result-card{
  transform: translateY(0) scale(1);
}

.result-card h3{
  margin: 4px 0 8px;
  font-size: 18px;
}

.result-card p{
  margin: 0 0 14px;
  font-size: 15px;
  white-space: pre-line;
}

.result-actions{
  display: flex;
  gap: 10px;
  justify-content: center;
}

.result-actions button{
  appearance: none;
  border: 1px solid rgba(46,40,42,.18);
  background: rgba(255,255,255,.95);
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.result-actions button:active{
  transform: translateY(1px);
}

.result-actions #resultFreePlayBtn{
  background: var(--sage);
  color: white;
  border-color: rgba(122,163,155,.6);
}

/* No-image cards should be a normal full-width card */
.card.no-image{
  grid-template-columns: 1fr;   /* single column */
}

/* Ensure the description actually fills the card in no-image mode */
.card.no-image .description{
  grid-column: 1 / -1;
  width: 100%;
}

/* Fixed drop zones (do not affect layout) */
.drop-zone{
  position: absolute;
  left: 12px;
  right: 12px;
  height: 26px;
  border-radius: 14px;
  pointer-events: none;                 /* purely visual */
  opacity: 0;
  transform: scale(0.98);
  transition: opacity 120ms ease, transform 120ms ease;
  border: 1px solid rgba(23,190,187,.35);
  background: rgba(23,190,187,.12);
}

.drop-zone.is-hot{
  opacity: 1;
  transform: scale(1);
}

.drop-zone.top{ top: 10px; }
.drop-zone.bottom{ bottom: 10px; }

/* Overlay placeholder used ONLY for top/bottom (no layout movement) */
.placeholder-overlay{
  position: absolute;
  left: 12px;
  right: 12px;

  width: min(520px, calc(100% - 24px));
  margin: 0 auto;

  border-radius: var(--cardRadius);
  border: 2px dashed rgba(46,40,42,.28);
  background: rgba(255,255,255,.35);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.25);

  pointer-events: none;
  opacity: 0;
  transform: scale(0.995);
  transition: opacity 120ms ease, transform 120ms ease;

  z-index: 2; /* above the line, below dragged card */
}

.placeholder-overlay.is-on{
  opacity: 1;
  transform: scale(1);
}

/* Keyboard hover emphasis */
.card.kbd-hover{
  box-shadow: 0 14px 30px rgba(31,31,34,.18);
  border-color: rgba(31,31,34,.22);
}
.result-hidden{
  position: fixed;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
