/* Domino - La Juegoteca */

#screen-domino-game {
  width: 100vw;
  min-height: 100dvh;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 20%, #1a3a28, #0a1a0f);
  color: #e0e0e0;
  font-family: 'Segoe UI', Tahoma, sans-serif;
  user-select: none;
}

#screen-domino-game.active {
  display: flex;
}

.domino-score-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 12px;
  width: min(720px, calc(100vw - 32px));
  margin: 10px auto 0;
}

.domino-score-option {
  min-height: 124px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 7px;
  padding: 16px;
  border: 1px solid rgba(240,192,64,0.24);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03)),
    rgba(7,16,11,0.78);
  color: #e8e2d4;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(0,0,0,0.22);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.domino-score-option:hover,
.domino-score-option:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(250,204,21,0.8);
  box-shadow: 0 16px 34px rgba(0,0,0,0.32), 0 0 0 2px rgba(250,204,21,0.18);
  outline: none;
}

.domino-score-option.is-recommended {
  border-color: rgba(250,204,21,0.55);
  background:
    linear-gradient(180deg, rgba(250,204,21,0.16), rgba(255,255,255,0.03)),
    rgba(8,18,12,0.88);
}

.domino-score-option .domino-score-name {
  max-width: none;
  overflow: visible;
  white-space: normal;
  font-size: 1.15rem;
  color: #fff4bd;
}

.domino-score-meta {
  font-size: 0.78rem;
  color: #f0c040;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.domino-score-hint {
  color: #aebfaf;
  font-size: 0.82rem;
  line-height: 1.35;
}

@media (max-width: 640px) {
  .domino-score-options {
    grid-template-columns: 1fr;
    width: min(420px, calc(100vw - 28px));
  }
  .domino-score-option {
    min-height: 94px;
  }
}

#domino-score-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 6px 12px;
  background: rgba(0,0,0,0.35);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-size: 0.78rem;
  letter-spacing: 1px;
  flex-shrink: 0;
  flex-wrap: wrap;
  z-index: 20;
}

.domino-score-entry {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(255,255,255,0.05);
}
.domino-score-entry.me {
  background: rgba(240,192,64,0.12);
  border: 1px solid rgba(240,192,64,0.25);
}
.domino-score-name {
  font-weight: 600;
  max-width: 86px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.domino-score-pts {
  color: #f0c040;
  font-weight: 700;
  font-size: 0.9rem;
}
.domino-score-target {
  color: #6a9a7a;
  font-size: 0.68rem;
}

#domino-status {
  text-align: center;
  font-size: 0.8rem;
  letter-spacing: 1.5px;
  color: #90c0a0;
  padding: 4px 8px;
  min-height: 1.6em;
  flex-shrink: 0;
}

#domino-game-area {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  position: relative;
  min-height: 0;
}

/* Wide table layout: seats wrap around a broad central felt. */
#domino-table-layout {
  display: grid;
  grid-template-areas:
    "top top top"
    "left table right"
    "bottom bottom bottom";
  grid-template-columns: 180px minmax(600px, 1fr) 180px;
  grid-template-rows: 100px minmax(360px, 1fr) 86px;
  gap: 12px;
  flex: 1;
  width: min(94vw, 1500px);
  min-height: min(620px, calc(100dvh - 126px));
  margin: 0 auto;
  padding: 10px 0 6px;
  position: relative;
}

.domino-table-middle {
  display: contents;
  align-items: initial;
  gap: initial;
  min-height: 0;
}

.domino-seat-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  position: relative;
  border-radius: 12px;
  transition: filter 0.18s, transform 0.18s;
}
.domino-seat-zone.active-turn {
  filter: drop-shadow(0 0 18px rgba(250,204,21,0.35));
}
.domino-seat-top,
.domino-seat-bottom {
  gap: 8px;
  flex-wrap: wrap;
}
.domino-seat-top { grid-area: top; }
.domino-seat-bottom { grid-area: bottom; }
.domino-seat-left { grid-area: left; justify-content: flex-end; padding-right: 8px; }
.domino-seat-right { grid-area: right; justify-content: flex-start; padding-left: 8px; }
.domino-seat-side {
  align-items: center;
}

