@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Arabic:wght@400;600;700&display=swap');
:root{color-scheme:dark;--gold:#e9c98c;--ink:#f5f2e9;--quiet:#91aa9f}*{box-sizing:border-box}body{margin:0;background:radial-gradient(ellipse at top,#203b31,#091a15 80%);color:var(--ink);font-family:'Noto Sans Arabic',Tahoma,sans-serif}button,select{font:inherit;color:inherit;border:1px solid #ffffff25;background:#ffffff07;border-radius:10px;cursor:pointer;min-height:42px;padding:7px 14px}button:hover{border-color:var(--gold);background:#ffffff12}button:focus-visible,select:focus-visible{outline:3px solid var(--gold);outline-offset:3px}button:disabled{cursor:default;opacity:.45}button[hidden],[hidden]{display:none!important}main{max-width:1050px;margin:auto;padding:18px 22px}header{display:flex;align-items:center;gap:12px;margin-bottom:18px}header>div{flex:1}header small{font:9px monospace;letter-spacing:2.8px;color:var(--gold)}h1{font-size:28px;margin:3px 0;font-weight:700}h1 span{font-size:12px;font-weight:400;color:var(--quiet);margin-right:12px}header button{font-size:12px}#help{font-size:21px;padding:3px 15px}.scoreboard{display:grid;grid-template-columns:1fr auto 1fr;gap:24px;margin-bottom:16px;align-items:center}.scoreboard>div:not(.match){position:relative;display:grid;grid-template-columns:1fr auto;align-items:center;gap:5px 15px;background:#ffffff05;border:1px solid #ffffff13;border-radius:12px;padding:10px 16px}.scoreboard .active{border-color:#d6b47c8a!important;background:#a78b4810!important}.scoreboard span{font-size:13px}.scoreboard strong{font:32px Georgia,serif;color:var(--gold)}progress{width:100%;height:3px;grid-column:1/-1;accent-color:var(--gold);border:0;border-radius:5px;overflow:hidden}progress::-webkit-progress-bar{background:#ffffff12}progress::-webkit-progress-value{background:var(--gold)}.match{text-align:center;display:grid;gap:4px}.match span{font-size:11px;color:var(--quiet)}.match label{font-size:10px}.match select{min-height:30px;font-size:12px;padding:2px 4px;background:#132b22}.table{border:8px solid #4e392b;border-radius:30px;padding:15px 20px;background:radial-gradient(ellipse at 45% 20%,#2b5a44,#143b2c 75%);box-shadow:0 1px 0 #c49c60,inset 0 0 0 1px #c39b5b77,inset 0 0 55px #09241980,0 20px 50px #0005}.rival{text-align:center;font-size:11px;color:#c0d0c5}.rival b{font-weight:400;color:var(--quiet)}#ophand{display:flex;flex-wrap:wrap;justify-content:center;gap:4px;max-width:350px;margin:8px auto}#ophand i{width:13px;height:25px;background:linear-gradient(115deg,#f6eedb,#bfb092);border-radius:3px;border:1px solid #f8edce;box-shadow:0 2px 0 #8f8065,1px 3px 4px #0005}.status{text-align:center;font-size:12px;color:var(--gold);padding:7px 10px;min-height:35px;margin:6px auto;background:#071d1755;border-radius:20px;max-width:500px}.status.finished{background:#c4a36320;border:1px solid var(--gold);font-size:16px}.boardtools{display:flex;justify-content:space-between;align-items:center;font-size:11px;color:#aec3b6;margin-top:8px}.boardtools b{font:22px Georgia;color:var(--ink);padding:0 8px}.boardtools .scoring{color:var(--gold)}.boardtools button{font-size:11px;padding:2px 9px;min-height:32px;background:#08271d66}.boardtools>div{display:flex;gap:4px}#arena{height:clamp(270px,44vh,470px);position:relative;min-width:0;overflow:hidden}#board{width:100%;height:100%;display:block;touch-action:none;filter:drop-shadow(1px 3px 2px #0005)}#empty{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;flex-direction:column;pointer-events:none;color:#a7c2a73b;font-size:48px}#empty span{font-size:24px;text-align:center}#empty small{font-size:10px;color:#aac2b575}#ends{display:flex;justify-content:center;gap:8px;flex-wrap:wrap;min-height:30px;padding:4px}#ends span{font-size:10px;color:#9db6a6;background:#102e2366;padding:2px 9px;border-radius:20px}#ends b{color:#e9dfc9;margin-right:7px}#choice{border:1px solid #d9b77577;border-radius:12px;background:#122f26;padding:12px;text-align:center;margin:8px 0}#choice strong{font-size:12px}#choices{display:flex;justify-content:center;gap:8px;flex-wrap:wrap;margin:10px}#choices button{background:#d9b775;color:#1b3025;font-size:12px;font-weight:700}#cancel{font-size:11px;min-height:34px}.handbar{display:flex;justify-content:space-between;align-items:center;gap:10px;border-top:1px solid #ffffff16;margin-top:8px;padding-top:12px;font-size:12px}.handbar span{color:var(--quiet);font-weight:400}#draw{font-size:11px;min-height:38px}#draw:not(:disabled){color:#183326;background:linear-gradient(135deg,#efd8a3,#c39a54);border-color:#ffe0a1}#hand{display:flex;flex-wrap:wrap;gap:10px;justify-content:center;align-items:center;padding:20px 4px 14px;min-height:112px;background:linear-gradient(0deg,#08281c55,transparent);border-radius:0 0 16px 16px}.tile{position:relative;display:block;flex:none;border:0;padding:0;width:54px;height:103px;background:none!important;border-radius:9px;min-height:0;filter:drop-shadow(1px 4px 2px #0006);transition:transform .16s}.tile svg{width:100%;height:100%;display:block}.tile:disabled{opacity:1;filter:brightness(.86) drop-shadow(1px 3px 2px #0006)}.tile.playable:after{content:'';position:absolute;inset:0;border:1.5px solid #ffd700;border-radius:9px;pointer-events:none;box-shadow:none}.tile.playable:hover{transform:translateY(-4px);filter:drop-shadow(0 5px 4px rgba(0,0,0,0.35))}.tile.selected{transform:translateY(-12px);filter:drop-shadow(0 10px 8px rgba(0,0,0,0.45)) drop-shadow(0 3px 2px rgba(0,0,0,0.25))}.tile.selected:after{border:1.5px solid #ffd700;box-shadow:none}.actions{display:flex;justify-content:center;gap:8px;margin-top:8px;flex-wrap:wrap}.actions button{font-size:11px;min-height:36px}#next{background:var(--gold);color:#183b2c;font-weight:700}#notice{font-size:11px;text-align:center;color:var(--quiet);margin:13px 0;line-height:1.8}dialog{background:#15362b;color:var(--ink);border:1px solid #ae8c58;border-radius:20px;padding:24px;max-width:540px;max-height:85dvh;line-height:2;font-size:13px}dialog::backdrop{background:#000b}dialog a{color:var(--gold)}dialog h2{margin:0 0 14px}dialog button{color:var(--gold)}.sources{font-size:10px}@media(max-width:600px){main{padding:10px 8px}header{margin-bottom:10px;gap:7px}header small{font-size:8px;letter-spacing:1.8px}h1{font-size:23px}h1 span{font-size:10px;margin-right:5px}header button{padding:5px 10px;font-size:10px}.scoreboard{gap:9px;margin-bottom:10px}.scoreboard>div:not(.match){padding:7px 10px;gap:3px 6px}.scoreboard span{font-size:11px}.scoreboard strong{font-size:27px}.match span{font-size:10px}.table{padding:10px 10px;border-width:5px;border-radius:22px}#arena{height:clamp(280px,42dvh,390px)}.tile{width:43px;height:84px}#hand{gap:7px;min-height:106px;padding:15px 0 10px}.handbar{font-size:11px}.status{font-size:11px}.boardtools{font-size:10px}.boardtools button{min-height:34px}dialog{max-width:94vw;padding:20px}}@media(max-width:370px){.tile{width:38px;height:75px}#hand{gap:5px}h1 span{display:none}}@media(prefers-reduced-motion:reduce){.tile{transition:none}}@media(orientation:landscape) and (max-height:550px){#arena{height:300px}}
body{line-height:1.6}h1{line-height:1.4}@media(max-width:600px){#arena{height:clamp(220px,28dvh,280px)}header small{line-height:1.3}.rival{line-height:1.5}.scoreboard{margin-bottom:8px}#notice{margin:8px 0}.table{padding-top:8px}}
/* Seats and shared partnership scoring. */
.matchsettings{display:flex;justify-content:space-between;gap:12px;align-items:center;padding:5px 2px 12px;font-size:11px;color:var(--quiet)}.matchsettings label{display:flex;align-items:center;gap:7px}.matchsettings select{min-height:34px;padding:4px 8px;font-size:11px;background:#153126;color:var(--ink)}.scoreboard{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin-bottom:7px}.scoreboard[data-count="3"]{grid-template-columns:repeat(3,minmax(0,1fr))}.scoreboard .scorecard{min-width:0}.scoreboard .scorecard span{font-size:12px}#teamnote{font-size:10px;text-align:center;color:var(--quiet);margin:4px 0 12px}#rivals{display:flex;justify-content:center;gap:10px;direction:ltr;align-items:center;margin-bottom:7px}.seat{direction:rtl;text-align:center;border:1px solid #ffffff15;border-radius:11px;background:#0d2d2255;padding:7px 8px;flex:1;max-width:200px;min-width:0;color:#a9bfb0}.seat.playing{border-color:var(--gold);box-shadow:0 0 16px #d4b97b13;background:#c8a5640c}.seat.partner{border-top:2px solid #96cba8}.seatname b{display:block;font-size:11px;color:#e9e9dc;font-weight:600}.seatname small{font-size:9px;color:#8fae9a}.seat.partner .seatname b{color:#a9dfbc}.seat>span{display:block;font-size:9px;white-space:normal}.backs{display:flex;flex-wrap:wrap;justify-content:center;gap:3px;margin:5px auto;max-width:130px}.backs i{display:block;width:10px;height:20px;border-radius:2px;background:linear-gradient(115deg,#f5ebd3,#c0af8b);border:1px solid #eee1c4;box-shadow:0 2px 0 #938368}.table{padding-top:12px}@media(max-width:600px){.matchsettings{gap:7px;padding-bottom:9px;font-size:10px}.matchsettings label{gap:4px}.matchsettings select{font-size:10px;padding:4px;max-width:124px}.scoreboard{gap:7px}.scoreboard .scorecard span{font-size:10px}.scoreboard[data-count="3"] .scorecard{grid-template-columns:1fr;text-align:center;gap:1px;padding:5px}.scoreboard[data-count="3"] strong{font-size:23px}.scoreboard[data-count="3"] progress{grid-column:auto}#teamnote{font-size:9px;margin-bottom:8px}#rivals{gap:5px}.seat{padding:5px 3px}.seatname b{font-size:10px}.seatname small,.seat>span{font-size:8px}.backs{gap:2px}.backs i{width:8px;height:17px}.table{padding-top:9px}#arena{height:clamp(210px,27dvh,270px)}}
@media(max-width:600px){#hand{gap:5px}.tile{width:clamp(32px,10vw,43px);height:auto;aspect-ratio:46/88}}
/* On-board placement targets and pointer drag feedback. */
#hand .tile{touch-action:none;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;cursor:grab}#hand .tile:disabled{cursor:default}#hand .tile.selected{filter:drop-shadow(0 10px 8px rgba(0,0,0,0.45)) drop-shadow(0 3px 2px rgba(0,0,0,0.25));transform:translateY(-12px)}body.dragging-tile,body.dragging-tile *{cursor:grabbing!important;user-select:none!important}body.dragging-tile #hand .tile.selected{opacity:.38}.placement-preview{cursor:pointer;pointer-events:auto}.placement-preview>rect{fill:#e9cc8425;stroke:#f6d591;stroke-width:2;cursor:pointer;pointer-events:auto;stroke-dasharray:5 4;filter:drop-shadow(0 0 5px #eec36e);animation:placementGlow 1.5s ease-in-out infinite}.preview-face{opacity:.25}.placement-preview.drop-hot>rect{fill:#f4d89566;stroke:#fff0c1;stroke-width:3;stroke-dasharray:none}.placement-preview.drop-hot .preview-face{opacity:.75}#dropzones{position:absolute;inset:0;pointer-events:none;z-index:3}.dropzone{position:absolute;transform:translate(-50%,-50%);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:0;min-width:44px;min-height:44px;padding:2px 5px;border:1px solid #f4d799aa;border-radius:10px;color:#ffe6a8;background:#123c2ee8;box-shadow:0 0 12px #e2c47866;pointer-events:auto;line-height:1.1;touch-action:manipulation}.dropzone span{font-size:23px;line-height:1}.dropzone small{font-size:9px}.dropzone:hover,.dropzone.drop-hot{background:#ecd191;color:#173e2b;box-shadow:0 0 22px #f4d799aa;scale:1.08}.dropzone:focus-visible{outline:3px solid #fff3c7;outline-offset:3px}#drag-tile{position:fixed;z-index:1000;pointer-events:none;width:52px;height:100px;filter:drop-shadow(3px 10px 7px #0008);will-change:top,left,transform;opacity:.96}#drag-tile svg{width:100%;height:100%;display:block}#drag-tile.ready{filter:drop-shadow(0 0 13px #ffdc89)}#sound{font-size:10px;white-space:nowrap;padding:5px 9px}#sound[aria-pressed="false"]{color:var(--quiet)}#choice{padding:8px;margin:6px 0}#choice strong{font-size:10px}#choices{margin:6px;gap:6px}#choices button{font-size:10px;min-height:34px;padding:5px 10px}#cancel{font-size:10px;min-height:28px;padding:3px 9px}@keyframes placementGlow{50%{stroke-opacity:.6;fill-opacity:.6}}@media(prefers-reduced-motion:reduce){.placement-preview>rect{animation:none}}@media(max-width:600px){#arena{height:clamp(245px,32dvh,320px)}header{gap:5px}h1 span{display:none}#sound{font-size:9px;padding:5px 6px}header small{letter-spacing:1px;font-size:7px}}
/* Reserve the same small action row while selecting: the hand must not jump under a finger. */
#choice,#choice[hidden]{display:flex!important;align-items:center;justify-content:center;gap:5px;height:38px;min-height:38px;margin:0;padding:0;border:0;background:none}#choice[hidden]{visibility:hidden;pointer-events:none}#choice strong{display:none}#choices{margin:0;flex-wrap:nowrap;gap:4px}#choices button{min-height:30px;padding:4px 7px;font-size:9px}#cancel{min-height:30px;white-space:nowrap;font-size:9px;padding:4px 6px}
/* Shared materials keep board, hand, previews and drag tiles consistent. */
.tile-material{filter:var(--tile-filter,none)}
[data-tile-theme=ivory],[data-theme=ivory]{--tile-filter:none;--pip-fill:#171a19;--pip-shine:#343936}
[data-tile-theme=ocean],[data-theme=ocean]{--tile-filter:sepia(1) saturate(3) hue-rotate(155deg) brightness(.82);--pip-fill:#102632;--pip-shine:#355a68}
[data-tile-theme=rose],[data-theme=rose]{--tile-filter:sepia(.7) saturate(2) hue-rotate(305deg);--pip-fill:#391b2b;--pip-shine:#64364c}
[data-tile-theme=midnight],[data-theme=midnight]{--tile-filter:brightness(.23) saturate(.4);--pip-fill:#fff5de;--pip-shine:#ffffff}
#sound,#palette{width:40px;min-width:40px;height:40px;padding:9px;display:grid;place-items:center}#sound svg,#palette svg,#draw>svg{width:23px;height:23px}#draw{min-width:64px;min-height:44px;display:flex;align-items:center;justify-content:center;gap:8px;padding:8px 12px}.stock-count{font-size:12px;font-weight:700}header{gap:6px}.swatches{display:grid;grid-template-columns:repeat(4,1fr);gap:10px;margin:20px 0}.swatches button{display:grid;justify-items:center;gap:8px;padding:12px 7px}.swatches svg{width:46px;height:88px}.swatches [aria-pressed=true]{outline:2px solid #e9c374;background:#355648}#appearance{max-width:380px;width:calc(100% - 32px)}#appearance-close{width:100%}

/* Premium Purple-and-Gold 20-Second Turn Timer */
.turn-timer {
  position: relative;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin: 0 6px;
  z-index: 10;
  vertical-align: middle;
}
.turn-timer.hidden {
  display: none !important;
}
.turn-timer .timer-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.turn-timer .timer-bg {
  stroke: rgba(255, 255, 255, 0.15);
}
.turn-timer .timer-ring {
  stroke: var(--timer-color, #eab308);
  transition: stroke-dashoffset 0.08s linear, stroke 0.3s ease;
  filter: drop-shadow(0 0 4px var(--timer-glow, rgba(234, 179, 8, 0.4)));
}
.turn-timer .timer-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  font-weight: 800;
  color: var(--timer-color, #eab308);
  z-index: 1;
  line-height: 1;
  user-select: none;
}
.turn-timer.warning {
  --timer-color: #f97316;
  --timer-glow: rgba(249, 115, 22, 0.5);
}
.turn-timer.critical {
  --timer-color: #ef4444;
  --timer-glow: rgba(239, 68, 68, 0.75);
  animation: timer-pulse 0.5s infinite alternate ease-in-out;
}
@keyframes timer-pulse {
  from { transform: scale(1); }
  to { transform: scale(1.12); filter: drop-shadow(0 0 6px #ef4444); }
}
