/* Not Rummikub on phones: the workbench on felt, the rack on a wooden ledge. Dark first, light overrides last. */
body.g-notrummikub { font-family: "Avenir Next", "Inter", -apple-system, "Helvetica Neue", Arial, sans-serif; }
.rkp { position: relative; display: flex; flex-direction: column; gap: 8px; height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 80px); min-height: 500px; }
.rkp-top { display: flex; flex-direction: column; gap: 6px; flex: none; }

/* whose turn */
.rkp-turnbar { display: flex; align-items: center; gap: 10px; border-radius: 16px; padding: 7px 12px; min-height: 58px; }
.rkp-tbtext { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.rkp-turnbar.me { background: linear-gradient(120deg, #ffd60a, #ffb000); color: #1b1b1b; box-shadow: 0 8px 24px rgba(255,190,0,.42); animation: rkp-pop .35s cubic-bezier(.2,1.4,.4,1) both, rkp-throb 1.6s ease-in-out .4s infinite; }
.rkp-turnbar.me b { font-size: 26px; font-weight: 900; font-style: italic; letter-spacing: -.01em; line-height: 1; }
.rkp-turnbar.me span { font-size: 13.5px; font-weight: 700; margin-top: 2px; }
.rkp-turnbar.me:has(.rk-glass.urgent) { background: linear-gradient(120deg, #ff7a3d, #ff3b30); color: #fff; }
.rkp-turnbar.me .rk-glass.urgent b { color: #fff; }
.rkp-turnbar.idle { background: rgba(0,0,0,.3); color: var(--label-2); font-size: 15px; }
.rkp-turnbar.idle b { color: var(--text); }
.rkp-turnbar.idle small { font-size: 12px; }
@keyframes rkp-pop { from { transform: scale(.88); opacity: 0; } }
@keyframes rkp-throb { 50% { box-shadow: 0 8px 34px rgba(255,190,0,.7); } }
body.rkp-myturn::after { content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 15; box-shadow: inset 0 0 0 5px #ffc400, inset 0 0 50px rgba(255,196,0,.45); animation: rkp-frame 1.6s ease-in-out infinite; }
@keyframes rkp-frame { 50% { box-shadow: inset 0 0 0 7px #ffc400, inset 0 0 80px rgba(255,196,0,.6); } }
.rk-glass.ph { gap: 4px; }
.rk-glass.ph svg { width: 28px; height: 42px; filter: none; }
.rk-glass.ph b { font-size: 24px; min-width: 1.4em; text-align: right; }
.rkp-turnbar.me .rk-glass .bulb { fill: rgba(255,255,255,.45); stroke: rgba(60,40,0,.55); }
.rkp-turnbar.idle .rk-glass.ph svg { width: 22px; height: 33px; }
.rkp-turnbar.idle .rk-glass.ph b { font-size: 18px; }

/* the other players */
.rkp-opps { display: flex; gap: 6px; }
.rkp-opp { flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: 5px; background: rgba(0,0,0,.28); border-radius: 999px; padding: 3px 8px 3px 3px; font-size: 13px; font-weight: 700; border: 2px solid transparent; }
.rkp-opp.turn { border-color: #ffb800; }
.rkp-opp.last { border-color: #ff453a; animation: rkp-last 1s ease-in-out infinite; }
@keyframes rkp-last { 50% { box-shadow: 0 0 0 4px rgba(255,69,58,.3); } }
.rkp-opp .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rkp-opp .ct { display: inline-flex; align-items: center; gap: 3px; font-variant-numeric: tabular-nums; }
.rkp-opp .ct i { width: 9px; height: 12px; border-radius: 2px; background: #f6eedb; box-shadow: inset 0 -2px 0 #d8c59c; display: inline-block; }
.rkp-opp .in { font-size: 10px; font-weight: 900; letter-spacing: .08em; color: #30d158; }
.rkp-opp .w { font-size: 9px; color: #ffcf3f; letter-spacing: 1px; }

/* the workbench */
.rkp-bench { --rkw: 34px; --pc: #ffb800; position: relative; flex: 1; min-height: 0; overflow-y: auto; border-radius: 18px; background: rgba(0,0,0,.18); box-shadow: inset 0 2px 12px rgba(0,0,0,.28); padding: 6px; -webkit-overflow-scrolling: touch; }
.rkp-sets { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 14px 8px; padding-top: 8px; min-height: calc(100% - 8px); }
.rkp-set { position: relative; display: flex; gap: 3px; padding: 5px; border-radius: 11px; background: rgba(0,0,0,.2); box-shadow: inset 0 0 0 1px rgba(255,255,255,.06); transition: box-shadow .15s, background .15s, transform .15s; }
.rkp .rkt[data-t] { touch-action: none; cursor: grab; -webkit-touch-callout: none; }
.rkp-set .rkt.mine { box-shadow: inset 0 calc(var(--w) * -.075) 0 #d8c59c, 0 0 0 2px var(--pc), 0 0 10px color-mix(in srgb, var(--pc) 60%, transparent); }
.rkp-set .rkt.sel, .rkp-rack .rkt.sel { transform: translateY(-6px); box-shadow: 0 0 0 3px #0a84ff, 0 8px 16px rgba(0,0,0,.4); z-index: 2; }
.rkp-set .rkt.lifted, .rkp-rack .rkt.lifted { opacity: .25; }
.rkp-set.bad { background: rgba(255,69,58,.16); box-shadow: inset 0 0 0 2px #ff453a; }
.rkp-set.rejected { animation: rkp-shake .5s ease both; box-shadow: inset 0 0 0 3px #ff453a, 0 0 18px rgba(255,69,58,.55); }
@keyframes rkp-shake { 20% { transform: translateX(-8px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(2px); } }
.rkp-set.locked { opacity: .78; }
.rkp-set.locked .rkt { cursor: not-allowed; filter: saturate(.7); }
.rkp-set.target, .rkp-new.target { box-shadow: inset 0 0 0 2px rgba(10,132,255,.75); animation: rkp-target 1.2s ease-in-out infinite; }
@keyframes rkp-target { 50% { box-shadow: inset 0 0 0 2px rgba(10,132,255,.35); } }
.rkp-set.over, .rkp-new.over { background: rgba(10,132,255,.28); box-shadow: inset 0 0 0 3px #0a84ff; transform: scale(1.03); animation: none; }
.rkp-set.source { box-shadow: inset 0 0 0 2px rgba(255,255,255,.25); }
body.rkp-dragging .rkp-set:not(.locked):not(.source) { box-shadow: inset 0 0 0 2px rgba(10,132,255,.45); }
.rkp-tag { position: absolute; left: 50%; top: 0; transform: translate(-50%, -62%); z-index: 3; font-size: 11px; font-weight: 800; padding: 1px 8px; border-radius: 999px; white-space: nowrap; pointer-events: none; }
.rkp-tag.bad { background: #ff453a; color: #fff; }
.rkp-tag.ok { background: #30d158; color: #06240f; padding: 1px 6px; }
.rkp-lock { position: absolute; right: -6px; top: -9px; font-size: 12px; z-index: 3; pointer-events: none; }
.rkp-new { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; width: calc(var(--rkw) * 2 + 13px); height: calc(var(--rkw) * 1.36 + 10px); border-radius: 11px; border: 2px dashed rgba(255,255,255,.35); color: rgba(255,255,255,.75); font-weight: 800; cursor: pointer; transition: transform .15s, background .15s; }
.rkp-new b { font-size: calc(var(--rkw) * .55); line-height: 1; }
.rkp-new span { font-size: 11px; letter-spacing: .04em; }
.rkp-emptytable { width: 100%; text-align: center; color: rgba(255,255,255,.55); font-style: italic; padding: 30px 0; }

/* what to do, what is wrong, what is picked */
.rkp-tools { flex: none; min-height: 34px; display: flex; align-items: center; }
.rkp-status { width: 100%; display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; line-height: 1.25; color: var(--label-2); padding: 0 4px; }
.rkp-status.ok { color: #30d158; }
.rkp-status.warn { color: #ffb36b; }
.rkp-status.bad { color: #fff; background: #d92f26; border-radius: 12px; padding: 7px 10px; animation: rkp-shake .45s ease both; }
.rkp-status.quiet { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.rkp-meter { margin-left: auto; position: relative; flex: none; width: 92px; height: 22px; border-radius: 999px; background: rgba(255,255,255,.12); overflow: hidden; display: flex; align-items: center; justify-content: center; }
.rkp-meter i { position: absolute; left: 0; top: 0; bottom: 0; background: #ffb800; border-radius: inherit; transition: width .25s; }
.rkp-meter.ok i { background: #30d158; }
.rkp-meter b { position: relative; font-size: 12px; font-weight: 900; color: var(--text); font-variant-numeric: tabular-nums; }
.rkp-selline { width: 100%; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13.5px; }
.rkp-selline > span { flex: 1 1 100%; color: var(--text); font-weight: 600; }
.rkp-selline > span:only-of-type { flex-basis: auto; }
.rkp-mini { min-height: 36px; border: 0; border-radius: 10px; padding: 6px 11px; font-size: 13.5px; font-weight: 800; background: rgba(255,255,255,.14); color: var(--text); cursor: pointer; }
.rkp-mini:active { transform: scale(.96); }
.rkp-mini[data-op="cancel"] { margin-left: auto; }

/* the buttons */
.rkp-acts { flex: none; display: grid; grid-template-columns: 54px 54px 1fr 1fr; gap: 6px; }
.rkp-acts:empty { display: none; }
.rkp-acts .btn { min-height: 50px; padding: 6px 8px; font-size: 16px; font-weight: 800; border-radius: 13px; }
.rkp-b { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; font-size: 20px !important; line-height: 1; }
.rkp-b small { font-size: 10px; font-weight: 700; margin-top: 2px; opacity: .8; }
.rkp-done.primary { background: #30d158; color: #06240f; }
.rkp-draw.confirm { background: #ff453a; color: #fff; font-size: 14px !important; }

/* the rack */
.rkp-rackwrap { position: relative; flex: none; border-radius: 16px; padding: 6px 6px 8px; background: linear-gradient(180deg, #5a3a22 0%, #4a2f1b 100%); box-shadow: inset 0 2px 0 rgba(255,220,170,.2), 0 10px 24px rgba(0,0,0,.35); }
.rkp-rackwrap.over { box-shadow: inset 0 0 0 3px #0a84ff, 0 10px 24px rgba(0,0,0,.35); }
.rkp-rackhead { display: flex; align-items: center; gap: 8px; padding: 0 2px 6px; color: rgba(255,236,210,.85); font-size: 12px; font-weight: 700; }
.rkp-rackinfo { margin-left: auto; white-space: nowrap; }
.rkp-rackinfo b { color: #fff; }
.rkp-seg { display: inline-flex; background: rgba(0,0,0,.3); border-radius: 9px; padding: 2px; }
.rkp-seg button { white-space: nowrap; border: 0; background: transparent; color: rgba(255,236,210,.8); font-size: 12px; font-weight: 800; padding: 5px 10px; border-radius: 7px; min-height: 30px; display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.rkp-seg button.on { background: #f6eedb; color: #3a2414; }
.rkp-seg .sw { width: 12px; height: 12px; border-radius: 3px; background: conic-gradient(#1f1d1a 0 25%, #d3242c 0 50%, #1d5ec4 0 75%, #e07d00 0); display: inline-block; }
.rkp-rack { --rkw: 36px; display: flex; flex-direction: column; gap: 4px; }
.rkp-shelf { display: flex; gap: 3px; justify-content: center; min-height: calc(var(--rkw) * 1.36 + 6px); padding-bottom: 6px; border-bottom: 5px solid #2e1c0e; border-radius: 0 0 4px 4px; box-shadow: 0 1px 0 rgba(255,220,170,.15); }
.rkp-rack .rkt { transition: transform .15s; }
.rkp-rack .rkt.peeking { transform: translateY(-8px); z-index: 2; }
.rkp-rack .rkt.rk-in { animation: rkp-in .45s cubic-bezier(.2,1.3,.4,1) both; }
@keyframes rkp-in { from { transform: translateY(-60px) scale(1.2) rotate(-8deg); opacity: 0; } }
.rkp.waiting .rkp-rack { opacity: .85; }
.rkp-peek { position: absolute; left: 50%; bottom: calc(100% + 8px); z-index: 30; width: min(88vw, 340px); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; opacity: 0; transform: translate(-50%, 12px) scale(.96); transition: opacity .12s ease, transform .16s ease; }
.rkp-peek.on { opacity: 1; transform: translate(-50%, 0) scale(1); }
.rkp-peektile { --rkw: 96px; filter: drop-shadow(0 18px 30px rgba(0,0,0,.45)); }
.rkp-peekcap { background: #1c1c1e; color: var(--text); border-radius: 14px; padding: 8px 12px; font-size: 13px; line-height: 1.35; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.rkp-peekcap b { display: block; font-size: 15px; margin-bottom: 2px; }

/* the tile you are dragging */
.rkp-ghost { position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none; filter: drop-shadow(0 14px 18px rgba(0,0,0,.45)); will-change: transform; }

/* the end screens */
.rkp-standings { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 6px; }
.rkp-strow { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 999px; background: rgba(0,0,0,.22); font-weight: 700; }
.rkp-strow.win { box-shadow: inset 0 0 0 2px #ffcf3f; }
.rkp-strow .nm { flex: 1; text-align: left; }
.rkp-strow b { font-size: 18px; font-variant-numeric: tabular-nums; }
.rkp-strow .tot { min-width: 64px; text-align: right; font-size: 13px; color: var(--label-2); font-variant-numeric: tabular-nums; }
.rkp-rackempty { min-height: 120px; display: flex; align-items: center; justify-content: center; text-align: center; color: #ffe2b0; font-weight: 800; font-size: 16px; padding: 0 20px; }
.rkp-end .rkp-endtiles { display: flex; justify-content: center; --rkw: 40px; margin-bottom: 6px; }
.rkp-up { color: #30d158; } .rkp-down { color: #ff7a5c; }
.rkp-leftover { --rkw: 30px; display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; max-width: 340px; }

/* big moments on every phone */
.rkp-moment { --pc: #ffb800; position: fixed; inset: 0; z-index: 70; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; pointer-events: none; background: radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--pc) 45%, transparent), rgba(0,0,0,.55) 70%); animation: rkp-moment 2.6s ease both; }
.rkp-moment .big { display: flex; --rkw: 46px; animation: rkp-big .6s cubic-bezier(.2,1.5,.4,1) both; }
.rkp-moment .who { display: flex; align-items: center; gap: 10px; background: var(--pc); color: #fff; font-size: 18px; font-weight: 800; padding: 8px 18px 8px 8px; border-radius: 999px; max-width: 90vw; text-shadow: 0 1px 2px rgba(0,0,0,.35); }
@keyframes rkp-moment { 0% { opacity: 0; } 10% { opacity: 1; } 85% { opacity: 1; } 100% { opacity: 0; } }
@keyframes rkp-big { from { transform: scale(.4) rotate(-6deg); } }

/* ---- light theme ---- */
[data-theme="light"] .rkp-turnbar.idle { background: rgba(255,255,255,.8); box-shadow: 0 4px 14px rgba(30,70,45,.08); }
[data-theme="light"] .rkp-opp { background: rgba(255,255,255,.8); box-shadow: 0 2px 8px rgba(30,70,45,.07); }
[data-theme="light"] .rkp-opp.turn { border-color: #e9a400; }
[data-theme="light"] .rkp-opp .in { color: #15803d; }
[data-theme="light"] .rkp-opp .w { color: #b45309; }
[data-theme="light"] .rkp-opp .ct i { box-shadow: inset 0 -2px 0 #d8c59c, 0 0 0 1px rgba(0,0,0,.12); }
[data-theme="light"] .rkp-bench { background: rgba(255,255,255,.3); box-shadow: inset 0 2px 10px rgba(30,70,45,.12), inset 0 0 0 1px rgba(30,70,45,.08); }
[data-theme="light"] .rkp-set { background: rgba(30,80,50,.1); box-shadow: inset 0 0 0 1px rgba(30,80,50,.08); }
[data-theme="light"] .rkp-set.bad { background: rgba(255,69,58,.12); box-shadow: inset 0 0 0 2px #e5332a; }
[data-theme="light"] .rkp-new { border-color: rgba(30,80,50,.35); color: rgba(20,60,40,.75); }
[data-theme="light"] .rkp-emptytable { color: rgba(20,60,40,.5); }
[data-theme="light"] .rkp-status.ok { color: #15803d; }
[data-theme="light"] .rkp-status.warn { color: #b45309; }
[data-theme="light"] .rkp-meter { background: rgba(0,0,0,.08); }
[data-theme="light"] .rkp-mini { background: rgba(255,255,255,.9); box-shadow: 0 2px 6px rgba(30,70,45,.12); }
[data-theme="light"] .rkp-acts .btn:not(.primary):not(.confirm) { background: #fff; box-shadow: 0 4px 12px rgba(30,70,45,.12); }
[data-theme="light"] .rkp-done.primary { background: #1f9d4c; color: #fff; }
[data-theme="light"] .rkp-peekcap { background: #fff; box-shadow: 0 10px 30px rgba(30,40,80,.2); }
[data-theme="light"] .rkp-strow { background: rgba(255,255,255,.8); box-shadow: 0 2px 8px rgba(30,70,45,.08); }
[data-theme="light"] .rkp-strow.win { box-shadow: inset 0 0 0 2px #e9a400; }
[data-theme="light"] .rkp-up { color: #15803d; } [data-theme="light"] .rkp-down { color: #c2410c; }
