:root{--felt:#123e5b;--felt-dark:#08273d;--felt-glow:#277898;--panel:#153e54;--sheet:#143c53;--text:#fff7e5;--muted:#c1d6dc;--gold:#ffd365;--gold-deep:#b98b28;--safe-l:env(safe-area-inset-left,0px);--safe-r:env(safe-area-inset-right,0px);--safe-t:env(safe-area-inset-top,0px);--safe-b:env(safe-area-inset-bottom,0px);--danger:#e7786c;--blue:#235da5;--tile:34px}
body{background:var(--felt-dark)}button{font:inherit}button:not(:disabled){cursor:pointer}.brand h1{font-family:Georgia,serif;letter-spacing:5px;color:#ffe6a3}.az-brand{display:flex;justify-content:center;gap:8px;margin:12px}.az-brand .az-tile{width:42px;height:42px}.field select{color-scheme:dark}.rules h4{color:var(--gold);margin-bottom:6px}.rules p{line-height:1.5}.table-link{display:block;text-align:center;margin:14px 0}#menu .btn{display:block;margin:8px 0;width:100%}
.az-tile{display:inline-grid;place-items:center;position:relative;width:var(--tile);height:var(--tile);border-radius:16%;border:1px solid #ffffff9c;box-shadow:inset 0 2px 2px #fff9,inset 0 -3px 2px #0004,0 2px 2px #0005;flex:none;vertical-align:middle;color:#fff;font-weight:900;font-size:calc(var(--tile)*.55)}
.t0{background:#175fbd;background-image:conic-gradient(from 45deg at 50% 50%,#8dccff44 0 25%,transparent 0 50%,#8dccff44 0 75%,transparent 0);border-color:#77b2eb}.t1{background:#f3bc22;background-image:repeating-conic-gradient(from 45deg,#fff3b588 0 25%,transparent 0 50%);background-size:70% 70%;border-color:#ffe58d}.t2{background:#c9383f;background-image:radial-gradient(ellipse at 0 0,#fda59488 0 35%,transparent 37%),radial-gradient(ellipse at 100% 100%,#fda59488 0 35%,transparent 37%);border-color:#f7a18d}.t3{background:#183f52;background-image:repeating-conic-gradient(#4fc0cf 0 25%,transparent 0 50%);background-size:50% 50%;border-color:#65b3bc}.t4{background:#f8efde;background-image:linear-gradient(45deg,transparent 44%,#3476b7 45% 55%,transparent 56%),linear-gradient(-45deg,transparent 44%,#3476b7 45% 55%,transparent 56%);border-color:#bac5d2}.t5{background:#f5dfb3;color:#173c59;border-color:#95723d}.az-tile.socket{background:#c5c9be55;border:1px dashed #72898588;box-shadow:inset 0 1px 2px #0002}.az-tile.ghost{opacity:.2;box-shadow:none}.az-tile::after{content:'';position:absolute;inset:3px;border-radius:12%;border:1px solid #ffffff28;pointer-events:none}
#table{position:absolute;inset:0;padding:8px max(8px,var(--safe-r,env(safe-area-inset-right))) max(8px,var(--safe-b,env(safe-area-inset-bottom))) max(8px,var(--safe-l,env(safe-area-inset-left)));display:grid;grid-template-columns:82px minmax(0,1fr) 244px;grid-template-rows:39px minmax(0,1fr);gap:6px;background:radial-gradient(ellipse at center,#24738b,#10364f 85%);--tile:min(42px,calc((100dvh - var(--safe-b,0px) - 155px)/6),calc((100vw - var(--safe-l,0px) - var(--safe-r,0px) - 398px)/11.5))}
#table.personal{grid-template-columns:82px minmax(0,1fr) 180px;--tile:min(54px,calc((100dvh - var(--safe-b,0px) - 155px)/6),calc((100vw - var(--safe-l,0px) - var(--safe-r,0px) - 320px)/11.5))}
.az-top{grid-column:1/-1;display:flex;justify-content:space-between;align-items:center;min-width:0}.az-top>b{font-size:18px;color:#ffe6a3}.az-tools{display:flex;gap:5px;align-items:center}.az-tools .icon-btn{width:34px;height:32px;font-size:20px}#turnLabel{font-size:15px}#players{grid-row:2;display:flex;flex-direction:column;gap:6px;overflow:auto;min-height:0}.player-card{padding:5px;border-radius:12px;border:1px solid var(--pc);background:#0b2a3bbf;color:var(--text);display:grid;justify-items:center;gap:2px;font-size:13px;min-width:0}.player-card.current{border:2px solid var(--gold);background:#315b65}.player-card .avatar{width:27px;height:27px;font-size:17px}.player-card b{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;width:100%}.player-card strong{font-size:19px}.player-card small{font-size:11px}
#boardArea{min-width:0;min-height:0;display:flex;justify-content:center;align-items:center}.board-paper{background:#f2e8cf;color:#153b54;border-radius:13px;border:3px solid #8aafbe;box-shadow:0 3px 12px #001c2a88;padding:8px;position:relative;max-width:100%}.board-paper::before{content:'';position:absolute;inset:2px;pointer-events:none;border:1px solid #b8a179;border-radius:9px}.board-heading{display:flex;justify-content:space-between;align-items:center;font-size:16px;margin-bottom:3px}.board-heading strong{font-size:23px;color:#1c5b86}.board-heading small{font-size:12px}.az-board{display:grid;grid-template-columns:auto auto;column-gap:calc(var(--tile)*.45);row-gap:3px}.board-labels{display:contents}.board-labels span{font-size:12px;font-weight:700;line-height:1.1}.board-labels span:first-child{text-align:right;padding-right:calc(var(--tile)*.5)}.az-lines{display:flex;flex-direction:column;gap:3px}.pattern-line{height:var(--tile);display:flex;align-items:center;gap:4px;padding:0;border:0;border-radius:6px;background:transparent;color:inherit}.pattern-line>b{width:15px;font-size:12px;font-weight:400}.pattern-line>span{display:flex;gap:3px;justify-content:flex-end;width:calc(var(--tile)*5 + 12px)}.pattern-line>i{font-style:normal;font-size:14px;width:13px}.az-wall{display:grid;grid-template-columns:repeat(5,var(--tile));gap:3px}.wall-space{padding:0;border:0;background:none;border-radius:6px;width:var(--tile);height:var(--tile)}.az-floor{grid-column:1/-1;display:flex;justify-content:flex-end;align-items:end;gap:5px;margin-top:3px;border-radius:6px;padding:2px;cursor:pointer}.az-floor>b{font-size:12px;flex:1}.floor-cell{display:flex;flex-direction:column;align-items:center;gap:2px}.floor-cell small{font-size:12px;font-weight:700}.floor-cell .az-tile{width:calc(var(--tile)*.8);height:calc(var(--tile)*.8)}.target{outline:2px solid #bb8b13;outline-offset:1px;background:#ffe28b55}.chosen{outline:3px solid #167b9c;background:#80d5e166}.az-footer{font-size:11px;text-align:center;margin:5px 0 0}
#actionArea{grid-column:3;grid-row:2;min-height:0;overflow:auto;display:flex;flex-direction:column;gap:6px}#marketArea{flex:1;min-height:125px}#prompt{font-size:15px;font-weight:700;color:#ffe6a3;line-height:1.3}#actions{display:flex;flex-wrap:wrap;gap:5px}#actions .btn{padding:7px 10px;font-size:14px;min-height:32px;flex:1}#held{display:flex;align-items:center;gap:7px;font-size:17px;font-weight:700}#held .az-tile{--tile:30px}#marketArea:empty{display:none}.factory-ring{position:relative;width:100%;height:100%;min-height:160px}.factory{position:absolute;left:var(--x);top:var(--y);transform:translate(-50%,-50%);border:2px solid #c3a96e;background:radial-gradient(circle,#f7f0d9 0 55%,#b8d5dc 58% 65%,#235d83 67% 70%,#f0e3b7 72%);border-radius:50%;width:61px;height:61px;display:grid;place-items:center;box-shadow:0 2px 4px #0006}.factory>div{display:grid;grid-template-columns:repeat(2,1fr);gap:2px}.factory button{padding:0;border:0;background:none}.factory .az-tile{--tile:20px}.factory-label{position:absolute;top:-9px;left:0;color:#d7e8ea;font-size:10px;line-height:1}.factory.empty{opacity:.32}.center-pool{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:95px;max-height:90px;text-align:center;padding:4px;background:#113951ee;border-radius:12px;border:1px solid #b9ccd666}.center-pool>b{display:block;font-size:11px}.center-pool>b .az-tile{--tile:17px}.center-pool>div{display:flex;flex-wrap:wrap;gap:3px;justify-content:center;margin-top:4px}.center-pool button{border:0;background:none;color:var(--text);display:flex;align-items:center;gap:1px;padding:1px}.center-pool button .az-tile{--tile:18px}.center-pool strong{font-size:11px}.center-pool small{font-size:10px}
.score-row{display:grid;grid-template-columns:1fr auto;gap:4px 12px;padding:10px;border-radius:10px;background:#ffffff10;margin:7px 0}.score-row>b{font-size:19px}.score-row>span{grid-column:1;font-size:15px;color:var(--muted)}.score-row>strong{grid-column:2;grid-row:1/3;font-size:28px;align-self:center}.score-row.winner{border:2px solid var(--gold)}#peekBody{display:flex;justify-content:center;--tile:40px}.sheet{max-height:calc(100dvh - 20px);overflow:auto}#roundBody p{font-size:15px}.pending-note{color:var(--gold)}#fx .flip>.az-tile{width:100%;height:100%}.az-final-dismiss{margin-top:12px}
@media(min-width:1400px) and (min-height:760px){#table{inset:50% auto auto 50%;transform:translate(-50%,-50%);width:min(1600px,96vw);height:min(900px,94vh);border-radius:22px;grid-template-columns:140px minmax(0,1fr) 380px;--tile:62px;padding:16px;grid-template-rows:50px 1fr}.player-card{font-size:20px;padding:12px}.player-card .avatar{width:42px;height:42px}.player-card strong{font-size:28px}.player-card small{font-size:15px}.factory{width:92px;height:92px}.factory .az-tile{--tile:31px}.factory-label{font-size:15px}.center-pool{width:155px;max-height:150px}.center-pool button .az-tile{--tile:30px}.center-pool strong,.center-pool>b{font-size:16px}#prompt{font-size:21px}#actions .btn{font-size:20px}#table.personal{grid-template-columns:140px minmax(0,1fr) 260px;--tile:68px}.board-heading{font-size:24px}.board-labels span{font-size:18px}.az-footer{font-size:15px}}
.t1{background-image:url('art/yellow.svg');background-size:100% 100%}.t2{background-image:url('art/red.svg');background-size:100% 100%}.t3{background-image:url('art/black.svg');background-size:100% 100%}.t4{background-image:url('art/white.svg');background-size:100% 100%}.brand .az-brand{padding:14px;background:linear-gradient(90deg,transparent,#e8d7a822,transparent)}.board-paper{border-color:#9ab8c2}.board-paper::before{border:2px dotted #a38c5299}
.icon-btn{display:inline-grid;place-items:center;flex:none;width:42px;height:40px;padding:5px;border:1px solid #bcd8e566;border-radius:11px;background:#0a2d4399;font-size:23px;color:#fff7e5}.icon-btn svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:2}
@media(max-height:500px){.board-paper{padding:6px;border-width:2px}.board-heading{margin-bottom:2px}.board-heading strong{font-size:20px}.az-footer{display:none}}
@media(max-height:500px){.player-card{grid-template-columns:24px minmax(0,1fr);grid-template-rows:13px 18px 10px;gap:1px 2px;padding:3px}.player-card .avatar{grid-column:1;grid-row:1/3;width:23px;height:23px;font-size:15px;align-self:center}.player-card b{grid-column:2;grid-row:1;font-size:11px;line-height:13px}.player-card strong{grid-column:2;grid-row:2;font-size:17px;line-height:18px}.player-card small{grid-column:1/-1;grid-row:3;font-size:10px;line-height:10px}}
@media(orientation:portrait){body:not(.az-table-display) .rotate{display:flex}}

.factory{left:clamp(31px,var(--x),calc(100% - 31px));top:clamp(31px,var(--y),calc(100% - 31px))}

/* Personal boards stay at the top; shared factories occupy a bottom strip.
   The dedicated Fire Table screen uses its own factory-ring layout. */
#table .player-card.mine{order:1;margin-top:auto}
#table.stacked{grid-template-columns:90px minmax(0,1fr);grid-template-rows:39px minmax(0,1fr) auto}
#table.stacked #players{grid-row:2/4}
#table.stacked #boardArea{align-items:flex-start}
#table.stacked #boardArea{grid-column:2;grid-row:2}
#decisions{display:contents}
#table.stacked #actionArea{grid-column:2;grid-row:3;display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:6px;overflow:visible}
#table.stacked #marketArea{grid-column:1/-1;height:max(58px,calc(var(--strip-factory) + 16px));min-height:0}
#table.stacked.personal #marketArea,#table.finished #marketArea{display:none}
#table.stacked #prompt{grid-column:2;grid-row:2;align-self:center}
#table.stacked #actions{grid-column:3;grid-row:2;align-self:center}
#table.stacked #held{grid-column:1;grid-row:2;align-self:center}
#table #held:empty,#table #actions:empty{display:none}
#table.stacked .factory-ring{display:grid;grid-template-columns:repeat(var(--factory-count),minmax(0,1fr)) var(--center-width);grid-template-rows:minmax(0,1fr);gap:4px;min-height:0;padding-top:12px;align-items:center;justify-items:center}
#table.stacked .factory{position:relative;left:auto;top:auto;transform:none;width:var(--strip-factory);height:var(--strip-factory)}
#table.stacked .factory .az-tile{--tile:clamp(13px,calc(var(--strip-factory)*.34),31px)}
#table.stacked .factory-label{font-size:11px;top:-10px}
#table.stacked .center-pool{position:static;transform:none;grid-column:auto;grid-row:auto;width:100%;max-height:100%;padding:2px;overflow:auto}
#table.stacked .center-pool>div{gap:2px;margin-top:2px}
#table.stacked .center-pool>b,#table.stacked .center-pool strong{font-size:11px;line-height:1.1}
#table.stacked .center-pool button{padding:0}
#table.stacked .center-pool>b .az-tile{--tile:12px}
#table.stacked .center-pool button .az-tile{--tile:clamp(16px,calc(var(--strip-factory)*.4),26px)}
#table.finished #prompt{text-align:center}
@media(max-height:500px){#table.stacked{grid-template-columns:82px minmax(0,1fr)}#table.stacked #held .az-tile{--tile:23px}#table.stacked #prompt{font-size:13px}#table.stacked #actions .btn{padding:5px 8px;min-height:30px;font-size:13px}}
/* Short phones: put tools and decisions beside the board, freeing its full
   height above the factory strip. The board starts at the top safe edge. */
@media(max-height:500px){
 #table.stacked{grid-template-columns:82px minmax(0,1fr) 142px;grid-template-rows:minmax(0,1fr) auto}
 #table.stacked #players{grid-row:1/3}
 #table.stacked #boardArea{grid-column:2;grid-row:1}
 #table.stacked .az-top{grid-column:3;grid-row:1;align-self:start;flex-direction:column;align-items:stretch;justify-content:flex-start;gap:5px}
 #table.stacked .az-top>b{font-size:17px;letter-spacing:0}
 #table.stacked .az-tools{display:grid;grid-template-columns:repeat(3,34px);justify-content:end;gap:4px}
 #table.stacked #turnLabel{grid-column:1/-1;order:1;font-size:13px;overflow-wrap:anywhere}
 #table.stacked #actionArea{display:contents}
 #table.stacked #marketArea{grid-column:2/4;grid-row:2}
 #table.stacked #decisions{display:flex;flex-direction:column;gap:5px;grid-column:3;grid-row:1;align-self:end;min-width:0}
 #table.stacked #actions{flex-direction:column;width:100%}
 #table.stacked #actions .btn{width:100%;flex:none}
 #table.stacked .board-paper{padding:4px}
 #table.stacked .board-heading{line-height:1.1}
 #table.stacked .board-heading strong{font-size:17px}
 #table.stacked .board-heading small{font-size:11px}
 #table.stacked .board-labels span{font-size:11px}
 #table.stacked .az-floor{padding:1px;gap:3px;margin-top:1px}
 #table.stacked .floor-cell small{font-size:10px}
}
@media(min-height:600px){#table .board-heading{font-size:clamp(18px,2vw,26px)}#table .board-heading strong{font-size:clamp(26px,3vw,38px)}#table .board-heading small,#table .board-labels span,#table .az-floor>b,#table .floor-cell small,#table .pattern-line>b{font-size:clamp(14px,1.4vw,19px)}#table .az-footer{font-size:clamp(13px,1.25vw,17px)}}

/* Give short-phone factory tiles more space by parking the centre pool in the
   control margin. The title/tools use the gap between the player boxes. */
@media(max-height:500px){
 #table.stacked{grid-template-columns:82px minmax(0,1fr) 88px}
 #table.stacked #marketArea{height:calc(var(--strip-factory) + 2px)}
 #table.stacked .factory-ring{position:static;grid-template-columns:repeat(var(--factory-count),minmax(0,1fr));padding-top:0}
 #table.stacked .factory-label{top:1px;left:1px;background:#15435cdd;color:white;border-radius:3px;padding:1px 2px;font-size:9px}
 #table.stacked .center-pool{position:absolute;left:auto;top:auto;right:max(8px,var(--safe-r));bottom:calc(max(8px,var(--safe-b)) + var(--strip-factory) + 8px);width:88px;max-height:100px}
 #table.stacked .center-pool button .az-tile{--tile:18px}
 #table.stacked #decisions{align-self:start}
 #table.stacked #held{font-size:14px;gap:3px}
 #table.stacked #prompt{font-size:12px}
 #table.stacked #actions .btn{font-size:12px;padding:5px 3px}
 #table.stacked .az-top{flex:none;align-self:stretch;gap:3px;padding-top:3px}
 #table.stacked .az-top>b{font-size:13px;text-align:center}
 #table.stacked .az-tools{display:flex;flex-wrap:wrap;gap:3px;justify-content:center}
 #table.stacked .az-tools .icon-btn{height:28px}
 #table.stacked #turnLabel{flex:0 0 100%;font-size:11px;line-height:1.15;text-align:center}
 #table.stacked .player-card{grid-template-rows:12px 17px 9px;gap:0 2px;padding:2px 3px}
 #table.stacked #players{gap:3px}
 #table.stacked #players>.az-top{order:1}
 #table.stacked #players>.mine{order:2}
}
@media(max-height:350px){#table.stacked .board-labels{display:none}}

.score-row .final-breakdown{display:grid;gap:3px;min-width:0}
.final-breakdown>span{display:flex;justify-content:space-between;gap:16px;font-size:14px}
.final-breakdown>span b{color:var(--text);white-space:nowrap}
.final-breakdown>span:last-child{border-top:1px solid #b9d4db40;padding-top:3px}

/* Touch gestures never scroll the factory strip; taps and keyboard still work.
   These overlays are fixed on the body so desktop table transforms cannot
   offset the pointer or stretch a flying square into a rectangle. */
.az-draggable{touch-action:none;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;cursor:grab}
.az-dragging,.az-dragging .az-draggable{cursor:grabbing}
.az-drag-ghost,.az-drag-flights{position:fixed;z-index:9000;pointer-events:none}
.az-drag-ghost{width:max-content;max-width:220px;padding:7px 9px;border:2px solid #f4cf65;border-radius:10px;background:#113b50f5;color:#fff9e5;box-shadow:0 5px 18px #0008;font:600 13px/1.25 system-ui,sans-serif}
.az-drag-pieces{display:flex;align-items:center;gap:3px;flex-wrap:wrap;max-width:195px}
.az-drag-pieces .az-tile{--tile:25px;flex:none}
.az-drag-pieces strong{font-size:17px;margin:0 3px}
.az-drag-hint{max-width:195px;margin-top:5px}
.az-drag-ghost.invalid{border-color:#ff9e8e}
#boardArea .drag-preview-tile{outline:2px dashed #065d83;outline-offset:-3px;opacity:.72}
#boardArea .drag-drop-valid{outline:3px solid #187243;outline-offset:1px;background:#67ca7940}
#boardArea .drag-drop-invalid{outline:2px solid #a93828;outline-offset:1px;background:#e8907c40}
.az-drag-flights{inset:0;overflow:hidden}
.az-drag-flights .fly{position:absolute;left:0;top:0}
.az-drag-flights .flip,.az-drag-flights .flip>.az-tile{width:100%;height:100%}
