:root{
  --edge-gap:24px;
  --section-gap:12px;
  --dice-height:72px;
  --ui-height:96px;

  --btn-width:180px;
  --btn-height:44px;
  --btn-font:20px;

  --board-size:min(
    calc(100vw - var(--edge-gap) * 2),
    calc(100dvh - var(--edge-gap) * 2 - var(--dice-height) - var(--ui-height) - var(--section-gap) * 2)
  );
}

html,body{
  margin:0;
  min-height:100dvh;
}

body{
  background:#2c3e50;
  color:white;
  font-family:sans-serif;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:var(--section-gap);
  padding:var(--edge-gap);
  box-sizing:border-box;
  overflow:hidden;
}

#dicePanel{
  width:var(--board-size);
  height:var(--dice-height);
  display:grid;
  grid-template-columns:1fr auto 1fr;
  align-items:center;
  gap:10px;
}

.top-card{
  min-height:58px;
  padding:6px 10px;
  border-radius:12px;
  background:rgba(17,17,17,.72);
  box-sizing:border-box;
  display:flex;
  justify-content:center;
  align-items:center;
  text-align:center;
  font-weight:bold;
  line-height:1.15;
}

#turnPanel{
  font-size:clamp(16px, 3.6vw, 24px);
}

.rank-card{
  align-items:flex-start;
  flex-direction:column;
  font-size:12px;
  color:#ffffff;
}

#finishRanks{
  margin:3px 0 0 0;
  padding-left:18px;
  line-height:1.18;
}

#finishRanks li{
  white-space:nowrap;
}

.dice-face{
  width:58px;
  height:58px;
  background:#ffffff;
  color:#28143c;
  border-radius:12px;
  box-shadow:0 3px 10px rgba(0,0,0,.45);
  position:relative;
  font-size:30px;
  font-weight:bold;
  display:flex;
  justify-content:center;
  align-items:center;
}

.dice-face.rolling{
  transform:scale(1.06);
}

.dice-face.unknown{
  font-size:30px;
}

.pip{
  position:absolute;
  width:10px;
  height:10px;
  border-radius:50%;
  background:#28143c;
}

.pip.p1{ left:14px; top:14px; }
.pip.p2{ left:24px; top:14px; }
.pip.p3{ right:14px; top:14px; }
.pip.p4{ left:14px; top:24px; }
.pip.p5{ left:24px; top:24px; }
.pip.p6{ right:14px; top:24px; }
.pip.p7{ left:14px; bottom:14px; }
.pip.p8{ left:24px; bottom:14px; }
.pip.p9{ right:14px; bottom:14px; }

#game{
  width:var(--board-size);
  height:var(--board-size);
  position:relative;
  display:flex;
  justify-content:center;
  align-items:center;
  flex-shrink:0;
}

#board{
  width:100%;
  height:100%;
  border:0;
  background:transparent;
  display:block;
}

#pieces{
  position:absolute;
  inset:0;
  pointer-events:none;
}

.piece{
  position:absolute;
  width:4.8%;
  height:4.8%;
  border-radius:50%;
  border:2px solid currentColor;
  background:#ffffff;
  box-sizing:border-box;
  transform:translate(-50%,-50%);
  transition:left .2s linear, top .2s linear;
  box-shadow:0 2px 6px rgba(0,0,0,.55);
  pointer-events:auto;
  display:flex;
  justify-content:center;
  align-items:center;
  user-select:none;
}

.piece .plane-icon{
  width:62%;
  height:62%;
  display:block;
  transform-origin:center;
}

.piece .plane-icon svg{
  width:100%;
  height:100%;
  display:block;
  fill:currentColor;
}

.piece.selectable{
  cursor:pointer;
  transform:translate(-50%,-50%) scale(1.16);
  box-shadow:0 0 0 3px #ffffff, 0 4px 10px rgba(0,0,0,.65);
}

.piece.disabled{
  cursor:default;
}

.piece.finished{
  background:#28143c;
  color:#ffffff !important;
  border-color:#ffffff;
  font-size:18px;
  font-weight:bold;
}

#ui{
  width:var(--board-size);
  height:var(--ui-height);
  padding:0;
  text-align:center;
  box-sizing:border-box;
  display:flex;
  flex-direction:column;
  justify-content:flex-start;
  align-items:center;
  gap:10px;
}

#status{
  font-size:22px;
  line-height:1.2;
}

#rollBtn{
  width:var(--btn-width);
  height:var(--btn-height);
  font-size:var(--btn-font);
  cursor:pointer;
  border:0;
  border-radius:12px;
  background:#ffffff;
  color:#28143c;
  font-weight:bold;
  font-family:inherit;
}

#rollBtn:disabled{
  opacity:0.45;
  cursor:not-allowed;
}

#adminPanel:not([hidden]){
  margin-top:2px;
  display:flex;
  justify-content:center;
  gap:8px;
}

#adminStartBtn,
#adminTerminateBtn{
  height:34px;
  padding:0 16px;
  border:0;
  border-radius:10px;
  color:#28143c;
  font-weight:bold;
  font-family:inherit;
  cursor:pointer;
}

#adminStartBtn{
  background:#f2d648;
}

#adminTerminateBtn{
  background:#e55c5c;
}

#killStatsLayer{
  position:absolute;
  inset:0;
  pointer-events:none;
  z-index:3;
}

.kill-card{
  position:absolute;
  min-width:92px;
  padding:3px 6px;
  border-radius:8px;
  background:rgba(32,16,48,.78);
  color:#ffffff;
  font-size:10px;
  line-height:1.25;
  box-sizing:border-box;
}

.kill-card .kill-title{
  font-weight:bold;
  margin-bottom:2px;
  text-align:center;
}

.kill-card .kill-row{
  display:flex;
  align-items:center;
  gap:3px;
  white-space:nowrap;
}

.kill-plane{
  width:12px;
  height:12px;
  display:inline-block;
}

.kill-plane svg{
  width:100%;
  height:100%;
  display:block;
  fill:currentColor;
}

.kill-red{ right:2.5%; bottom:0.8%; }
.kill-yellow{ left:2.5%; bottom:0.8%; }
.kill-blue{ left:2.5%; top:0.8%; }
.kill-green{ right:2.5%; top:0.8%; }


@media (hover:none), (pointer:coarse), (any-pointer:coarse){
  :root{
    --edge-gap:14px;
    --section-gap:12px;
    --dice-height:70px;
    --ui-height:140px;

    --btn-width:min(300px, 76vw);
    --btn-height:68px;
    --btn-font:25px;
  }

  #status{
    font-size:23px;
  }

  #rollBtn{
    border-radius:16px;
    touch-action:manipulation;
  }

  #adminStartBtn,
  #adminTerminateBtn{
    height:40px;
    border-radius:12px;
  }

  .piece{
    width:5.8%;
    height:5.8%;
    border-width:2px;
  }

  .piece.finished{
    font-size:18px;
  }

  .dice-face{
    width:56px;
    height:56px;
  }

  .top-card{
    min-height:56px;
    padding:5px 6px;
  }

  .rank-card{
    font-size:10px;
  }

  #finishRanks{
    padding-left:14px;
  }

  .kill-card{
    min-width:78px;
    font-size:9px;
    padding:2px 4px;
  }

  .kill-plane{
    width:10px;
    height:10px;
  }
}
