html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #08061b;
  color: #fff;
  font-family: system-ui, Arial, sans-serif;
}
*, *::before, *::after { box-sizing: border-box }

#landing-page, #restart-page, #pause-menu, #graphics-settings-menu {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(8, 6, 27, 0.95);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 100;
  text-align: center;
  padding: 20px;
  box-sizing: border-box;
}

#landing-page h1, #restart-page h2, #pause-menu h2, #graphics-settings-menu h2 {
  font-size: 3rem;
  color: #d6c9ff;
  text-shadow: 0 0 12px #6b5cff, 0 0 24px #6b5cff;
  margin-bottom: 30px;
}

#landing-page button, #restart-page button, #pause-menu button, #graphics-settings-menu button {
  background: linear-gradient(145deg,#3b2e6e,#2f254f);
  border: 2px solid #5a4690;
  color: #d6c9ff;
  padding: 15px 30px;
  font-size: 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  margin: 10px;
  min-width: 250px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.3);
  transition: background 0.2s, transform 0.1s;
}

#landing-page button:hover, #restart-page button:hover, #pause-menu button:hover, #graphics-settings-menu button:hover {
  background: linear-gradient(145deg,#52439a,#473b81);
}

#landing-page button:active, #restart-page button:active, #pause-menu button:active, #graphics-settings-menu button:active {
  transform: scale(0.95);
}

#landing-page button.disabled, #restart-page button.disabled {
  background: #2e2541;
  color: #786a9f;
  cursor: not-allowed;
  opacity: 0.6;
  pointer-events: none;
}

#landing-page button.breaking {
    pointer-events: none;
    animation: button-break 0.4s forwards ease-out;
}

@keyframes button-break {
    0% { transform: scale(0.95); opacity: 1; }
    30% { transform: scale(0.9); box-shadow: 0 0 0 3px rgba(255,255,255,0.7), inset 0 0 2px 1px #5a4690; }
    100% { transform: scale(1.3); opacity: 0; }
}

#finalScore {
    font-size: 1.8rem;
    color: #ccc;
    margin-bottom: 20px;
}

#graphics-settings-menu .setting-item {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 15px 0;
  font-size: 1.2rem;
  color: #c0b8dd;
  width: 100%;
  max-width: 400px;
}
#graphics-settings-menu .setting-item label {
  margin-right: 10px;
  flex-shrink: 0;
}
#graphics-settings-menu .setting-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-right: 5px;
  cursor: pointer;
}
#graphics-settings-menu .setting-item span {
    font-size: 0.9rem;
    color: #9d8dff;
    margin-left: 5px;
}

#grid, #restart-page, #pause-menu, #graphics-settings-menu {
  display: none;
}

#grid {
  grid-template-columns: auto 420px auto;
  height: 100%;
  width: 100%;
}

#pad {
  grid-column: 1;
  width: 100%;
  height: 100%;
  position: relative;
  background: #2e2541;
  border: 8px solid #4a3780;
  box-shadow: inset 0 4px 8px rgba(0,0,0,0.6), 0 4px 6px rgba(0,0,0,0.7);
  z-index: 10;
}
#pad::before {
  content:"";
  position:absolute; inset:8px;
  background:#241c3d;
  box-shadow: inset 0 0 0 4px rgba(76,58,144,0.8), inset 0 6px 8px rgba(0,0,0,0.5);
}

#game-container {
  grid-column: 2;
  background:#0a0625;
  display:flex; align-items:center; justify-content:center;
  position: relative;
}
#game {
  width:100%; height:100%; display:block;
}

#hud {
  grid-column: 3;
  width:100%; height:100%;
  position: relative;
  background:#2e2541;
  border:8px solid #4a3780;
  box-shadow: inset 0 4px 8px rgba(0,0,0,0.6), 0 4px 6px rgba(0,0,0,0.7);
  z-index:10;
}
#hud::before {
  content:"";
  position:absolute; inset:8px;
  background:#241c3d;
  box-shadow: inset 0 0 0 4px rgba(76,58,144,0.8), inset 0 6px 8px rgba(0,0,0,0.5);
}

