/*
 * The city: the problem cards dealt into the middle of the board, and the
 * end-of-round / end-of-game modals.
 *
 * The card frame art is kept as-is; everything printed on top of it was
 * rebuilt so the requirements read as physical cubes and pawns.
 */

.problem-board {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0.8cqi;
  text-align: left;
}

.problem-board-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1cqi;
  padding-bottom: 0.5cqi;
  border-bottom: 0.07cqi solid rgba(180, 148, 84, 0.22);
  color: rgba(226, 234, 223, 0.9);
}

.problem-board-head strong {
  font-family: var(--display-font);
  font-size: clamp(0.36rem, 0.72cqi, 0.9rem);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.problem-board-head small {
  max-width: 66%;
  overflow: hidden;
  color: rgba(198, 211, 197, 0.55);
  font-size: clamp(0.36rem, 0.55cqi, 0.7rem);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.problem-card-list {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(var(--problem-columns, 2), minmax(0, 1fr));
  grid-auto-rows: auto;
  align-content: center;
  justify-items: center;
  gap: 0.8cqi;
  padding: 0.7cqi 0.2cqi 0.2cqi;
  overflow: hidden;
}

/* A dealt card: real frame art, lifted off the board, very slightly askew. */
.problem-card-piece {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  aspect-ratio: 1.5 / 1;
  display: flex;
  flex-direction: column;
  /*
   * Each card is its own query container, so the contents scale with the card
   * rather than with the board. That is what lets three or four cards share
   * the city without their requirement rows spilling over the frame.
   */
  container-type: inline-size;
  /* Percentages, not cqi: a container never queries itself. */
  padding: 4.4% 4.9% 3.9%;
  overflow: hidden;
  /*
   * The frame art carries a black margin and black outside its rounded
   * corners. `background-size` past 100% pushes the straight margin out of
   * view; the matching `border-radius` clips the corners, which is what
   * removed the black band around an enlarged card.
   */
  border-radius: 4.6% / 6.9%;
  background: #111b16 url("../assets/images/problem-card-frame.png") center / 102.5% 103.4% no-repeat;
  color: #d7dfd4;
  filter: drop-shadow(0 0.5cqi 0.7cqi rgba(0, 0, 0, 0.78));
  transform: rotate(-0.4deg);
}

.problem-card-piece:nth-child(even) { transform: rotate(0.5deg); }

.problem-card-piece.ready {
  filter:
    drop-shadow(0 0.5cqi 0.7cqi rgba(0, 0, 0, 0.7))
    drop-shadow(0 0 0.55cqi rgba(159, 221, 118, 0.55));
}

.problem-card-piece h3 {
  margin: 0;
  color: #ecefe6;
  font-family: var(--display-font);
  font-size: clamp(0.36rem, 4.9cqi, 1.15rem);
  font-weight: 600;
  letter-spacing: 0.03em;
  text-shadow: 0 0.518cqi 0.826cqi rgba(0, 0, 0, 0.85);
}

.problem-card-piece > p {
  margin: 1.54cqi 0 2.66cqi;
  color: #b9c3b6;
  font-size: clamp(0.36rem, 3.5cqi, 1.148rem);
  line-height: 1.35;
}

/* An empty printed space where the next problem will be dealt. */
.problem-card-slot {
  width: 100%;
  aspect-ratio: 1.5 / 1;
  display: grid;
  place-items: center;
  border-radius: 0.4cqi;
  border: 0.12cqi dashed rgba(163, 132, 74, 0.2);
}

.problem-card-slot span {
  color: rgba(174, 186, 172, 0.22);
  font-family: var(--display-font);
  font-size: clamp(0.36rem, 0.52cqi, 0.64rem);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

/* ------------------------------------------------------- requirement rows -- */

.problem-needs {
  display: grid;
  gap: 1.258cqi;
}

.problem-need-row {
  display: grid;
  grid-template-columns: 36cqi minmax(0, 1fr) 15.022cqi;
  align-items: center;
  gap: 2.59cqi;
  min-width: 0;
}

.problem-need-row.wood  { --face-lit: var(--wood-lit);  --face: var(--wood-face);  --face-dark: var(--wood); }
.problem-need-row.stone { --face-lit: var(--stone-lit); --face: var(--stone-face); --face-dark: var(--stone); }
.problem-need-row.tools { --face-lit: var(--tools-lit); --face: var(--tools-face); --face-dark: var(--tools); }
.problem-need-row.food  { --face-lit: var(--food-lit);  --face: var(--food-face);  --face-dark: var(--food); }

.problem-resource-name {
  display: flex;
  align-items: center;
  gap: 1.554cqi;
  overflow: hidden;
  color: #c8d2c5;
  font-size: clamp(0.36rem, 3.108cqi, 1.036rem);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.problem-resource-name .game-icon {
  color: var(--face);
  font-size: clamp(0.36rem, 4.04cqi, 1.33rem);
}

.problem-resource-slots {
  display: flex;
  gap: 1.14cqi;
  min-width: 0;
}

/*
 * Empty requirement socket, matched to the inventory cube shape.
 *
 * `--slots` is set inline from the requirement's size, so a seven-cube
 * requirement shrinks its sockets to fit the track instead of running under
 * the progress count.
 */
.problem-resource-slots i {
  display: grid;
  place-items: center;
  width: min(4.625cqi, calc((100% - (var(--slots, 4) - 1) * 1.14cqi) / var(--slots, 4)));
  aspect-ratio: 1;
  flex: 0 0 auto;
  border-radius: 0.518cqi;
  background: linear-gradient(rgba(3, 7, 5, 0.72), rgba(14, 22, 16, 0.4));
  font-style: normal;
  box-shadow:
    inset 0 0 0 0.204cqi rgba(163, 132, 74, 0.18),
    inset 0 0.296cqi 0.592cqi rgba(0, 0, 0, 0.68);
}

/* Delivered: an actual cube of that resource sitting in the socket. */
.problem-resource-slots i.filled {
  background: linear-gradient(148deg, var(--face-lit), var(--face) 46%, var(--face-dark));
  color: color-mix(in srgb, var(--face-dark) 66%, #080a06);
  box-shadow:
    inset 0.296cqi 0.296cqi 0.444cqi rgba(255, 255, 255, 0.4),
    inset -0.37cqi -0.444cqi 0.592cqi rgba(0, 0, 0, 0.5),
    var(--lift-1);
}

.problem-resource-slots i .game-icon {
  width: 68%;
  height: 68%;
}

.problem-need-row > b {
  color: var(--gold);
  font-family: var(--display-font);
  font-size: clamp(0.36rem, 3.263cqi, 1.092rem);
  font-weight: 500;
  white-space: nowrap;
}

/* -------------------------------------------------------- squads and time -- */

.problem-squads,
.problem-time {
  margin-top: 1.85cqi;
}

.problem-squads > strong,
.problem-time > strong {
  display: block;
  margin-bottom: 1.45cqi;
  color: rgba(219, 190, 130, 0.82);
  font-family: var(--display-font);
  font-size: clamp(0.36rem, 2.953cqi, 0.98rem);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.problem-squads > div {
  display: flex;
  align-items: center;
  gap: 1.658cqi;
}

/* An empty pawn space on the card. */
.problem-squads i {
  display: grid;
  place-items: center;
  width: 6.29cqi;
  aspect-ratio: 1;
  border-radius: 50%;
  background: linear-gradient(rgba(3, 7, 5, 0.7), rgba(14, 22, 16, 0.4));
  color: rgba(150, 163, 149, 0.3);
  font-style: normal;
  box-shadow:
    inset 0 0 0 0.222cqi rgba(163, 132, 74, 0.22),
    inset 0 0.296cqi 0.592cqi rgba(0, 0, 0, 0.68);
}

/* A crew that has actually been sent: the same pawn used in the stations. */
.problem-squads i.filled {
  background:
    radial-gradient(circle at 34% 26%, rgba(255, 244, 214, 0.42), transparent 46%),
    radial-gradient(circle at 48% 46%, #8a7145, #4b3b20 64%, #241a0e);
  color: #f0d494;
  box-shadow:
    inset -0.333cqi -0.407cqi 0.555cqi rgba(0, 0, 0, 0.65),
    inset 0.259cqi 0.259cqi 0.37cqi rgba(255, 255, 255, 0.3),
    var(--lift-1);
}

.problem-squads i .game-icon {
  width: 74%;
  height: 74%;
}

.problem-squads small {
  color: rgba(163, 176, 161, 0.72);
  font-size: clamp(0.36rem, 2.59cqi, 0.868rem);
}

/* The deadline track, printed the same way as the board's mood/round tracks. */
.problem-deadline-track {
  display: flex;
  align-items: center;
  gap: 0.962cqi;
}

.problem-deadline-track i {
  position: relative;
  display: grid;
  place-items: center;
  width: 7.252cqi;
  aspect-ratio: 1;
  border-radius: 50%;
  background: linear-gradient(rgba(3, 7, 5, 0.78), rgba(14, 22, 16, 0.45));
  color: rgba(174, 186, 172, 0.5);
  font-style: normal;
  box-shadow:
    inset 0 0 0 0.286cqi rgba(163, 132, 74, 0.24),
    inset 0 0.414cqi 0.829cqi rgba(0, 0, 0, 0.7);
}

.problem-deadline-track span {
  color: rgba(122, 136, 121, 0.55);
  font-size: clamp(0.36rem, 2.694cqi, 0.896rem);
}

/* The marker piece resting on the current step. */
.problem-deadline-track i.current {
  color: #1f2a13;
  background:
    radial-gradient(circle at 34% 26%, rgba(255, 255, 224, 0.95), transparent 36%),
    radial-gradient(circle at 46% 42%, #dff49b, #a3cd60 58%, #4e7a2f 88%);
  box-shadow:
    inset -0.333cqi -0.407cqi 0.555cqi rgba(30, 58, 18, 0.6),
    inset 0.259cqi 0.259cqi 0.37cqi rgba(255, 255, 255, 0.5),
    var(--lift-1);
}

.problem-deadline-track i .game-icon {
  width: 66%;
  height: 66%;
}

.problem-deadline-track i.deadline-skull {
  color: rgba(196, 104, 96, 0.72);
  box-shadow:
    inset 0 0 0 0.311cqi rgba(170, 76, 68, 0.4),
    inset 0 0.414cqi 0.829cqi rgba(0, 0, 0, 0.7);
}

.problem-deadline-track i.deadline-skull.expired {
  color: #ffcdc6;
  background: radial-gradient(circle at 40% 32%, #d4635a, #8e2f29 72%);
  box-shadow: var(--lift-1), 0 0 2.59cqi rgba(217, 75, 67, 0.6);
}

.problem-ready-label {
  margin-top: 1.554cqi;
  color: #bfe878;
  font-family: var(--display-font);
  font-size: clamp(0.36rem, 2.849cqi, 0.952rem);
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.problem-board-empty {
  flex: 1;
  display: grid;
  place-items: center;
  color: rgba(198, 211, 197, 0.5);
}

.phase-modal { width: min(45rem, 92vw); text-align: center; }
.phase-modal h2 { color: #efc475; }
.phase-modal .game-result-title {
  margin-bottom: .8rem;
  font-size: clamp(2rem, 5vw, 3.5rem);
  letter-spacing: .09em;
}
.phase-modal .game-result-title.is-victory {
  color: #9cf078;
  text-shadow: 0 0 .35rem rgba(125, 232, 93, .72), 0 0 1.1rem rgba(79, 190, 69, .42), 0 .16rem .2rem #000;
}
.phase-modal .game-result-title.is-defeat {
  color: #f06f68;
  text-shadow: 0 0 .35rem rgba(240, 82, 74, .68), 0 0 1.1rem rgba(174, 45, 42, .42), 0 .16rem .2rem #000;
}
.game-result-reason { color: #e0e6dd; font-size: 1rem; }
.loss-breakdown {
  width: min(36rem, 100%);
  margin: 1.2rem auto;
  padding: 1rem 1.15rem;
  border: 1px solid rgba(210, 101, 88, .52);
  border-radius: .55rem;
  background: linear-gradient(145deg, rgba(68, 25, 21, .44), rgba(18, 13, 11, .72));
  text-align: left;
}
.loss-breakdown h3 { margin: 0 0 .65rem; color: #f0a095; font-size: .86rem; letter-spacing: .035em; }
.loss-breakdown ul { display: grid; gap: .45rem; margin: 0; padding-left: 1.25rem; color: #e5d8d3; }
.loss-breakdown li::marker { color: #ed796d; }
.rematch-status {
  width: min(36rem, 100%);
  margin: 1.15rem auto .4rem;
  padding: .9rem 1.05rem;
  border: 1px solid rgba(155, 199, 112, .4);
  border-radius: .55rem;
  background: rgba(10, 24, 14, .58);
}
.rematch-status h3 { margin: 0 0 .6rem; color: #cbe88e; font-size: .86rem; letter-spacing: .055em; }
.rematch-status p { margin: .35rem 0 0; color: #b9c6b6; }
.rematch-player-list,
.rematch-exited-list { display: flex; flex-wrap: wrap; justify-content: center; gap: .4rem .85rem; }
.rematch-player-list span { color: #aee77f; }
.rematch-exited-list span { color: #db8a80; }
.game-over-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .7rem; }
.game-over-actions .modal-primary-action { width: min(16rem, 100%); margin: .8rem 0 0; }
.game-over-actions .rematch-choice-action,
.rematch-start-action { background-image: url("../assets/images/green-button.png"); }
.game-over-actions .game-exit-action { background-image: url("../assets/images/golden-button.png"); color: #e6c276; }
.rematch-start-action { width: min(22rem, 100%); }
.rematch-waiting { color: #aeb9ab; font-size: .82rem; }
.rematch-error { margin: .7rem 0 0; color: #f09589; }
.phase-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .7rem; }
.phase-actions .modal-primary-action { margin: .8rem 0 0; }
.phase-die { color: #efc475; font-size: 4.5rem; line-height: 1; text-shadow: 0 .3rem .5rem #000; }

.controller-delivery-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: .45rem;
}

.controller-delivery-row strong { min-width: 10rem; color: #d6dfd3; }
.controller-delivery-row button { padding: .38rem .62rem; border: 1px solid #627765; background: rgba(19,32,21,.85); color: #efc475; cursor: pointer; }
.controller-delivery-row button:disabled { opacity: .3; cursor: not-allowed; }
.finish-problem-action { filter: sepia(.35) brightness(1.12); }
