/* ----- page split with fixed sidebars --------------------------------- */
body{
  display:flex;
  flex-direction:row;
  margin:0;
  background:#0b0c0d;
  color:#f5f6fa;
  font-family:"Segoe UI",Arial,sans-serif;
  height:100vh;
  overflow:hidden;
  min-width:800px; /* Minimum width to prevent crushing */
}

/* centred title bar ------------------------------------------------------ */
.header{
  position:absolute;
  top:20px;
  left:50%;
  transform:translateX(-50%);
  background:rgba(12,13,14,.85);
  padding:.5em 1.5em;
  border-radius:10px;
  font-size:1.75rem;
  letter-spacing:2px;
  box-shadow:0 2px 16px #000a;
  z-index:20;
  display:flex;
  align-items:center;
  gap:1.2em;
}

/* middle WebGL view ------------------------------------------------------ */
#three-canvas{
  flex:0 0 calc((100vw - 200px) * 0.65); /* 65% of space after 200px scoreboard */
  width:calc((100vw - 200px) * 0.65);
  height:100vh;
  display:block;
  background:#0b0c0d;
  min-width:400px; /* Minimum canvas width */
}

/* left-hand inventory sidebar ------------------------------------------- */
.piece-list{
  flex:0 0 calc((100vw - 200px) * 0.35); /* 35% of space after 200px scoreboard */
  width:calc((100vw - 200px) * 0.35);
  height:100vh;
  background:rgba(6, 7, 8, 0.98); /* darker than before */
  overflow-y:auto;
  box-shadow:0 2px 12px #0008;
  backdrop-filter:blur(4px);
  padding:0;
  z-index:15;
  display:flex;
  flex-direction:column;
  justify-content:center;
  align-items:center;
}

/* 8 × 8 grid ------------------------------------------------------------- */
.piece-grid{
  width:100%;
  max-width:95%;
  box-sizing:border-box;
  display:grid;
  grid-template-columns:repeat(8,1fr);
  gap:1px;
  justify-items:stretch;
  align-items:stretch;
  padding:1.5vw 1vw;
  background:none;
  border-radius:14px;
}

