/* =========================
RESET
========================= */

*{
  margin:0;
  padding:0;
  box-sizing:border-box;
  -webkit-tap-highlight-color:transparent;
}

html,
body{
  width:100%;
  height:100%;
  overflow:hidden;

  background:#050816;
  font-family:Arial,sans-serif;

  touch-action:none;
}

/* =========================
AUTO LANDSCAPE SYSTEM
========================= */

body{
  position:fixed;
  inset:0;
}

body.game-started{

  display:flex;
  justify-content:center;
  align-items:center;

  width:100vw;
  height:100vh;

  overflow:hidden;
}

/* AUTO ROTATE HP PORTRAIT */
@media screen and (max-width:900px)
and (orientation:portrait){

  body.game-started{

    width:100vh;
    height:100vw;

    position:fixed;

    left:50%;
    top:50%;

    transform:
      translate(-50%,-50%)
      rotate(90deg);

    transform-origin:center center;
  }

  #outer{

    width:100vh !important;
    height:100vw !important;
  }

  #mobile-controls{

    width:100vh;
    height:100vw;
  }
}

/* =========================
SETUP SCREEN
========================= */

#setup-screen{
  position:fixed;
  inset:0;

  display:flex;
  justify-content:center;
  align-items:center;

  background:#050816;

  z-index:999999;

  padding:20px;
}

.setup-box{

  width:min(430px,100%);

  background:#111827;

  padding:30px;

  border-radius:24px;

  border:2px solid #00d4ff;

  box-shadow:
    0 0 40px rgba(0,212,255,.25);
}

.setup-box h1{

  text-align:center;

  color:#00d4ff;

  margin-bottom:25px;

  font-size:34px;
}

.player-form{
  margin-bottom:20px;
}

.player-form h2{

  margin-bottom:10px;

  font-size:20px;

  color:white;
}

.player-form input,
.player-form select{

  width:100%;

  padding:14px;

  border:none;

  border-radius:14px;

  background:#1f2937;

  color:white;

  font-size:16px;

  outline:none;
}

.player-form input{
  margin-bottom:10px;
}

#start-btn,
#restart-btn{

  width:100%;

  padding:15px;

  border:none;

  border-radius:14px;

  background:#00d4ff;

  color:black;

  font-size:18px;

  font-weight:bold;

  cursor:pointer;

  transition:.2s;
}

#start-btn:active,
#restart-btn:active{

  transform:scale(.96);
}

/* =========================
MAIN LAYOUT
========================= */

#outer{

  width:100vw;
  height:100vh;

  display:flex;
  justify-content:center;
  align-items:center;

  gap:14px;

  padding:12px;
}

/* =========================
PLAYER PANEL
========================= */

.stat-panel{

  width:110px;

  background:#111827;

  border-radius:18px;

  padding:15px;

  text-align:center;

  border:
    1px solid rgba(255,255,255,.08);

  flex-shrink:0;
}

.stat-name{

  font-size:16px;
  font-weight:bold;

  margin-bottom:10px;

  color:white;

  word-break:break-word;
}

.stat-score{

  font-size:56px;
  font-weight:bold;

  color:#00d4ff;
}

/* =========================
ARENA
========================= */

#arena{

  position:relative;

  display:flex;
  justify-content:center;
  align-items:center;
}

canvas{

  width:min(78vw,1200px);
  height:auto;

  aspect-ratio:760/520;

  background:#0a0f1f;

  border:3px solid #00d4ff;

  border-radius:24px;

  box-shadow:
    0 0 50px rgba(0,212,255,.3);
}

/* =========================
COUNTDOWN
========================= */

#countdown{

  position:absolute;

  left:50%;
  top:50%;

  transform:translate(-50%,-50%);

  font-size:130px;
  font-weight:bold;

  color:white;

  text-shadow:
    0 0 30px #00d4ff;

  pointer-events:none;

  z-index:50;
}

/* =========================
GAME OVER
========================= */

