body{
font-family:system-ui,-apple-system,Segoe UI,Roboto;
margin:0;
background:#1c1f26;
color:white;
text-align:center;
min-height:100dvh;
}

html,
body{
width:100%;
height:100%;
overflow-x:hidden;
}

body.light{
background:#eef1f6;
color:#111;
}

body.light header{
background:#ffffff;
}

body.light th,
body.light td{
background:#ffffff;
color:#111;
}

body.light .player-name{
background:#e5e9f0;
}

body.light .overlay-content{
background:#ffffff;
}

body.light .modal-content{
background:#ffffff;
color:#111;
}

body.light input{
background:#ffffff;
color:#111;
}

body.light .player-card{
background:#ffffff;
}

body.light .titel{
background:none;
-webkit-text-fill-color:#111;

text-shadow:
0 0 6px rgba(255,0,0,0.5),
0 0 8px rgba(255,0,0,0.35),
0 0 14px rgba(255,0,0,0.2);
}


body.light .start-lobby-btn{
color:#333;
border-color:#22c55e;
}

body.light .round-number{
color:black;
}

body.light .podium-rest-item {
  color: white;
}

body.light #keypad-display {
background: #e5e9f0;
}


header{
background:#111318;
padding:16px;
position:sticky;
top:0;
z-index:100;
box-shadow:0 2px 6px rgba(0,0,0,0.5);
}

.titel{

font-size:26px;
font-weight:700;
letter-spacing:1.5px;

background:linear-gradient(
90deg,
#ffd700 0%,
#fff6b0 45%,
#ffd700 100%
);

-webkit-background-clip:text;
-webkit-text-fill-color:transparent;

text-shadow:
0 0 6px rgba(255,215,0,0.35),
0 0 12px rgba(255,215,0,0.15);
}

h2{
margin-top:10px;
font-weight:500;
}

button{
padding:12px 20px;
margin:8px;
font-size:16px;
border:none;
border-radius:10px;
cursor:pointer;
background:#2c7ef7;
color:white;
transition:0.2s;

touch-action: manipulation;
}

button:hover{
opacity:0.9;
}

input{
display:block;
width:80%;
margin:10px auto;
padding:12px;
font-size:16px;
border-radius:8px;
border:none;
background:#2b2f38;
color:white;
}

.hidden{
display:none;
}

/* START SCREEN */

.start-container{
max-width:420px;
margin:auto;
padding:20px;
}

.players-list{
display:flex;
flex-direction:column;
gap:12px;
margin-bottom:20px;
}

.player-card{
display:flex;
width:100%;
align-items:center;
background:#2b2f38;
border-radius:12px;
padding:6px;
box-shadow:0 4px 10px rgba(0,0,0,0.4);
}

.player-card input{
flex:1;
border:none;
background:transparent;
color:white;
font-size:16px;
padding:10px;
}

.player-card input:focus{
outline:none;
}

.remove-player{
background:#ff5a5a;
border:none;
color:white;
font-size:16px;
width:36px;
height:36px;
border-radius:8px;
cursor:pointer;

display: flex;
align-items: center;
justify-content: center;
}

.add-player-btn{
width:99%;
background:#3b82f6;
color:white;
}

.start-btn{
width:99%;
background:#22c55e;
font-size:18px;
}

/* HEADER */

.game-header{
background:#111318;
padding:18px 10px;
position:sticky;
top:0;
z-index:100;
box-shadow:0 4px 10px rgba(0,0,0,0.6);
}

.total-cell {
  position: sticky;
  left: 0;
  z-index: 6;
  font-weight: bold;
  background: #353a45;
  min-width: 60px;
  width: 60px;
  border-right: 1.5px solid #7f828a;
}

.total-header{
min-width:20px;
width:20px;
}

.game-title{
display:flex;
align-items:center;
justify-content:center;
gap:8px;
margin-left:45px;
}

.title-card{
height:60px;
border-radius:6px;
}

.left-card{
transform:rotate(-10deg);
height: 48px;
}

.right-card{
transform:rotate(30deg);
margin-left:-20px;
}

.lobby-btn{
background:none;
border:none;
display:flex;
align-items:center;
justify-content:center;
width:40px;
height:40px;
cursor:pointer;
opacity:0.85;
transition:0.15s;
}

.lobby-btn img{
width:45px;
height:45px;
}

.lobby-btn:hover{
opacity:1;
}

.lobby-btn:active{
transform:scale(0.92);
}

.start-lobby-btn{
justify-content:left;
width:100%;
color:grey;
background:none;
font-size:18px;
padding:14px 40px 14px 14px;
margin-top:10px;
margin-bottom:20px;
margin-left:-15px;
gap:10px;
}

.start-lobby-btn:hover{
text-shadow: 0 0 20px white;
}

.start-lobby-btn img{
width:40px;
height:40px;
}


/* TABLE */

#table-container {
    display: inline-flex;
    align-items: stretch;
    overflow-x: auto;
    max-width: 100%;
    margin-top: 25px;
    padding-bottom: 20px;
}

