:root {
  --teal: #800000; /* desktop color: maroon */
  --felt: #007000;
  --felt-dark: #005400;
  --gray: #c0c0c0;
  --navy: #000080;
  --taskbar: 30px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body {
  background: var(--teal);
  color: #000;
  font-family: "Pixelated MS Sans Serif", Arial, sans-serif;
  -webkit-user-select: none; user-select: none;
  touch-action: manipulation;
}
[hidden] { display: none !important; }

#desktop {
  position: fixed; inset: 0 0 env(safe-area-inset-bottom) 0;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}

/* ----- dialogs on the desktop ----- */
.screen { width: 100%; max-width: 340px; }
.window-body p { margin: 0 0 10px; line-height: 1.45; }
.buttons { display: flex; gap: 8px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.buttons button { min-width: 88px; min-height: 26px; }
button.default { outline: 1px dotted #000; outline-offset: -5px; }
.row-icon { display: flex; gap: 12px; align-items: flex-start; }
.row-icon p { flex: 1; }
.icon-warn, .icon-info {
  flex: none; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; font: bold 20px/1 Arial, sans-serif; color: #fff;
}
.icon-warn { background: #e6c300; color: #000; border-radius: 2px; clip-path: polygon(50% 0, 100% 100%, 0 100%); padding-top: 8px; }
.icon-info { background: #1060e0; border: 1px solid #000; font-family: Georgia, serif; font-style: italic; }
.icon-cam {
  flex: none; width: 36px; height: 26px; margin-top: 4px; background: #404040; border: 2px solid #000; border-radius: 4px; position: relative;
}
.icon-cam::after { content: ""; position: absolute; left: 9px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: #6ab0ff; border: 2px solid #000; }
.icon-camera { flex: none; width: 48px; height: 48px; }
.err { color: #a00000; }

.logo { display: flex; gap: 12px; align-items: center; margin: 4px 0 14px; }
.logo-die {
  display: block; width: 48px; height: 48px; border-radius: 9px; flex: none;
  background: url(/apple-touch-icon.png) center / cover; /* same image as the browser icon */
  border: 1px solid #000; box-shadow: inset 0 0 0 1px rgba(255,255,255,.15), 2px 2px 0 #000;
}
.logo-name { font-size: 20px; font-weight: bold; }
.logo-sub { color: #404040; margin-top: 2px; }
fieldset { padding: 10px; }
button.big {
  display: block; width: 100%; padding: 10px 12px; margin-bottom: 8px; text-align: left; font-weight: bold; font-size: 13px;
}
button.big:last-child { margin-bottom: 0; }
button.big small { display: block; font-weight: normal; color: #404040; font-size: 11px; margin-top: 3px; }
#link { width: 100%; height: 26px; font-size: 13px; background: #fff !important; color: #000 !important; -webkit-text-fill-color: #000; }
.expires { text-align: center; margin-top: 12px !important; }
#s-wait .progress-indicator { margin: 8px 0; }

/* ----- game window ----- */
#game {
  position: absolute; inset: 0; margin: auto;
  width: min(100%, 560px); height: 100%;
  display: flex; flex-direction: column;
}
#desktop:has(#game:not([hidden])) { padding: 0; }
@media (min-width: 700px) { #desktop:has(#game:not([hidden])) { padding: 12px; } #game { height: calc(100% - 24px); } }
#table-wrap { flex: 1; position: relative; margin: 3px; padding: 0; min-height: 0;
  box-shadow: inset -1px -1px #fff, inset 1px 1px #808080, inset -2px -2px #dfdfdf, inset 2px 2px #0a0a0a; padding: 2px; }
#table-wrap { overflow: hidden; }
#stage { position: absolute; inset: 2px; transform-origin: 0 0; transition: transform .45s cubic-bezier(.3,.1,.2,1); will-change: transform; }
#table { display: block; width: 100%; height: 100%; touch-action: none; background: var(--felt); }
.status-bar { flex: none; }
#st-msg { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#st-hp { flex: none; }

.dialog {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(290px, calc(100% - 24px)); z-index: 5;
}
.dialog .window-body { text-align: center; }
#choice { top: calc(50% + 64px); transform: translate(-50%, 0); }
.over-big { font-size: 22px; font-weight: bold; margin: 6px 0 8px !important; }
.note { color: #404040; min-height: 1em; margin-top: 10px !important; }

/* ----- webcam windows ----- */
.cam { position: fixed; z-index: 20; width: 104px; padding: 2px; touch-action: none; }
.cam .title-bar { cursor: grab; padding: 2px 3px; }
.cam .title-bar-text { font-size: 11px; }
.cam-body { position: relative; aspect-ratio: 3 / 4; background: #000; margin-top: 2px; overflow: hidden; }
.cam video { width: 100%; height: 100%; object-fit: cover; display: block; }
#v-me { transform: scaleX(-1); }
.cam-off { position: absolute; inset: 0; display: grid; place-items: center; color: #8f8; font-size: 10px; text-align: center; padding: 4px; }
#unmute { position: absolute; left: 4px; right: 4px; bottom: 4px; min-width: 0; font-size: 10px; padding: 2px; }
@media (min-width: 700px) { .cam { width: 168px; } }

/* ----- taskbar ----- */
#taskbar {
  position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--taskbar) + env(safe-area-inset-bottom));
  padding: 3px 3px calc(3px + env(safe-area-inset-bottom));
  background: var(--gray); box-shadow: inset 0 1px #dfdfdf, inset 0 2px #fff;
  display: flex; align-items: center; gap: 4px; z-index: 30;
}
.task { display: flex; align-items: center; gap: 6px; height: 24px; min-width: 0; padding: 0 8px; font-weight: bold; }
.task.active { box-shadow: inset -1px -1px #fff, inset 1px 1px #0a0a0a, inset -2px -2px #dfdfdf, inset 2px 2px #808080; background: #e0e0e0; }
.task-die { width: 16px; height: 16px; font-size: 11px; border-width: 1px; border-radius: 3px; box-shadow: none; }
.tray {
  margin-left: auto; height: 24px; padding: 0 10px; display: flex; align-items: center;
  box-shadow: inset -1px -1px #fff, inset 1px 1px #808080;
}

/* ----- 3D dice ----- */
#fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
#dice-layer { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 1; }
.die { position: absolute; left: 0; top: 0; width: var(--s); height: var(--s); perspective: calc(var(--s) * 7); will-change: transform; }
.die-shadow { position: absolute; inset: 6%; border-radius: 22%; background: rgba(0,0,0,.55); filter: blur(4px); }
.cube { position: absolute; inset: 0; transform-style: preserve-3d; will-change: transform; }
.core { position: absolute; inset: 4%; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.t-green .core { background: #178a35; }
.t-black .core { background: #0a0a0a; }
.k-shield .core { background: #2c3036; }
.k-jack .core { background: #3a1a6a; }
.f {
  position: absolute; inset: 0; border-radius: 13%;
  display: grid; place-items: center;
  transform-style: flat;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12), inset 0 calc(var(--s) * -.06) calc(var(--s) * .12) rgba(0,0,0,.45), inset 0 calc(var(--s) * .05) calc(var(--s) * .1) rgba(255,255,255,.15);
}

/* team colors (main + attack dice) */
.t-green .f { background: radial-gradient(circle at 30% 25%, #4fd06c, #1f9a3d 55%, #10642a); color: #fff; }
.t-black .f { background: radial-gradient(circle at 30% 25%, #3a3a3a, #121212 55%, #050505); color: #f2f2f2; }

/* main: normal dots */
.pips { width: 74%; height: 74%; display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); }
.pips b, .pips i { display: block; }
.pips b { width: 66%; aspect-ratio: 1; place-self: center; border-radius: 50%; background: #fff; box-shadow: inset 0 calc(var(--s) * .02) calc(var(--s) * .03) rgba(0,0,0,.45); }
.t-black .pips b { background: #f4f4f4; }

/* attack: -N / -N */
.k-attack .f { font-family: "Old Standard TT", Georgia, serif; font-weight: 700; }
.a1, .a2 { position: absolute; font-size: calc(var(--s) * .3); line-height: 1; text-shadow: 0 1px 0 rgba(0,0,0,.6); }
.a1 { left: 9%; top: 8%; }
.a2 { right: 9%; bottom: 8%; }
.slash { position: absolute; left: 50%; top: 14%; width: calc(var(--s) * .035); height: 72%; margin-left: calc(var(--s) * -.0175); background: currentColor; border-radius: 2px; transform: rotate(38deg); opacity: .95; }

/* shield: gunmetal + gold */
.k-shield .f { background: linear-gradient(135deg, #79818b 0%, #3b4148 30%, #23272c 55%, #4b525a 80%, #2a2e33 100%); }
.k-shield svg { width: 90%; height: 90%; }
.sh-num { font: 700 50px "Old Standard TT", Georgia, serif; }

/* jack: purple galaxy, numbers */
.k-jack .f {
  background:
    radial-gradient(circle at 50% 50%, rgba(10,0,30,.45), rgba(10,0,30,.1) 70%),
    url(/galaxy.jpg);
  background-size: 100% 100%, 260% 260%;
  color: #fff;
}
.k-jack .f:nth-child(1) { background-position: 0 0, 10% 15%; }
.k-jack .f:nth-child(2) { background-position: 0 0, 80% 20%; }
.k-jack .f:nth-child(3) { background-position: 0 0, 30% 75%; }
.k-jack .f:nth-child(4) { background-position: 0 0, 90% 85%; }
.k-jack .f:nth-child(5) { background-position: 0 0, 55% 45%; }
.k-jack .f:nth-child(6) { background-position: 0 0, 15% 95%; }
.jn { font: 700 calc(var(--s) * .62) "Old Standard TT", Georgia, serif; line-height: 1; text-shadow: 0 0 calc(var(--s) * .1) rgba(20,0,50,.95), 0 1px 2px rgba(0,0,0,.9); position: relative; z-index: 1; }
.jn.u { text-decoration: underline; text-decoration-thickness: calc(var(--s) * .04); text-underline-offset: calc(var(--s) * .04); }


/* messages: on each player's half, plus a big popup in the middle */
.feed {
  position: absolute; left: 50%; transform: translate(-50%, 0);
  z-index: 3; pointer-events: none; width: max-content; max-width: calc(100% - 24px);
  background: #ffffe1; color: #000; border: 1px solid #000; box-shadow: 2px 2px 0 rgba(0,0,0,.45);
  padding: 5px 9px; font-size: 12px; line-height: 1.5; text-align: center; white-space: pre-wrap;
}
.feed-me { transform: translate(0, -100%); border-left: 5px solid var(--me-team, #2fae4f); max-width: 58%; text-align: left; }
.feed-opp { transform: none; border-left: 5px solid var(--opp-team, #111); max-width: 58%; text-align: left; }
.feed-mid { transform: translate(-50%, -100%); }
.feed.big {
  background: #c0c0c0; font-size: 16px; font-weight: bold; padding: 8px 16px;
  box-shadow: inset -1px -1px #0a0a0a, inset 1px 1px #fff, inset -2px -2px #808080, inset 2px 2px #dfdfdf, 3px 3px 0 rgba(0,0,0,.4);
  border: none;
}
.feed.pop { animation: feedpop .2s ease-out; }
@keyframes feedpop { from { scale: .8; } to { scale: 1; } }

/* title bars: solid black, no gradient */
.title-bar, .title-bar.inactive { background: #000 !important; }

/* start of game: countdown, then the face-off */
.count-num { font-size: 44px; font-weight: bold; margin: 2px 0 8px !important; line-height: 1; }
#countdown .progress-indicator { margin-top: 4px; }
#faceoff {
  position: absolute; inset: 0; z-index: 6; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55); animation: fadein .35s ease-out;
}
.faceoff-win { width: min(78%, 340px); animation: faceoffpop .45s cubic-bezier(.2,1.4,.4,1); }
.faceoff-body { position: relative; aspect-ratio: 3 / 4; background: #000; margin-top: 2px; overflow: hidden; }
#v-face { width: 100%; height: 100%; object-fit: cover; display: block; }
#face-off-text { position: absolute; inset: 0; display: grid; place-items: center; color: #8f8; font-size: 22px; font-weight: bold; }
@keyframes fadein { from { opacity: .3; } to { opacity: 1; } }
@keyframes faceoffpop { from { transform: scale(.4); } to { transform: scale(1); } }

/* doubles */
.feed.big.blocked div:first-child { font-size: 26px; color: #a00000; letter-spacing: 2px; }
.feed.big.blocked div + div { font-size: 12px; font-weight: normal; }

/* videos stay invisible until they're actually playing (iPhone shows a play button on empty ones) */
.cam video, #v-face { visibility: hidden; }
.cam video.live, #v-face.live { visibility: visible; }
.cam-body, .faceoff-body { transition: aspect-ratio .2s; }