.pbtn {
  position: absolute;
  width:  clamp(100px, 12vw, 250px);
  height: clamp(100px, 12vw, 250px);
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg,#3b2e6e,#2f254f);
  border: 4px solid #5a4690;
  border-radius: 22px;
  box-shadow: inset 0 2px 4px #0009, 0 3px 6px #000a;
  cursor: pointer;
  user-select: none;
  transition: .1s;
}
.pbtn:active {
  background: linear-gradient(145deg,#52439a,#473b81);
  transform: scale(.95);
}
.pbtn svg {
  width: 48%;
  fill: #d6c9ff;
}
#up    { top:12%;   left:50%; transform:translateX(-50%) rotate(45deg); }
#down  { bottom:12%;left:50%; transform:translateX(-50%) rotate(45deg); }
#left  { top:50%;   left:12%; transform:translateY(-50%) rotate(45deg); }
#right { top:50%;   right:12%;transform:translateY(-50%) rotate(45deg); }

#hudInner {
  position:absolute; inset:8px; padding:28px; overflow-y:auto;
  background:linear-gradient(#1a1533,#110e25);
  border:4px solid rgba(76,58,144,0.8);
  box-shadow:inset 0 6px 8px rgba(0,0,0,0.5);
  height: calc(100% - 16px);
  padding-bottom: 90px;
}
#hudInner h2 {
  margin:0 0 24px; text-align:center; font-size:2rem; color:#d6c9ff;
  text-shadow:0 0 12px #6b5cff,0 0 24px #6b5cff;
}
.label {
  font-size:1.1rem; margin:12px 0; text-transform:uppercase;
  letter-spacing:.5px; color:#9d8dff;
  text-shadow:0 0 8px #6b5cff,0 0 16px #6b5cff;
}
.barOuter {
  width:100%; height:28px; border:1px solid #888;
  border-radius:4px; overflow:hidden;
}
.barInner { height:100%; background:#e648a5 }

#lives { margin-bottom:12px }
#depth,#score, #wins-counter {
  margin-bottom:12px; font-size:2rem; color:#ddd;
  text-shadow:0 0 6px #6b5cff,0 0 12px #6b5cff;
}

#wins-counter {
    font-size: 1.5rem;
}

#lives span {
  display:inline-block; width:28px; height:28px; margin-right:8px;
  background:#e648a5;
  clip-path:polygon(50% 0,100% 40%,80% 100%,20% 100%,0 40%);
}

#pauseGameBtn {
    background: linear-gradient(145deg,#3b2e6e,#2f254f);
    border: 2px solid #5a4690;
    color: #d6c9ff;
    padding: 12px 24px;
    font-size: 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    transition: background 0.2s, transform 0.1s;
    position: absolute;
    bottom: 28px;
    left: 28px;
    width: calc(100% - 56px);
}
#pauseGameBtn:hover {
    background: linear-gradient(145deg,#52439a,#473b81);
}
#pauseGameBtn:active {
    transform: scale(0.95);
}

#mp-lobby{
  position:fixed; inset:0;
  background:rgba(8,6,27,.95);
  display:none; flex-direction:column;
  justify-content:center; align-items:center;
  z-index:100; text-align:center; padding:20px;
}
#mp-lobby h2{font-size:2.2rem;color:#d6c9ff;margin-bottom:22px}

#joinPane, #readyPane {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 550px;
    margin-bottom: 5px;
}

.join-actions-left {
  display: flex;
  flex-direction: column;
  margin-right: 6px;
}
.join-actions-left button {
  min-width: auto;
  width: 90px;
  padding: 8px 12px;
  font-size: 1rem;
  margin: 2px 0 !important;
}