.table {
    border-collapse: separate;
    border-spacing: 4px;
    margin: 0; 
}

th{
background:#2b2f38;
padding:10px;
border-radius:8px;
font-weight:500;
min-width:60px;
}

td{
background:#2b2f38;
min-width:30px;
height:60px;
border-radius:8px;
position:relative;
cursor:pointer;
}

.player-name{
position:sticky;
left:60px;
background:#181b21;
font-weight:600;
z-index:5;
min-width:100px;
border-right: 1.5px solid #666970;
}

.player-name,
.total-cell{
cursor:default;
}

.overlay{
position:fixed;
top:0;
left:0;
width:100%;
height:100%;
background:rgba(0,0,0,0.5);
display:flex;
align-items:center;
justify-content:center;
z-index:200;
}

.overlay.hidden{
display:none;
}

.overlay-content{
background:#1f222a;
padding:15px;
border-radius:14px;
width:240px;
max-width:90%;
}

/* KEYPAD */

#keypad-grid{
display:grid;
grid-template-columns:repeat(3,1fr);
gap:8px;
justify-items:center;
}

#keypad-grid button{
width:55px;
height:55px;
font-size:20px;
border-radius:10px;
}

.game-controls{
display:flex;
justify-content:flex-start;
gap:10px;
margin-top:20px;
margin-bottom:20px;
padding-left:10px;
}

.active-round{
box-shadow:0 0 0 1.5px #0f8759;
background:#353a45;
}

.endgame-cell{
vertical-align:middle;
}

#end-game-vertical{
background:none;
border:3px solid #444;
color:#ff5a5a;
padding:10px;
border-radius:10px;
font-size:14px;
}

#toast{
position:fixed;
top:55%;
left:50%;
transform:translate(-50%,-50%);
background:#2b2f38;
color:yellow;
padding:14px 20px;
border-radius:10px;
font-size:15px;
opacity:0;
pointer-events:none;
transition:opacity 0.3s, transform 0.3s;
box-shadow:0 8px 25px rgba(0,0,0,0.6);
z-index:500;
}

#toast.show{
opacity:1;
transform:translate(-50%,-55%);
}

#endgame-container{
display:flex;
justify-content:flex-end;
margin-top:8px;
}

#end-game{
background:none;
border:3px solid #444;
color:#ff5a5a;
padding:12px 8px;
font-size:16px;
border-radius:10px;

writing-mode:vertical-rl;
transform:rotate(180deg);
}

.round-header{
position:relative;
width:30px;
height:30px;
font-size:13px;
}

.round-header img{
position:absolute;
top:0;
left:0;
width:100%;
height:100%;
object-fit:cover;
border-radius:8px;
opacity:0.6;
}

.round-number{
position:relative;
z-index:2;
font-weight:bold;

font-size:15px;
color:white;
text-shadow: 0 0 10px red, 0 0 20px red;
}

.add-round{
background:none;
border: 2.5px solid #444;
color: #22c55e;
padding: 25px 9px;
border-radius: 0 10px 10px 0;
cursor: pointer;
font-size: 16px;

writing-mode: vertical-rl;

/* Îl aliniem să înceapă sub header-ul tabelului */
margin-top: 4px;
flex-shrink: 0; /* Împiedică strivirea butonului */
transition: 0.2s;
}

body.light .add-round{
 border: 2.5px solid #55575c;
}

.close-game {
background:none;
border:2px solid #444;
color:#ff5a5a;
padding:8px 20px;
font-size:16px;
border-radius:10px;
opacity:0.9;
}

#end-game-side.close {
  border:2px solid #444;
  border-color: #ff5a5a;
  color: #ff5a5a;
}

/* Podium */
#podium-screen{
margin-bottom:40px;
}

#podium-title{
margin-top: 45px;
text-shadow: 0 0 10px red, 0 0 20px red;
}

/* container */
#podium {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
}

/* card general */
.podium-item {
  margin-top:25px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  text-align: center;

  width: 90px;
  border-radius: 12px;
  padding: 10px 10px 8px 10px;

  background: #2b2f38;
  box-shadow: 0 8px 20px rgba(0,0,0,0.6);

  animation: popUp 0.5s ease forwards;
}

/* rank emoji */
.podium-rank {
  position: absolute;
  bottom: 100%;   /* 🔥 lipit de partea de sus a coloanei */
  margin-bottom: 4px;

  font-size: 24px;
}

/* name */
.podium-name {
  font-weight: 600;
  font-size: 17px;
}

/* score */
.podium-score {
  font-size: 16px;
  opacity: 0.9;
}