/* selectable thumbnail cell --------------------------------------------- */
.piece-item{
  width:100%;
  aspect-ratio:1/1;
  cursor:pointer;
  user-select:none;
  display:flex;
  align-items:center;
  justify-content:center;
  font-family:monospace;
  font-size:.95em;
  color:#e0e1e6;
  background:none;
  border:0;
  border-radius:6px;
  margin:0;
  transition:background .15s;
  position:relative;
  box-sizing:border-box;
}
.piece-item:hover    {background:#181a1b;}
.piece-item.selected {background:#00bfff33;border:2px solid #00bfff;box-sizing:border-box;}
.piece-item.empty    {background:none;border:1px solid #2222;pointer-events:none;}

/* thumbnail image -------------------------------------------------------- */
.piece-item img{
  width:100%;
  height:100%;
  object-fit:contain;
  pointer-events:none;
}

/* New Game button -------------------------------------------------------- */
.new-game-btn{
  font-size:1rem;
  padding:.4em 1.1em;
  margin-left:.5em;
  border:none;
  border-radius:7px;
  background:linear-gradient(90deg,#141618 60%,#181a1b 100%);
  color:#fff;
  box-shadow:0 1px 6px #0006;
  cursor:pointer;
  transition:background .2s,color .2s,box-shadow .2s;
}
.new-game-btn:hover,
.new-game-btn:focus{
  background:linear-gradient(90deg,#181a1b 60%,#141618 100%);
  color:#fff;
  box-shadow:0 2px 12px #000a;
  outline:none;
}

/* Options button --------------------------------------------------------- */
.options-btn{
  font-size:1.3rem;
  margin-left:.7em;
  background:none;
  border:none;
  color:#f5f6fa;
  cursor:pointer;
  border-radius:50%;
  width:2.2em;
  height:2.2em;
  display:flex;
  align-items:center;
  justify-content:center;
  transition:background .2s;
}
.options-btn:hover,
.options-btn:focus{
  background:#232323;
  outline:none;
}

/* Options modal ---------------------------------------------------------- */
.options-modal{
  position:fixed;
  top:0;left:0;right:0;bottom:0;
  background:rgba(0,0,0,.65);
  z-index:1000;
  display:flex;
  align-items:center;
  justify-content:center;
}
.options-content{
  background:#23272a;
  color:#f5f6fa;
  border-radius:12px;
  padding:2em 2.5em 1.5em 2.5em;
  box-shadow:0 4px 32px #000a;
  min-width:260px;
  display:flex;
  flex-direction:column;
  gap:1.2em;
  align-items:flex-start;
}
.options-content label{
  font-size:1.1em;
  cursor:pointer;
}
.close-options{
  align-self:flex-end;
  font-size:1em;
  padding:.3em 1.2em;
  border:none;
  border-radius:7px;
  background:#31363b;
  color:#f5f6fa;
  cursor:pointer;
  margin-top:.5em;
  transition:background .2s,color .2s;
}
.close-options:hover,
.close-options:focus{
  background:#f5f6fa;
  color:#23272a;
  outline:none;
}

/* -------------------------------------------------------------- */
/* NEW   🏆  scoreboard panel – right-hand overlay                */
/* -------------------------------------------------------------- */
.scoreboard{
  flex:0 0 200px; /* Fixed 200px width instead of responsive */
  width:200px;
  height:100vh;
  background:rgba(6, 7, 8, 0.98); /* match left menu, even darker */
  overflow-y:auto;
  box-shadow:0 2px 12px #0008;
  backdrop-filter:blur(4px);
  padding:4px; /* Reduced padding from 8px to 4px */
  z-index:15;
  display:flex;
  flex-direction:column;
  align-items:stretch;
  justify-content:flex-start;
}

.scoreboard-header{
  text-align:center;
  font-size:14px; /* Smaller font size */
  letter-spacing:1px;
  margin:8px 0 4px 0;
  color:#fff;
}

.score-summary{
  font-size:16px; /* Smaller font size */
  margin:0 0 12px 0;
  color:#fff;
  text-align:center;
  /* Remove background box styling */
}

.scored-sets-container{
  display:flex;
  flex-direction:column;
  gap:4px; /* Fixed pixel gap */
}

.scored-set{
  background:rgba(255,255,255,0.03);
  border-radius:6px;
  border:1px solid rgba(255,255,255,0.08);
  padding:4px;
  min-height:54px;
  display:flex;
  flex-direction:column;
  width:fit-content;
}

/* Cube sets need more height for two rows */
.scored-set.cube-set {
  min-height:74px;
}

.scored-set .player-name{
  font-weight:bold;
  color:#f5f6fa;
  font-size:11px; /* Smaller font size */
  margin-bottom:3px;
  line-height:1;
}

.scored-set .set-content{
  display:flex;
  align-items:center;
  min-height:36px;
  flex:1;
}

.scored-set .piece-thumbnails{
  display:flex;
  gap:2px;
}

.scored-set .piece-thumbnail{
  width:31px; /* 20% larger than 26px */
  height:31px;
  border-radius:3px;
  background:#222;
  box-shadow:0 1px 3px #0006;
  border:1px solid rgba(255,255,255,0.1);
}

.scored-set .points{
  font-weight:bold;
  color:#ffe066;
  font-size:12px;
  min-width:18px;
  text-align:left;
  margin-left:4px;
}

/* Cube layout for 2x2x2 scored sets ------------------------------------ */
.piece-thumbnails.cube-layout{
  flex-direction:column;
  gap:2px;
  align-items:flex-start;
}

.cube-row{
  display:flex;
  gap:1px;
}

/* Overlay for entering player name before connecting ------------------- */
.name-overlay{
  position:fixed;
  top:0;
  left:0;
  width:100%;
  height:100%;
  background:rgba(0,0,0,0.8);
  display:flex;
  align-items:center;
  justify-content:center;
  flex-direction:column;
  color:#fff;
  font-size:1.5em;
  z-index:2000;
}
.name-overlay input,
.name-overlay button{
  font-size:1em;
  padding:0.5em;
  margin:0.5em;
}

/* Netplay modal styles ------------------------------------------------- */
.netplay-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.netplay-content {
  background: rgba(12, 13, 14, 0.95);
  border: 2px solid #333;
  border-radius: 15px;
  padding: 2rem;
  max-width: 400px;
  width: 90%;
  text-align: center;
  color: #f5f6fa;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.netplay-content h2, .netplay-content h3 {
  margin-top: 0;
  color: #fff;
}

.netplay-content label {
  display: block;
  margin: 1rem 0;
  font-size: 1.1rem;
}

.netplay-content input {
  width: 100%;
  padding: 0.8rem;
  margin-top: 0.5rem;
  border: 2px solid #444;
  border-radius: 8px;
  background: rgba(20, 21, 22, 0.9);
  color: #fff;
  font-size: 1rem;
  box-sizing: border-box;
}

.netplay-content input:focus {
  outline: none;
  border-color: #2288ff;
}

.netplay-btn {
  background: linear-gradient(135deg, #2288ff, #1a6acc);
  color: white;
  border: none;
  padding: 0.8rem 1.5rem;
  margin: 0.5rem;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 120px;
}

.netplay-btn:hover {
  background: linear-gradient(135deg, #3399ff, #2277dd);
  transform: translateY(-1px);
}

.netplay-btn.cancel {
  background: linear-gradient(135deg, #666, #555);
}

.netplay-btn.cancel:hover {
  background: linear-gradient(135deg, #777, #666);
}

#room-code-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 1rem 0;
}

#room-code {
  font-family: 'Courier New', monospace;
  font-size: 2rem;
  font-weight: bold;
  letter-spacing: 4px;
  color: #ffff44;
  background: rgba(0, 0, 0, 0.3);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 2px solid #444;
}

#copy-code {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid #666;
  color: #fff;
  padding: 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
}

#copy-code:hover {
  background: rgba(255, 255, 255, 0.2);
}

.waiting {
  color: #ffaa00;
  font-style: italic;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.error {
  color: #ff6666;
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

/* -------------------------------------------------------------- */
/* Status bar styles (from status-bar.css) ---------------------- */
/* -------------------------------------------------------------- */
.status-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(24, 26, 27, 0.95);
  color: #f5f6fa;
  font-size: 1.1rem;
  padding: 0.7em 1.5em 0.7em 1.5em;
  text-align: center;
  letter-spacing: 1px;
  z-index: 30;
  border-top: 1px solid #2226;
  min-height: 2.2em;
  transition: background-color 0.3s ease, border-left 0.3s ease;
}

.skip-rotation-btn {
  position: absolute;
  right: 20px;
  bottom: 20px;
  background: linear-gradient(135deg, #ff6b35, #e55529);
  color: white;
  border: none;
  padding: 0.6em 1.2em;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 31;
  font-weight: 500;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.skip-rotation-btn:hover {
  background: linear-gradient(135deg, #ff7c4a, #f66a3c);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.skip-rotation-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}