.domino-opponent {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  min-width: 70px;
  max-width: 132px;
  transition: border-color 0.3s, background 0.3s, box-shadow 0.3s, transform 0.2s;
  position: relative;
}
.domino-opponent.active {
  border-color: rgba(250,204,21,0.95);
  background: rgba(240,192,64,0.08);
  box-shadow:
    0 0 0 2px rgba(250,204,21,0.72),
    0 0 26px rgba(250,204,21,0.42);
}
.domino-opponent.active-turn {
  animation: activeTurnPulse 1.4s ease-in-out infinite;
}
@keyframes activeTurnPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow:
      0 0 0 2px rgba(250,204,21,0.66),
      0 0 18px rgba(250,204,21,0.34);
  }
  50% {
    transform: scale(1.03);
    box-shadow:
      0 0 0 3px rgba(250,204,21,0.94),
      0 0 30px rgba(250,204,21,0.58);
  }
}
.domino-turn-badge {
  position: absolute;
  left: 50%;
  top: -24px;
  transform: translateX(-50%);
  background: rgba(250,204,21,0.96);
  color: #102418;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.6px;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
  z-index: 8;
}
.domino-opponent.me {
  background: rgba(240,192,64,0.1);
  border-color: rgba(240,192,64,0.32);
}
.domino-opponent.teammate {
  border-color: rgba(80,180,120,0.42);
  box-shadow: inset 0 0 0 1px rgba(80,180,120,0.08);
}
.domino-opponent.rival {
  border-color: rgba(210,110,110,0.28);
}
.domino-opp-name {
  font-size: 0.72rem;
  letter-spacing: 1px;
  color: #a0c0b0;
  max-width: 88px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.domino-opp-tiles {
  display: flex;
  gap: 2px;
}
.domino-tile-back {
  width: 14px;
  height: 22px;
  background: linear-gradient(135deg, #2a4a3a, #1a3028);
  border: 1px solid #4a7a5a;
  border-radius: 2px;
}
.domino-opp-count {
  font-size: 0.62rem;
  color: #708080;
}
.domino-team-tag {
  font-size: 0.58rem;
  letter-spacing: 2px;
  color: #79b98d;
  text-transform: uppercase;
}
.domino-opponent.rival .domino-team-tag {
  color: #c07878;
}

.domino-pass-bubble {
  position: absolute;
  left: 50%;
  top: -52px;
  transform: translateX(-50%);
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(15,23,42,0.94);
  border: 1px solid rgba(250,204,21,0.72);
  color: #facc15;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.8px;
  white-space: nowrap;
  pointer-events: none;
  animation: domino-pass-pop 1.15s ease-out forwards;
  z-index: 50;
}
@keyframes domino-pass-pop {
  0%   { opacity: 0; transform: translate(-50%, 8px) scale(0.95); }
  15%  { opacity: 1; transform: translate(-50%, 0) scale(1); }
  75%  { opacity: 1; transform: translate(-50%, -6px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -16px) scale(0.98); }
}

#domino-chain-wrap {
  --domino-tile-long: 56px;
  --domino-tile-short: 32px;
  --domino-tile-gap: 12px;
  --domino-turn-gap: 28px;
  --domino-lane-gap: 72px;
  --domino-safe-padding: 78px;
  --domino-board-h: 100%;
  grid-area: table;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  width: 100%;
  height: 100%;
  border-radius: 24px;
  background:
    radial-gradient(ellipse at center, rgba(240,192,64,0.11), transparent 62%),
    linear-gradient(160deg, rgba(18,55,36,0.78), rgba(7,24,14,0.88));
  border: 1px solid rgba(240,192,64,0.12);
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.04),
    inset 0 18px 44px rgba(255,255,255,0.03),
    0 18px 48px rgba(0,0,0,0.28);
}

#domino-chain {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 340px;
}

#domino-boneyard {
  position: absolute;
  right: 22px;
  top: 18px;
  z-index: 80;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 8px 10px;
  border: 1px solid rgba(240,192,64,0.36);
  border-radius: 8px;
  background: rgba(7,16,11,0.88);
  color: #eadca8;
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.8px;
  cursor: default;
  box-shadow: 0 10px 22px rgba(0,0,0,0.32);
}

#domino-boneyard.is-visible {
  display: inline-flex;
}

#domino-boneyard.can-draw {
  cursor: pointer;
  border-color: rgba(250,204,21,0.82);
  color: #fff4bd;
  box-shadow: 0 10px 24px rgba(0,0,0,0.34), 0 0 0 2px rgba(250,204,21,0.14);
}

#domino-boneyard.can-draw:hover {
  filter: brightness(1.08);
}

.domino-boneyard-stack {
  width: 24px;
  height: 34px;
  border-radius: 5px;
  background: linear-gradient(160deg,#1a1a1a,#2a2a2a);
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow:
    3px 0 0 #101010,
    6px 0 0 #202020,
    0 4px 8px rgba(0,0,0,0.35);
}

#domino-chain-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #3a5a4a;
  font-size: 0.78rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-align: center;
}

