/* =========================================================
   Truco — entyscoco
   Direction : la pulpería. Bois sombre, laiton, papier de
   carte espagnole. Le trucómetro est la signature.
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Abril+Fatface&family=Karla:ital,wght@0,400;0,600;0,700;1,400&family=Space+Mono:wght@400;700&display=swap');

:root {
  --noche: #16110e;
  --madera: #241a15;
  --madera-2: #2f221b;
  --madera-3: #3d2c22;
  --hueso: #efe3cc;
  --hueso-dim: #b9a98f;
  --fileteado: #e0a52e;
  --fileteado-dark: #a97a17;
  --sangre: #a8322a;
  --verde: #4e7a52;
  --indigo: #3f6489;

  --display: 'Abril Fatface', Georgia, serif;
  --body: 'Karla', system-ui, sans-serif;
  --mono: 'Space Mono', ui-monospace, monospace;

  --r: 6px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --line: 1px solid rgba(224, 165, 46, .22);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 700px at 50% -10%, #2a1d16 0%, transparent 60%),
    repeating-linear-gradient(101deg, rgba(255, 255, 255, .012) 0 2px, transparent 2px 7px),
    var(--noche);
  color: var(--hueso);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--fileteado); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-family: var(--display); font-weight: 400; letter-spacing: .01em; margin: 0 0 .4em; }
h1 { font-size: clamp(2.1rem, 5vw, 3.6rem); line-height: 1.02; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.12rem; }

.eyebrow {
  font-family: var(--mono); font-size: .68rem; letter-spacing: .22em;
  text-transform: uppercase; color: var(--fileteado); margin-bottom: .6rem;
}

.muted { color: var(--hueso-dim); }
.small { font-size: .85rem; }
.mono { font-family: var(--mono); }
.center { text-align: center; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.stack > * + * { margin-top: .8rem; }
.hidden { display: none !important; }

/* ------------------------------------------------------------ chrome */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .7rem clamp(.9rem, 3vw, 2rem);
  border-bottom: var(--line);
  background: linear-gradient(180deg, rgba(45, 32, 25, .95), rgba(22, 17, 14, .8));
  position: sticky; top: 0; z-index: 40; backdrop-filter: blur(6px);
}

.wordmark {
  font-family: var(--display); font-size: 1.45rem; color: var(--hueso);
  display: inline-flex; align-items: baseline; gap: .45rem;
}
.wordmark:hover { text-decoration: none; }
.wordmark .pip { color: var(--fileteado); font-size: 1.1em; }
.wordmark small {
  font-family: var(--mono); font-size: .58rem; letter-spacing: .2em;
  color: var(--hueso-dim); text-transform: uppercase;
}

.nav { display: flex; gap: 1.1rem; align-items: center; font-size: .92rem; }
.nav a { color: var(--hueso-dim); }
.nav a:hover, .nav a.active { color: var(--fileteado); text-decoration: none; }

.wrap { max-width: 1180px; margin: 0 auto; padding: clamp(1rem, 3vw, 2.4rem) clamp(.9rem, 3vw, 2rem) 4rem; }

/* ------------------------------------------------------------ panneaux */
.panel {
  background: linear-gradient(180deg, var(--madera-2), var(--madera));
  border: var(--line); border-radius: var(--r);
  padding: 1.1rem 1.2rem; box-shadow: var(--shadow);
}
.panel + .panel { margin-top: 1rem; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: .8rem; }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* -------------------------------------------------------------- boutons */
.btn {
  font-family: var(--body); font-weight: 700; font-size: .9rem;
  letter-spacing: .02em; color: var(--hueso);
  background: linear-gradient(180deg, var(--madera-3), var(--madera-2));
  border: 1px solid rgba(224, 165, 46, .3); border-radius: var(--r);
  padding: .55rem 1rem; cursor: pointer; transition: transform .12s, box-shadow .12s, border-color .12s;
}
.btn:hover { border-color: var(--fileteado); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .35; cursor: not-allowed; transform: none; }
.btn:focus-visible { outline: 2px solid var(--fileteado); outline-offset: 2px; }