/* 🥇 locul 1 */
.place-1 {
  height: 60px;
  background: linear-gradient(180deg, #ffd700, #b89600);
  color: black;
  transform: scale(1.05);
}

/* 🥈 locul 2 */
.place-2 {
  height: 48px;
  color: black;
  background: linear-gradient(180deg, #c0c0c0, #7d7d7d);
}

/* 🥉 locul 3 */
.place-3 {
  height: 35px;
  color: black;
  background: linear-gradient(180deg, #cd7f32, #8c4f1f);
}

/* wrapper top 3 */
.podium-top {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 14px;
}

/* lista rest */
.podium-rest {
  margin-top: 15px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.podium-rest-item {
  background: #2b2f38;
  padding: 8px 14px;
  border-radius: 8px;
  width: 200px;
  text-align: center;
  font-size: 16px;
  opacity: 0.85;
}

/* animatie */
@keyframes popUp {
  0% {
    transform: translateY(40px);
    opacity: 0;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

#keypad-grid button[data-key="enter"]{
color:#4dff88;
font-weight:bold;
}

#keypad-grid button[data-key="del"]{
color:#ff5a5a;
font-weight:bold;
}

/*animatie podium */

.firework{
position:fixed;
width:8px;
height:8px;
border-radius:50%;
background:#ffd700;
box-shadow:
0 0 6px #ffd700,
0 0 12px #ff3b3b,
0 0 18px #ff3b3b;

animation:fireworkPop 1.2s ease-out forwards;
}

@keyframes fireworkPop{

0%{
transform:scale(0.2);
opacity:0;
}

40%{
transform:scale(1.5);
opacity:1;
}

100%{
transform:scale(3);
opacity:0;
}

}


/* Stilul butonului lateral - acum se va mișca cu tabelul */
#end-game-side {
background:none;
border:2px solid #444;
color:#ff5a5a;
padding:8px 20px;
font-size:16px;
border-radius:10px;
opacity:0.9;
}

.undo-btn{
background:none;
border:none;
display:flex;
align-items:center;
justify-content:center;
width:40px;
height:40px;
cursor:pointer;
opacity:0.85;
transition:0.15s;
}

.undo-btn img{
width:38px;
height:38px;
}

/* Ajustare pentru modul Light */
body.light #end-game-side {
    background: #ffffff;
}

.score-limit-container {
  margin: 15px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

#score-limit {
  width: 120px;
  padding: 10px;
  font-size: 16px;
  border-radius: 8px;
  border: none;
  background: #2b2f38;
  color: white;
  text-align: center;
  box-shadow: 0 4px 10px rgba(0,0,0,0.4);
}


#score-limit::-webkit-outer-spin-button,
#score-limit::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

#score-limit {
  -moz-appearance: textfield;
}

.score-negative {
  color: #4dff88;
  text-shadow: 0 0 8px rgba(77,255,136,0.7);
}

.score-warning {
  color: #eab308;
}

.score-danger {
  color: #ff5a5a;
  text-shadow: 0 0 8px rgba(255,90,90,0.7);
}

.keypad-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 10px;
}

.keypad-top button[data-key="double"] {
  width: 55px;
  height: 55px;
  font-size: 18px;
  border-radius: 10px;
  
  color: #f59e0b;
  font-weight: bold;
}

.keypad-top button[data-key="double"].active {
  box-shadow:
    0 0 8px rgba(255,0,0,0.7),
    0 0 16px rgba(255,0,0,0.5),
    0 0 24px rgba(255,0,0,0.3);
}

.keypad-top button[data-key="minus"].active {
  box-shadow:
    0 0 8px lightblue,
    0 0 16px #08b3d1;
}

#keypad-display {
  width: 85px;
  height: 55px;

  display: flex;
  align-items: center;
  justify-content: center;

  background: #2b2f38;
  border-radius: 10px;

  font-size: 22px;
  margin-bottom: 8px;
  min-height: 29px;
}

/* 🔥 animație nume care "cad" */
.animated-name {
  opacity: 0;
  transform: translateY(-60px) scale(0.9);
  animation: dropName 0.6s ease forwards;
}

/* delay diferit pe fiecare */
.podium-item:nth-child(1) .animated-name { animation-delay: 0.5s; }
.podium-item:nth-child(2) .animated-name { animation-delay: 1s; }
.podium-item:nth-child(3) .animated-name { animation-delay: 1.5s; }

.podium-rest-item:nth-child(1) .animated-name { animation-delay: 2s; }
.podium-rest-item:nth-child(2) .animated-name { animation-delay: 2.3s; }
.podium-rest-item:nth-child(3) .animated-name { animation-delay: 2.5s; }
.podium-rest-item:nth-child(4) .animated-name { animation-delay: 2.7s; }
.podium-rest-item:nth-child(5) .animated-name { animation-delay: 2.9s; }

.podium-rest-item .animated-name {
  opacity: 0;
  transform: translateY(-50px) scale(0.95);
  animation: dropName 0.6s ease forwards;
}

@keyframes dropName {
  0% {
    opacity: 0;
    transform: translateY(-60px) scale(0.9);
  }
  70% {
    transform: translateY(5px) scale(1.05);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* PAGE TRANSITIONS */

body{
opacity:0;
transform:scale(0.98);
transition:
opacity 0.35s ease,
transform 0.35s ease;
}

body.page-enter{
opacity:1;
transform:scale(1);
}

body.page-exit{
opacity:0;
transform:scale(0.98);
pointer-events:none;
}