.chain-endpoint {
  position: absolute;
  width: 28px;
  height: 46px;
  border: 2px dashed rgba(240,192,64,0.6);
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: rgba(240,192,64,0.8);
  letter-spacing: 1px;
  transition: background 0.2s, border-color 0.2s;
  animation: endpoint-pulse 1.4s ease-in-out infinite;
  transform: translate(-50%, -50%);
}
.chain-endpoint:hover {
  background: rgba(240,192,64,0.12);
  border-color: #f0c040;
}
@keyframes endpoint-pulse {
  0%, 100% { border-color: rgba(240,192,64,0.4); }
  50% { border-color: rgba(240,192,64,0.9); }
}

.domino-tile {
  display: flex;
  align-items: center;
  background: #f5f0e8;
  border-radius: 4px;
  border: 1px solid #c8c0a8;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.4);
  cursor: default;
  flex-shrink: 0;
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
}

.domino-tile.chain-tile {
  position: absolute;
  transform: translate(-50%, -50%);
}
.domino-tile.chain-tile.animating-target {
  opacity: 0;
}
.domino-tile.pending-placement {
  opacity: 0;
}
.domino-tile.domino-moving-tile {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 9999;
  pointer-events: none;
  will-change: transform, opacity, filter;
  filter: drop-shadow(0 10px 14px rgba(0,0,0,0.45));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4);
}
.domino-tile.domino-moving-tile.is-flying {
  transition:
    transform 520ms cubic-bezier(.2,.8,.2,1),
    opacity 520ms ease;
}
.domino-tile.domino-moving-tile.domino-horizontal {
  flex-direction: row;
}
.domino-tile.domino-moving-tile.domino-vertical {
  flex-direction: column;
}
.domino-tile.chain-tile.domino-horizontal {
  width: var(--domino-tile-long);
  height: var(--domino-tile-short);
  flex-direction: row;
}
.domino-tile.chain-tile.domino-vertical {
  width: var(--domino-tile-short);
  height: var(--domino-tile-long);
  flex-direction: column;
}
.domino-tile.hand-tile {
  width: 40px;
  height: 70px;
  flex-direction: column;
  cursor: pointer;
}
.domino-tile.hand-tile:hover {
  transform: translateY(-6px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.4);
}
.domino-tile.hand-tile.selected {
  transform: translateY(-10px);
  box-shadow: 0 8px 20px rgba(240,192,64,0.5), inset 0 1px 0 rgba(255,255,255,0.4);
  border-color: #f0c040;
  border-width: 2px;
}
.domino-tile.hand-tile.playable {
  border-color: #60c080;
}
.domino-tile.hand-tile.not-playable {
  opacity: 0.45;
  cursor: not-allowed;
}
.domino-tile.hand-tile.not-playable:hover {
  transform: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.4);
}
.domino-tile.hand-tile.is-being-played {
  opacity: 0;
  pointer-events: none;
}

.domino-half {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}
.domino-divider-h {
  width: 100%;
  height: 1px;
  background: #a0987a;
  flex-shrink: 0;
}
.domino-tile.domino-horizontal .domino-half {
  width: auto;
  height: 100%;
}
.domino-tile.domino-horizontal .domino-divider-h {
  width: 1px;
  height: 100%;
}

.pip-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: 100%;
  height: 100%;
  padding: 3px;
  box-sizing: border-box;
}
.pip-cell {
  display: flex;
  align-items: center;
  justify-content: center;
}
.pip-dot {
  border-radius: 50%;
  background: #1c1c1c;
}
.chain-tile .pip-dot {
  width: 5px;
  height: 5px;
}
.hand-tile .pip-dot {
  width: 7px;
  height: 7px;
}

#domino-hand-wrap {
  padding: 10px 18px 16px;
  background: rgba(0,0,0,0.3);
  border-top: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
  z-index: 30;
}

#domino-hand-info {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 0.72rem;
  color: #708070;
  letter-spacing: 1px;
}

#domino-hand-info.is-visible {
  display: flex;
}

#btn-domino-draw {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 5px 12px;
  border: 1px solid rgba(240,192,64,0.42);
  border-radius: 7px;
  background: linear-gradient(135deg, #f0c040, #9d6f12);
  color: #16110a;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.8px;
  cursor: pointer;
  box-shadow: 0 5px 16px rgba(240,192,64,0.22);
}

#btn-domino-draw.is-visible {
  display: inline-flex;
}

#btn-domino-draw:hover {
  filter: brightness(1.08);
}

#domino-hand {
  display: flex;
  gap: clamp(9px, 1.1vw, 14px);
  justify-content: center;
  align-items: flex-end;
  flex-wrap: wrap;
  min-height: 78px;
  padding: 4px 18px 2px;
}