#mp-lobby input{
  padding:10px 14px;font-size:1.1rem;border-radius:8px;
  border:2px solid #5a4690;background:#241c3d;color:#d6c9ff;
  width:230px;text-align:center;
  margin: 6px;
  height: 68px;
}
#mp-lobby button{
  background:linear-gradient(145deg,#3b2e6e,#2f254f);
  border:2px solid #5a4690;color:#d6c9ff;
  padding:12px 24px;font-size:1.1rem;border-radius:8px;
  cursor:pointer;margin:6px;min-width:120px;
}
#mp-lobby button:hover{background:linear-gradient(145deg,#52439a,#473b81)}
#mp-lobby button:active{transform:scale(.96)}

#host-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 10px 0;
}
#host-info p {
    margin: 0 0 8px 0;
    color: #c0b8dd;
    font-size: 1rem;
}
.code-container {
    display: flex;
    align-items: center;
    background: #241c3d;
    border: 2px solid #5a4690;
    border-radius: 8px;
    padding: 5px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.4);
}
#hostCode {
    padding: 5px 10px;
    font-size: 1.4rem;
    font-family: monospace;
    color: #9d8dff;
    margin: 0;
    user-select: text;
}
#copyCodeBtn {
    margin-left: 8px !important;
    padding: 8px 16px !important;
    font-size: 1rem !important;
    min-width: auto !important;
}

#mp-rematch-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(8, 6, 27, 0.95);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    text-align: center;
    padding: 20px;
}
#mp-rematch-page h2 {
    font-size: 3rem;
    color: #d6c9ff;
    text-shadow: 0 0 12px #6b5cff, 0 0 24px #6b5cff;
    margin-bottom: 20px;
}
#mp-rematch-page p {
    font-size: 1.5rem;
    color: #ccc;
    margin-bottom: 20px;
}
#mp-rematch-page button {
    background: linear-gradient(145deg,#3b2e6e,#2f254f);
    border: 2px solid #5a4690;
    color: #d6c9ff;
    padding: 15px 30px;
    font-size: 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    margin: 10px;
    min-width: 250px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    transition: background 0.2s, transform 0.1s;
}
#mp-rematch-page button:hover {
    background: linear-gradient(145deg,#52439a,#473b81);
}
#mp-rematch-page button:disabled {
    background: #2e2541;
    color: #786a9f;
    cursor: not-allowed;
}

@media (max-width: 699px) {
  #pad, #hud { display:none !important; }
  #grid {
    grid-template-columns:1fr !important;
   }
  #game-container {
    grid-column:1 !important;
  }
}

@media (max-width: 1024px) {
    #pad { display: none !important; }

    #grid {
        grid-template-columns: 1fr;
        position: relative;
    }
    #game-container {
        grid-column: 1;
    }
    #hud {
        position: absolute;
        top: 0;
        right: 0;
        width: 180px;
        height: 100%;
        background: rgba(8, 6, 27, 0.8);
        border: none;
        border-left: 3px solid #4a3780;
        box-shadow: -5px 0 15px rgba(0,0,0,0.4);
        grid-column: auto;
    }
    #hudInner {
        padding: 15px;
    }
    #hudInner h2 { font-size: 1.4rem; margin-bottom: 10px; }
    .label { font-size: 0.8rem; margin: 8px 0; }
    .barOuter { height: 18px; }
    #depth, #score { font-size: 1.3rem; margin-bottom: 8px; }
    #wins-counter { font-size: 1rem; margin-bottom: 8px; }
    #lives { margin-bottom: 8px; }
    #lives span { width: 18px; height: 18px; margin-right: 5px;}
    #pauseGameBtn { padding: 10px; font-size: 1rem; }
}

@media (orientation:portrait) and (max-width:1024px){
  body::before{
    content:"Please rotate your device";
    position:fixed; inset:0;
    background:rgba(0,0,0,0.9);
    display:flex;justify-content:center;align-items:center;
    font-size:1.8rem;
    z-index:999;
    color: white;
  }
  #grid, #landing-page, #restart-page, #pause-menu, #graphics-settings-menu, #mp-lobby {
     filter:blur(3px);
  }
}