:root {
  --bg: #0b0e14;
  --card: #161b22;
  --primary: #4f46e5;
  --accent: #facc15;
  --danger: #ef4444;
  --success: #22c55e;
  --text: #ffffff;
  --muted: #94a3b8;
  --nav-bg: #0f172a;
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Kanit', sans-serif;
  min-height: 100vh;
  width: 100%;
  overflow-x: hidden;
}

.app-shell {
  max-width: 500px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  background: var(--bg);
}

/* FIXED TOP BAR */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 45px 20px 15px 20px; /* Increased top padding for notch */
  background: var(--bg);
  position: fixed;
  top: 0;
  width: 100%;
  max-width: 500px;
  z-index: 1000;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

.container {
  padding: 110px 20px 120px 20px; /* Adjusted for Fixed Top/Bottom */
  flex: 1;
}

.hidden { display: none !important; }

.p-mini-img {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 2px solid var(--accent);
  object-fit: cover;
}

/* สไตล์ไอคอนเริ่มต้นเมื่อไม่มีรูป */
.p-img-default {
  width: 40px; height: 40px; border-radius: 12px;
  background: rgba(255,255,255,0.05);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); border: 1px solid rgba(255,255,255,0.1);
}
.p-img-default.large { width: 110px; height: 110px; border-radius: 30px; }
.p-img-default.mini { width: 35px; height: 35px; border-radius: 10px; border: 1.5px solid var(--accent); }

/* Card Style */
.card {
  background: var(--card);
  border-radius: 20px;
  padding: 22px;
  margin-bottom: 15px;
  border: 1px solid rgba(255,255,255,0.05);
}

/* Leaderboard Row Spacing */
.row {
  display: flex;
  align-items: center;
  padding: 14px;
  background: rgba(255,255,255,0.02);
  border-radius: 18px;
  margin-bottom: 10px;
}
.rank-num {
  font-weight: 800;
  font-size: 14px;
  color: var(--muted);
  width: 35px; /* Fixed width to give space before photo */
  text-align: center;
}
.p-img-thumb {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  object-fit: cover;
  margin-right: 15px; /* Space after photo */
}
.p-info { flex: 1; min-width: 0; }
.p-name { font-weight: 600; font-size: 17px; color: #fff; }
.p-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.p-score { font-size: 22px; font-weight: 800; color: var(--accent); }

/* Buttons */
.btn {
  width: 100%;
  padding: 18px;
  border-radius: 18px;
  border: none;
  font-family: 'Kanit';
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-gray { background: rgba(255,255,255,0.08); color: #fff; }
.btn-green { background: var(--success); color: #fff; }
.btn:active { transform: scale(0.97); opacity: 0.9; }

/* Inputs */
input, select {
  width: 100%;
  padding: 16px;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  color: #fff;
  font-family: 'Kanit';
  font-size: 16px;
  margin-bottom: 12px;
}

/* Bottom Nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 500px;
  background: var(--nav-bg);
  display: flex;
  justify-content: space-around;
  padding: 12px 10px 30px 10px;
  border-top: 1px solid rgba(255,255,255,0.05);
  z-index: 1000;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  color: #4b5563;
  text-decoration: none;
  font-size: 10px;
  background: none;
  border: none;
  font-family: 'Kanit';
}
.nav-item.active { color: #fff; }

/* Sidebar (Menu MORE) */
.sidebar {
  position: fixed;
  top: 0;
  right: -300px;
  width: 280px;
  height: 100%;
  background: #0f172a;
  z-index: 2000;
  transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 50px 20px;
  display: flex;
  flex-direction: column;
  box-shadow: -10px 0 50px rgba(0,0,0,0.5);
  visibility: hidden;
}
.sidebar.open { right: 0; visibility: visible; }
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  z-index: 1500;
  display: none;
}
.sidebar-overlay.show { display: block; }
.side-item {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px;
  color: #94a3b8;
  text-decoration: none;
  border-radius: 12px;
  margin-bottom: 5px;
  font-weight: 500;
  background: none;
  border: none;
  width: 100%;
  font-family: 'Kanit';
  font-size: 15px;
}
.side-item:active { background: rgba(255,255,255,0.05); color: #fff; }

/* Play Tab Specifics */
.level-info { font-size: 20px; font-weight: 800; color: var(--accent); text-align: center; margin-bottom: 5px; }
.timer-display { font-size: 72px; font-weight: 800; text-align: center; color: #fff; letter-spacing: -2px; }
.next-info { font-size: 15px; color: var(--muted); text-align: center; margin-bottom: 30px; }

.roster-grid { display: flex; flex-wrap: wrap; gap: 8px; margin: 15px 0; }
.roster-item {
  padding: 8px 16px;
  background: #333;
  border-radius: 50px; /* Capsule shape */
  font-size: 13px;
  text-align: center;
  color: #fff;
  cursor: pointer;
  border: 1px solid transparent;
}
.roster-item.active { background: var(--primary); border-color: rgba(255,255,255,0.2); }

/* --- PROFILE IMAGE & DEFAULT ICON STYLES --- */
.p-img-thumb, .p-img-default {
  width: 40px; height: 40px; border-radius: 12px; object-fit: cover;
  flex-shrink: 0;
}
.p-img-default {
  background: rgba(255,255,255,0.05);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); border: 1px solid rgba(255,255,255,0.1);
}
.p-img-default i { width: 18px; height: 18px; }

/* Large Size (Profile / Champion) */
.p-img-thumb.large, .p-img-default.large { width: 110px; height: 110px; border-radius: 30px; }
.p-img-default.large i { width: 40px; height: 40px; }

/* Mini Size (Top Bar) */
.p-img-thumb.mini, .p-img-default.mini { width: 35px; height: 35px; border-radius: 10px; border: 1.5px solid var(--accent); }
.p-img-default.mini i { width: 16px; height: 16px; }