#overlay-domino-round .overlay-box,
#overlay-domino-result .overlay-box {
  text-align: center;
}
.domino-round-title {
  font-size: 1.4rem;
  letter-spacing: 3px;
  color: #f0c040;
  margin-bottom: 8px;
}
.domino-round-detail {
  font-size: 0.85rem;
  color: #a0c0a0;
  margin-bottom: 4px;
}
.domino-round-scores,
.domino-final-scores {
  margin: 10px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.domino-round-review {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
  text-align: left;
}
.domino-round-review-row {
  border: 1px solid rgba(240,192,64,0.18);
  border-radius: 8px;
  background: rgba(8, 26, 16, 0.62);
  padding: 8px;
}
.domino-round-review-row.winner {
  border-color: rgba(250,204,21,0.52);
  box-shadow: 0 0 0 1px rgba(250,204,21,0.12);
}
.domino-round-review-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  color: #e9e2c2;
  font-size: 0.75rem;
  font-weight: 800;
}
.domino-round-review-head small {
  color: #90c090;
  font-size: 0.62rem;
  font-weight: 700;
  white-space: nowrap;
}
.domino-round-review-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}
.domino-tile.round-review-tile {
  width: 34px;
  height: 20px;
  flex-direction: row;
  border-radius: 3px;
}
.domino-tile.round-review-tile .pip-dot {
  width: 3px;
  height: 3px;
}
.domino-round-review-empty {
  color: #f0c040;
  font-size: 0.68rem;
  font-weight: 800;
}
.domino-round-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.domino-round-countdown {
  color: #7eb28a;
  font-size: 0.68rem;
  letter-spacing: 1px;
}
.domino-round-score-row,
.domino-final-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 12px;
  background: rgba(255,255,255,0.04);
  border-radius: 5px;
  font-size: 0.8rem;
}
.domino-round-score-row.leader,
.domino-final-row.winner-row {
  background: rgba(240,192,64,0.1);
  border: 1px solid rgba(240,192,64,0.2);
}
.domino-round-score-name,
.domino-final-name {
  color: #c0d0c0;
}
.domino-round-score-pts,
.domino-final-pts {
  color: #f0c040;
  font-weight: 700;
}
.domino-result-title {
  font-size: 1.8rem;
  letter-spacing: 3px;
  color: #f0c040;
  margin-bottom: 6px;
}
.domino-result-subtitle {
  font-size: 0.85rem;
  color: #90c090;
  margin-bottom: 14px;
  letter-spacing: 1px;
}

@keyframes dominoLand {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.985);
    filter: brightness(1.04);
  }
  70% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.015);
    filter: brightness(1.02);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    filter: brightness(1);
  }
}
.chain-tile.land-animation {
  animation: dominoLand 0.16s ease-out forwards;
}

#domino-toast {
  position: absolute;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20,40,30,0.92);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 7px 16px;
  font-size: 0.78rem;
  letter-spacing: 1px;
  color: #c0e0c0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  white-space: nowrap;
  z-index: 10;
}
#domino-toast.show {
  opacity: 1;
}

@media (max-width: 760px) {
  .domino-round-review {
    grid-template-columns: 1fr;
  }
  #domino-score-bar {
    gap: 6px;
    padding: 5px 8px;
  }
  #domino-table-layout {
    width: min(96vw, 760px);
    grid-template-rows: 58px minmax(250px, 1fr) 42px;
    grid-template-columns: 76px minmax(210px, 1fr) 76px;
    gap: 7px;
    padding: 8px 0 4px;
  }
  .domino-table-middle {
    display: contents;
  }
  .domino-opponent {
    min-width: 58px;
    max-width: 74px;
    padding: 4px 5px;
  }
  .domino-opp-name {
    max-width: 62px;
    font-size: 0.64rem;
  }
  .domino-opp-tiles {
    max-width: 58px;
    overflow: hidden;
  }
  .domino-tile-back {
    width: 10px;
    height: 17px;
  }
  .domino-team-tag,
  .domino-opp-count {
    font-size: 0.54rem;
  }
  #domino-chain-wrap {
    --domino-tile-long: 44px;
    --domino-tile-short: 26px;
    --domino-tile-gap: 7px;
    --domino-turn-gap: 16px;
    --domino-lane-gap: 46px;
    --domino-safe-padding: 18px;
    border-radius: 16px;
  }
  #domino-chain {
    min-height: 240px;
  }
  .domino-tile.chain-tile.domino-horizontal {
    width: var(--domino-tile-long);
    height: var(--domino-tile-short);
  }
  .domino-tile.chain-tile.domino-vertical {
    width: var(--domino-tile-short);
    height: var(--domino-tile-long);
  }
  .chain-tile .pip-dot {
    width: 4px;
    height: 4px;
  }
  #domino-hand {
    gap: clamp(6px, 2vw, 9px);
    min-height: 62px;
    padding: 3px 8px 2px;
  }
  #domino-hand-wrap {
    padding: 8px 10px 12px;
  }
  .domino-tile.hand-tile {
    width: 32px;
    height: 56px;
  }
  .hand-tile .pip-dot {
    width: 5px;
    height: 5px;
  }
}