#gameover{

  position:fixed;
  inset:0;

  background:rgba(0,0,0,.85);

  display:none;
  justify-content:center;
  align-items:center;

  z-index:999999;
}

.gameover-box{

  width:min(520px,92vw);

  background:#111827;

  padding:45px;

  border-radius:26px;

  border:2px solid #00d4ff;

  text-align:center;

  animation:popWinner .4s ease;
}

.gameover-box h1{

  font-size:clamp(34px,5vw,60px);

  color:#00d4ff;

  margin-bottom:20px;
}

.gameover-box h2{

  font-size:clamp(28px,4vw,42px);

  color:white;

  margin-bottom:25px;
}

/* =========================
MOBILE ANALOG
========================= */

#mobile-controls{

  position:fixed;
  inset:0;

  pointer-events:none;

  z-index:99999;
}

.analog-wrap{

  position:absolute;

  bottom:18px;

  width:170px;
  height:170px;

  pointer-events:auto;

  display:flex;
  justify-content:center;
  align-items:center;
}

.left-wrap{
  left:18px;
}

.right-wrap{
  right:18px;
}

.analog{

  width:170px;
  height:170px;

  border-radius:50%;

  position:relative;

  overflow:hidden;

  touch-action:none;

  background:
    radial-gradient(
      circle at center,
      rgba(255,255,255,.08),
      rgba(255,255,255,.02)
    );

  border:
    3px solid rgba(255,255,255,.14);

  backdrop-filter:blur(8px);

  box-shadow:
    inset 0 0 25px rgba(255,255,255,.05),
    0 0 25px rgba(0,0,0,.45);
}

.analog::before{

  content:"";

  position:absolute;

  inset:18px;

  border-radius:50%;

  border:
    2px solid rgba(255,255,255,.06);
}

.analog-stick{

  width:72px;
  height:72px;

  position:absolute;

  left:50%;
  top:50%;

  transform:
    translate(-50%,-50%);

  border-radius:50%;

  transition:
    transform .03s linear;

  background:
    radial-gradient(
      circle at 35% 35%,
      rgba(255,255,255,.65),
      rgba(255,255,255,.12)
    );

  border:
    2px solid rgba(255,255,255,.2);

  box-shadow:
    0 0 25px rgba(0,212,255,.7),
    inset 0 0 14px rgba(255,255,255,.15);
}

.right-wrap .analog-stick{

  box-shadow:
    0 0 25px rgba(255,77,109,.7),
    inset 0 0 14px rgba(255,255,255,.15);
}

/* =========================
WIN EFFECT
========================= */

.winner-flash{
  animation:flashWin .3s infinite;
}

@keyframes flashWin{

  0%{
    background:#050816;
  }

  50%{
    background:#220033;
  }

  100%{
    background:#050816;
  }
}

@keyframes popWinner{

  0%{
    transform:scale(.5);
    opacity:0;
  }

  100%{
    transform:scale(1);
    opacity:1;
  }
}

/* =========================
TABLET
========================= */

@media(max-width:1000px){

  .stat-panel{

    width:82px;
    padding:10px;
  }

  .stat-name{
    font-size:11px;
  }

  .stat-score{
    font-size:34px;
  }

  canvas{
    width:72vw;
  }

  .analog-wrap{
    width:145px;
    height:145px;
  }

  .analog{
    width:145px;
    height:145px;
  }

  .analog-stick{
    width:62px;
    height:62px;
  }
}

/* =========================
PHONE
========================= */

@media(max-width:800px){

  #outer{
    gap:8px;
    padding:6px;
  }

  canvas{
    width:72vh;
  }

  .analog-wrap{
    bottom:10px;
  }

  .left-wrap{
    left:10px;
  }

  .right-wrap{
    right:10px;
  }

  #countdown{
    font-size:90px;
  }
}

/* =========================
DESKTOP
========================= */

@media(min-width:1000px){

  #mobile-controls{
    display:none;
  }
}