.btn--gold { background: linear-gradient(180deg, var(--fileteado), var(--fileteado-dark)); color: #1a1207; border-color: #f0c25c; }
.btn--si { background: linear-gradient(180deg, #5f9163, var(--verde)); border-color: #7db183; color: #0f1a10; }
.btn--no { background: linear-gradient(180deg, #c0413a, var(--sangre)); border-color: #d8635b; color: #1c0b09; }
.btn--ghost { background: transparent; border-color: rgba(239, 227, 204, .22); color: var(--hueso-dim); }
.btn--ghost:hover { color: var(--hueso); }
.btn--sm { padding: .32rem .65rem; font-size: .78rem; }
.btn--block { display: block; width: 100%; }

/* ------------------------------------------------------- champs de saisie */
label.field { display: block; margin-bottom: .7rem; }
label.field span { display: block; font-size: .78rem; letter-spacing: .1em; text-transform: uppercase; color: var(--hueso-dim); margin-bottom: .25rem; }
input[type=text], input[type=password], input[type=search], select, textarea {
  width: 100%; font-family: var(--body); font-size: .95rem; color: var(--hueso);
  background: rgba(0, 0, 0, .3); border: 1px solid rgba(239, 227, 204, .18);
  border-radius: var(--r); padding: .5rem .65rem;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--fileteado); }
select option { background: var(--madera); }

.toggle { display: flex; gap: .7rem; align-items: flex-start; padding: .55rem 0; border-bottom: 1px dashed rgba(239, 227, 204, .1); cursor: pointer; }
.toggle:last-child { border-bottom: 0; }
.toggle input { appearance: none; width: 38px; height: 21px; flex: 0 0 38px; margin-top: .15rem; border-radius: 999px; background: rgba(0, 0, 0, .5); border: 1px solid rgba(239, 227, 204, .2); position: relative; cursor: pointer; transition: background .15s; }
.toggle input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 50%; background: var(--hueso-dim); transition: transform .15s, background .15s; }
.toggle input:checked { background: rgba(224, 165, 46, .35); border-color: var(--fileteado); }
.toggle input:checked::after { transform: translateX(17px); background: var(--fileteado); }
.toggle input:focus-visible { outline: 2px solid var(--fileteado); outline-offset: 2px; }
.toggle b { font-size: .92rem; font-weight: 700; display: block; }
.toggle em { font-style: normal; font-size: .8rem; color: var(--hueso-dim); }
.toggle.disabled { opacity: .4; }

/* ------------------------------------------------------------- listes */
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: .6rem 0; border-bottom: 1px dashed rgba(239, 227, 204, .12); display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
.list li:last-child { border-bottom: 0; }

table.data { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.data th { text-align: left; font-family: var(--mono); font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: var(--fileteado); padding: .4rem .5rem; border-bottom: 1px solid rgba(224, 165, 46, .25); }
table.data td { padding: .45rem .5rem; border-bottom: 1px dashed rgba(239, 227, 204, .1); vertical-align: middle; }
table.data tr:hover td { background: rgba(224, 165, 46, .05); }

.tag { display: inline-block; font-family: var(--mono); font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; padding: .12rem .45rem; border-radius: 3px; border: 1px solid currentColor; }
.tag--live { color: var(--verde); }
.tag--lobby { color: var(--fileteado); }
.tag--done { color: var(--hueso-dim); }
.tag--bot { color: var(--indigo); }
.tag--admin { color: var(--sangre); }

/* --------------------------------------------------------------- cartes */
.card {
  width: var(--cw, 92px); aspect-ratio: 5 / 8; border-radius: 5px;
  background: linear-gradient(160deg, #f6ecd8, #e2d2b4);
  border: 1px solid #b9a884; box-shadow: 0 5px 14px rgba(0, 0, 0, .5);
  display: block; position: relative; overflow: hidden; flex: 0 0 auto;
}
.card svg { display: block; width: 100%; height: 100%; }
.card--photo { background: #fff; aspect-ratio: 250 / 384; border-color: #9d8c6d; overflow: hidden; }
.card--photo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.card--photo .brava { position: absolute; top: 5px; right: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--fileteado); box-shadow: 0 0 5px rgba(224,165,46,.8); }

.card--back { background: repeating-linear-gradient(45deg, #6c2b25 0 6px, #57211c 6px 12px); border-color: #3a1613; }
.card--back::after {
  content: '♠'; position: absolute; inset: 0; display: grid; place-items: center;
  color: rgba(224, 165, 46, .5); font-size: 1.6rem;
}
.card--sm { --cw: 58px; }
.card--xs { --cw: 40px; }

.hand { display: flex; gap: .55rem; justify-content: center; align-items: flex-end; }
.hand .card { transition: transform .16s, box-shadow .16s; cursor: pointer; }
.hand .card:hover, .hand .card:focus-visible { transform: translateY(-14px); box-shadow: 0 14px 26px rgba(0, 0, 0, .6); outline: none; }
.hand .card.locked { cursor: not-allowed; filter: saturate(.5) brightness(.75); }
.hand .card.locked:hover { transform: none; }

/* ---------------------------------------------------------------- table */
.felt {
  position: relative; border-radius: 14px; min-height: 380px;
  background:
    radial-gradient(closest-side at 50% 45%, #2c4c3a 0%, #1e3629 70%, #17281f 100%),
    var(--madera);
  border: 6px solid var(--madera-3);
  box-shadow: inset 0 0 60px rgba(0, 0, 0, .6), var(--shadow);
  padding: 1rem; overflow: hidden;
}
.felt::after {
  content: ''; position: absolute; inset: 10px; border: 1px solid rgba(224, 165, 46, .16);
  border-radius: 10px; pointer-events: none;
}

.seat { position: absolute; text-align: center; width: 190px; }
.seat--n { top: 12px; left: 50%; transform: translateX(-50%); }
.seat--s { bottom: 12px; left: 50%; transform: translateX(-50%); }
.seat--e { right: 8px; top: 50%; transform: translateY(-50%); }
.seat--w { left: 8px; top: 50%; transform: translateY(-50%); }
.seat--ne { top: 12px; right: 8px; }
.seat--nw { top: 12px; left: 8px; }

.seat .who { font-weight: 700; font-size: .92rem; }
.seat .who .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--verde); margin-right: .35rem; }
.seat .who .dot.off { background: #6c5a49; }
.seat.turn .who { color: var(--fileteado); }
.seat.turn::before {
  content: ''; position: absolute; inset: -8px -6px; border: 1px solid var(--fileteado);
  border-radius: 10px; animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: .25; } 50% { opacity: .85; } }
.seat .meta { font-family: var(--mono); font-size: .66rem; letter-spacing: .1em; color: var(--hueso-dim); text-transform: uppercase; }
.seat .backs { display: flex; gap: .2rem; justify-content: center; margin-top: .3rem; }

.trick-area { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.trick-slots { display: flex; gap: .5rem; align-items: center; }
.trick-slots .played { position: relative; animation: drop .25s ease-out; }
.trick-slots .played .owner { font-family: var(--mono); font-size: .6rem; color: var(--hueso-dim); text-align: center; margin-top: .2rem; letter-spacing: .08em; }
@keyframes drop { from { transform: translateY(-26px) rotate(-6deg); opacity: 0; } to { transform: none; opacity: 1; } }

.tricks-done { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); display: flex; gap: .8rem; font-family: var(--mono); font-size: .66rem; color: var(--hueso-dim); }
.tricks-done b { color: var(--fileteado); }

.callout {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font-family: var(--display); font-size: clamp(1.6rem, 5vw, 3rem); color: var(--fileteado);
  text-shadow: 0 4px 18px rgba(0, 0, 0, .8); animation: shout .9s ease-out; pointer-events: none;
}
@keyframes shout { 0% { transform: translate(-50%, -50%) scale(.6); opacity: 0; } 25% { transform: translate(-50%, -50%) scale(1.08); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(1); opacity: 0; } }

/* ---------------------------------------------- signature : le trucómetro */
.trucometro {
  background: linear-gradient(160deg, #3a2a20, #241a15);
  border: 2px solid #4a3527; border-radius: 8px; padding: .9rem .8rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06), var(--shadow);
}
.trucometro h3 { font-family: var(--mono); font-size: .66rem; letter-spacing: .2em; text-transform: uppercase; color: var(--fileteado); margin-bottom: .7rem; }
.tm-team + .tm-team { margin-top: .9rem; padding-top: .8rem; border-top: 1px dashed rgba(239, 227, 204, .14); }
.tm-name { display: flex; justify-content: space-between; align-items: baseline; font-size: .86rem; font-weight: 700; }
.tm-name .pts { font-family: var(--mono); font-size: 1.35rem; color: var(--fileteado); }
.tm-holes { display: grid; grid-template-columns: repeat(15, 1fr); gap: 3px; margin-top: .45rem; }
.tm-holes.buenas { margin-top: 4px; }
.tm-hole { aspect-ratio: 1; border-radius: 50%; background: #150f0c; box-shadow: inset 0 1px 2px rgba(0, 0, 0, .9); }
.tm-hole.on { background: radial-gradient(circle at 35% 30%, #f4d38a, var(--fileteado)); box-shadow: 0 0 6px rgba(224, 165, 46, .6); }
.tm-hole.on.buena { background: radial-gradient(circle at 35% 30%, #ffd9d5, var(--sangre)); box-shadow: 0 0 6px rgba(168, 50, 42, .6); }
.tm-legend { display: flex; justify-content: space-between; font-family: var(--mono); font-size: .58rem; letter-spacing: .14em; text-transform: uppercase; color: var(--hueso-dim); margin-top: .25rem; }

/* ---------------------------------------------------------- actions/log */
.actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.actions .grouplabel { width: 100%; font-family: var(--mono); font-size: .62rem; letter-spacing: .16em; text-transform: uppercase; color: var(--hueso-dim); margin-top: .3rem; }

.log { height: 260px; overflow-y: auto; font-size: .84rem; padding-right: .4rem; }
.log p { margin: 0 0 .32rem; padding-left: .7rem; border-left: 2px solid rgba(239, 227, 204, .12); }
.log p.bet { border-left-color: var(--fileteado); color: #f4dcae; }
.log p.score { border-left-color: var(--verde); }
.log p.flor { border-left-color: var(--sangre); }
.log p.deal { border-left-color: var(--indigo); color: var(--hueso-dim); font-family: var(--mono); font-size: .76rem; }
.log p.reveal { color: var(--hueso-dim); font-family: var(--mono); font-size: .78rem; }
.log p.gameover { border-left-color: var(--fileteado); font-weight: 700; }

.chat { height: 150px; overflow-y: auto; font-size: .85rem; }
.chat p { margin: 0 0 .25rem; }
.chat b { color: var(--fileteado); }
.chat p.sys { color: var(--hueso-dim); font-style: italic; }

/* --------------------------------------------------------------- modale */
.modal-bg { position: fixed; inset: 0; background: rgba(10, 7, 5, .78); display: grid; place-items: center; z-index: 60; padding: 1rem; backdrop-filter: blur(3px); }
.modal { width: min(760px, 100%); max-height: 88vh; overflow-y: auto; background: linear-gradient(180deg, var(--madera-2), var(--madera)); border: 1px solid rgba(224, 165, 46, .35); border-radius: 10px; padding: 1.4rem; box-shadow: var(--shadow); }
.modal h2 { margin-bottom: .2rem; }

.toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); background: var(--madera-3); border: 1px solid var(--fileteado); color: var(--hueso); padding: .6rem 1rem; border-radius: var(--r); z-index: 90; box-shadow: var(--shadow); animation: rise .2s ease-out; max-width: 90vw; }
.toast.err { border-color: var(--sangre); }
@keyframes rise { from { transform: translate(-50%, 12px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* ------------------------------------------------------------- accueil */
.hero { display: grid; grid-template-columns: 1.15fr .85fr; gap: 2.4rem; align-items: center; padding: 1.5rem 0 2.4rem; }
.hero p.lead { font-size: 1.05rem; color: var(--hueso-dim); max-width: 46ch; }
.hero .fan { position: relative; height: 260px; }
.hero .fan .card { position: absolute; left: 50%; top: 20px; --cw: 128px; transform-origin: 50% 120%; }
.hero .fan .card:nth-child(1) { transform: translateX(-50%) rotate(-17deg); }
.hero .fan .card:nth-child(2) { transform: translateX(-50%) rotate(-1deg) translateY(-8px); }
.hero .fan .card:nth-child(3) { transform: translateX(-50%) rotate(15deg); }

.rule-pill { display: inline-block; font-family: var(--mono); font-size: .68rem; letter-spacing: .08em; padding: .16rem .5rem; border: 1px solid rgba(239, 227, 204, .2); border-radius: 999px; color: var(--hueso-dim); margin: 0 .25rem .3rem 0; }
.rule-pill.on { color: var(--fileteado); border-color: rgba(224, 165, 46, .5); }

.game-layout { display: grid; grid-template-columns: 230px 1fr 300px; gap: 1rem; align-items: start; }

@media (max-width: 1020px) {
  .game-layout { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1fr; }
  .hero .fan { display: none; }
}
@media (max-width: 620px) {
  .card { --cw: 66px; }
  .card--sm { --cw: 46px; }
  .seat { width: 130px; }
  .felt { min-height: 440px; }
  .nav { gap: .7rem; font-size: .82rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
