/* Souq — lobby + room styles. Phase 1a: readable defaults, no board yet.
   Board grid (CodePen-adapted) arrives in Phase 1b. */

.souq-lobby { max-width: 560px; padding-bottom: 40px; }
.souq-lobby h1 { font-size: 2.4rem; margin: 20px 0 4px; }
.souq-lobby .tagline { opacity: .8; margin: 0 0 24px; }
.ar-inline { font-weight: 400; opacity: .7; margin-left: 10px; font-size: 0.8em; direction: rtl; unicode-bidi: isolate; }

.souq-card {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 18px;
  margin: 16px 0;
}
.souq-card h2 { margin: 0 0 10px; font-size: 1.1rem; }
.souq-card label { display: block; margin: 10px 0 4px; font-size: .9rem; opacity: .9; }
.souq-card input[type="text"] {
  width: 100%; box-sizing: border-box;
  padding: 10px 12px; border-radius: 8px;
  background: rgba(0,0,0,0.25); color: #fff;
  border: 1px solid rgba(255,255,255,0.15);
  font-size: 1rem;
}
.souq-card input[type="text"]:focus { outline: 2px solid #4ea1ff; outline-offset: 1px; }

.souq-join { display: flex; gap: 8px; }
.souq-join input {
  flex: 1; text-transform: uppercase; letter-spacing: 2px;
  font-weight: 700; text-align: center;
}

.souq-status { margin-top: 16px; min-height: 1.4em; font-size: .9rem; }
.souq-status[data-kind="error"] { color: #ff9090; }
.souq-status[data-kind="warn"]  { color: #ffd17a; }

/* --- Room layout ------------------------------------------------------- */

.souq-room { max-width: 1200px; padding-bottom: 40px; }
.souq-header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.souq-header h1 { font-size: 1.6rem; margin: 10px 0; }
.souq-roomcode { font-size: .95rem; opacity: .85; }
.souq-roomcode strong { font-family: "Menlo", "Consolas", monospace; letter-spacing: 2px; margin: 0 6px; }

.btn.tiny { padding: 4px 10px; font-size: .8rem; }

.souq-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 16px;
  margin-top: 16px;
}
@media (max-width: 800px) {
  .souq-layout { grid-template-columns: 1fr; }
}

.souq-sidebar {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 14px;
  min-height: 400px;
}
.souq-sidebar h3 { margin: 6px 0 8px; font-size: .9rem; text-transform: uppercase; letter-spacing: 1px; opacity: .75; }

.souq-sidebar ul { list-style: none; margin: 0 0 18px; padding: 0; }
.souq-roster-row {
  display: grid;
  grid-template-columns: 20px 28px 1fr auto;
  gap: 8px; align-items: center;
  padding: 6px 8px; border-radius: 6px;
  margin-bottom: 2px;
}
.souq-roster-row.active { background: rgba(78, 161, 255, 0.18); }
.souq-roster-row.bankrupt { opacity: .45; text-decoration: line-through; }
.souq-roster-row.disconnected { opacity: .6; }
.souq-roster-row .seat { opacity: .6; font-variant-numeric: tabular-nums; }
.souq-roster-row .cash { font-variant-numeric: tabular-nums; font-weight: 600; }
.souq-roster-row .tag {
  display: inline-block; margin-left: 6px; padding: 1px 6px;
  font-size: .65rem; border-radius: 999px; background: rgba(255,255,255,.1);
}
.souq-roster-row .tag.jail { background: rgba(255, 170, 50, .25); }
.souq-roster-row .tag.dc   { background: rgba(255, 110, 110, .25); }
.souq-roster-row .tag.bot  { background: rgba(110, 200, 160, .25); }

.souq-host-controls { margin: 12px 0 20px; }

.souq-sidebar ol {
  max-height: 300px; overflow-y: auto;
  padding-left: 18px; margin: 0;
  font-size: .85rem;
}
.souq-sidebar ol li { margin-bottom: 4px; opacity: .9; }

.souq-board-wrap {
  background: #0b1a0c;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 20px;
  min-height: 400px;
}
.souq-actions {
  margin-top: 16px; display: flex; flex-direction: column; gap: 10px;
  align-items: center;
}
.souq-actions > .btn { min-width: 220px; }
.souq-manage { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.btn.danger { background: #b23a3a; color: #fff; }
.btn.danger:hover { background: #d04a4a; }

/* --- Trade modal + incoming-offer cards ------------------------------- */

.souq-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
/* Class-level display:flex beats the browser's default [hidden] rule,
   so we need an explicit override or the trade modal shows on page
   load. Applies to any souq-modal we add later. */
.souq-modal[hidden] { display: none; }
.souq-modal-card {
  background: #1a1e2a; color: #fff;
  border-radius: 12px; padding: 20px;
  width: 100%; max-width: 720px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.souq-modal-card header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.souq-modal-card h2 { margin: 0; font-size: 1.1rem; }
.souq-modal-card label { display: block; margin: 8px 0; font-size: .9rem; }
.souq-modal-card input[type="number"],
.souq-modal-card select {
  width: 100%; box-sizing: border-box;
  background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.15);
  color: #fff; padding: 8px 10px; border-radius: 6px;
}
.souq-modal-card footer { display: flex; gap: 8px; margin-top: 14px; }
.trade-two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .trade-two { grid-template-columns: 1fr; } }
.trade-two section {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px; padding: 12px;
}
.trade-two h3 { margin: 0 0 8px; font-size: .95rem; }
.trade-props {
  max-height: 180px; overflow-y: auto;
  margin-top: 10px; padding: 6px;
  background: rgba(0,0,0,0.2); border-radius: 6px;
}
.trade-props label { display: flex; align-items: center; gap: 6px; margin: 3px 0; font-size: .85rem; }
.trade-props .empty { opacity: .6; font-size: .8rem; margin: 0; }
.trade-error { color: #ff9090; margin: 10px 0 0; min-height: 1em; }

.trade-incoming {
  width: 100%; background: rgba(255, 220, 100, 0.08);
  border: 1px solid rgba(255, 220, 100, 0.25);
  border-radius: 8px; padding: 10px; margin-bottom: 10px;
}
.trade-incoming h4 { margin: 0 0 8px; font-size: .85rem; text-transform: uppercase; letter-spacing: 1px; }
.trade-card {
  background: rgba(0,0,0,0.2);
  border-radius: 6px; padding: 8px 10px; margin-bottom: 6px;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.trade-card p { flex: 1; margin: 0; font-size: .85rem; }

/* Property info popover — shown when any square is clicked. */
.prop-popover {
  position: absolute; top: 10%; left: 50%; transform: translateX(-50%);
  background: #1a1e2a; color: #fff;
  border-radius: 10px; padding: 14px 18px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  max-width: 280px; z-index: 10;
  font-family: "Poppins", system-ui, sans-serif;
  font-size: .85rem;
}
.prop-popover h4 { margin: 0 0 6px; font-size: 1rem; }
.prop-popover .rent-row { display: flex; justify-content: space-between; padding: 2px 0; border-top: 1px dashed rgba(255,255,255,0.1); }
.prop-popover .close { position: absolute; top: 6px; right: 8px; cursor: pointer; opacity: .7; }

/* Game-over banner overlaid on the board. */
.board-banner {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.75); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 4px; z-index: 5;
  font-family: "Poppins", system-ui, sans-serif;
  gap: 12px;
}
.board-banner .title { font-size: 1.8rem; font-weight: 800; }
.board-banner .sub   { opacity: .85; }
.sq { cursor: pointer; }

/* --- Board (11x11 CSS grid, layout inspired by
   https://codepen.io/johnnycopes/pen/yzQyMp — classic Monopoly grid pattern).
   Corners are 2x2 units; edge squares are 1x2 (corner squares double width
   so the name fits on the long axis). Center is a free 9x9 canvas for dice,
   status, and cards. Board always renders 1:1 square via aspect-ratio. */

#board {
  display: grid;
  grid-template-columns: 2fr repeat(9, 1fr) 2fr;
  grid-template-rows:    2fr repeat(9, 1fr) 2fr;
  gap: 2px;
  aspect-ratio: 1 / 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  background: #064a1f;           /* board felt */
  padding: 2px;
  border-radius: 4px;
  font-family: "Poppins", system-ui, -apple-system, sans-serif;
  color: #111;
  position: relative;            /* for overlay banner */
}

/* Mobile: narrower boards shrink all text proportionally and drop the
   rent-table hint on edge squares to keep city names legible. */
@media (max-width: 560px) {
  .souq-layout { grid-template-columns: 1fr; }
  .souq-sidebar { order: 2; }
  .souq-board-wrap { padding: 8px; }
  #board { font-size: .45rem; }
  .sq .name { font-size: .48rem; }
  .sq .price { font-size: .42rem; }
  .sq.corner .corner-label { font-size: .55rem; }
  .sq.corner .corner-icon  { font-size: 1.2rem; }
  .souq-center .title { font-size: 1.3rem; letter-spacing: 2px; }
  .souq-center .dice .d { width: 32px; height: 32px; font-size: 1.2rem; }
  .token { width: 10px; height: 10px; border-width: 1.5px; font-size: .4rem; }
}

.sq {
  background: #f4ead4;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: .55rem;
  line-height: 1.05;
  text-align: center;
}
.sq .color-bar {
  height: 18%;
  width: 100%;
  flex: none;
}
.sq .body {
  flex: 1;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 3px 2px;
  overflow: hidden;
}
.sq .name {
  font-size: .55rem; font-weight: 700;
  letter-spacing: .2px;
  margin-top: 2px;
  overflow: hidden;
}
.sq .price {
  font-size: .5rem; font-weight: 500; opacity: .8;
}
.sq .icon {
  font-size: 1.2rem; line-height: 1;
  margin: 4px 0;
}
.sq.corner { font-weight: 800; justify-content: center; align-items: center; padding: 6px; }
.sq.corner .corner-label { font-size: .7rem; letter-spacing: 1px; }
.sq.corner .corner-icon  { font-size: 1.8rem; margin: 4px 0; }

.sq.owned-0 { box-shadow: inset 0 0 0 3px #e63946; }
.sq.owned-1 { box-shadow: inset 0 0 0 3px #457b9d; }
.sq.owned-2 { box-shadow: inset 0 0 0 3px #2a9d8f; }
.sq.owned-3 { box-shadow: inset 0 0 0 3px #f4a261; }
.sq.owned-4 { box-shadow: inset 0 0 0 3px #8338ec; }
.sq.owned-5 { box-shadow: inset 0 0 0 3px #ffb703; }
.sq.owned-6 { box-shadow: inset 0 0 0 3px #06d6a0; }
.sq.owned-7 { box-shadow: inset 0 0 0 3px #ef476f; }
.sq.mortgaged { filter: grayscale(.8) opacity(.7); }

.sq .houses {
  position: absolute; top: 2px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 2px;
  font-size: .7rem;
}

/* Rotate the name text so it reads naturally along each board edge.
   Rotation is derived from grid placement: bottom row upright, left rotated
   90° CCW, top row upside-down-but-readable-from-top, right rotated 90° CW. */
.sq[data-edge="bottom"] { }
.sq[data-edge="left"]   { flex-direction: row; }
.sq[data-edge="left"]   .color-bar { width: 18%; height: 100%; flex: none; }
.sq[data-edge="left"]   .body      { padding: 2px 3px; transform: rotate(90deg); white-space: nowrap; }
.sq[data-edge="top"]    .body      { transform: rotate(180deg); }
.sq[data-edge="top"]    .color-bar { order: 2; }  /* bar on inside edge */
.sq[data-edge="top"]    { flex-direction: column-reverse; }
.sq[data-edge="right"]  { flex-direction: row-reverse; }
.sq[data-edge="right"]  .color-bar { width: 18%; height: 100%; flex: none; }
.sq[data-edge="right"]  .body      { padding: 2px 3px; transform: rotate(-90deg); white-space: nowrap; }

/* Color-group stripes — Classic Monopoly palette. */
.g-brown     { background: #8b4513; }
.g-lightblue { background: #87ceeb; }
.g-pink      { background: #d6408a; }
.g-orange    { background: #f48020; }
.g-red       { background: #ed1b24; }
.g-yellow    { background: #fef200; }
.g-green     { background: #1fb25a; }
.g-darkblue  { background: #0072bb; }

/* Board center: 9×9 free panel for dice / status / cards. */
.souq-center {
  grid-row: 2 / span 9;
  grid-column: 2 / span 9;
  background: #0b4c20;
  color: #fff;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 18px;
  padding: 24px;
  text-align: center;
  font-family: "Poppins", system-ui, sans-serif;
}
.souq-center .title {
  font-size: 2rem; letter-spacing: 4px; font-weight: 800;
  color: #f4ead4; text-transform: uppercase;
}
.souq-center .subtitle { opacity: .85; font-size: .9rem; max-width: 300px; }
.turn-countdown {
  display: inline-block; margin-top: 6px; padding: 2px 10px;
  font-family: "Menlo", monospace; font-weight: 600;
  background: rgba(255, 190, 50, 0.2); border: 1px solid rgba(255, 190, 50, 0.5);
  border-radius: 999px;
}
.souq-center .dice     {
  display: flex; gap: 14px; margin-top: 10px;
  font-family: "Menlo", monospace; font-weight: 800; font-size: 2rem;
}
.souq-center .dice .d {
  width: 48px; height: 48px; border-radius: 8px;
  background: #fff; color: #111;
  display: flex; align-items: center; justify-content: center;
}

/* Player tokens — small circles stacked at bottom of a square. */
.sq .tokens {
  position: absolute; bottom: 2px; left: 2px; right: 2px;
  display: flex; flex-wrap: wrap; gap: 2px;
  justify-content: center;
  pointer-events: none;
}
.token {
  width: 14px; height: 14px; border-radius: 50%;
  background: #111; color: #fff;
  font-size: .55rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.4);
}
.token.seat-0 { background: #e63946; }
.token.seat-1 { background: #457b9d; }
.token.seat-2 { background: #2a9d8f; }
.token.seat-3 { background: #f4a261; }
.token.seat-4 { background: #8338ec; }
.token.seat-5 { background: #ffb703; }
.token.seat-6 { background: #06d6a0; }
.token.seat-7 { background: #ef476f; }
