* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at center, #143666 0%, #061326 100%);
  color: #ffffff;
  font-family: 'Malgun Gothic', 'Apple SD Gothic Neo', 'Dotum', sans-serif;
}

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

#app-wrapper {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0;
  position: relative;
}

/* Compact Top-Right Floating Utility Buttons (Requirement #5: Never covers game screen) */
.floating-ui-btns {
  position: fixed;
  top: 6px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 200;
}

.float-icon-btn {
  background: rgba(14, 49, 102, 0.82);
  color: #ffffff;
  border: 1px solid rgba(132, 197, 255, 0.75);
  border-radius: 5px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(3px);
}

.float-icon-btn:hover {
  background: rgba(32, 92, 178, 0.95);
  border-color: #ffe866;
}

.controls-popover {
  position: absolute;
  top: 28px;
  right: 0;
  width: 395px;
  background: rgba(6, 22, 52, 0.96);
  border: 1px solid #63b5ff;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 11px;
  color: #d6ecff;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.8);
  z-index: 210;
}

.controls-popover.hidden {
  display: none;
}

.popover-lan-info {
  color: #ffe866;
  font-weight: 800;
  padding-bottom: 3px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.controls-popover kbd {
  background: #184a8c;
  border: 1px solid #6cb8ff;
  border-radius: 3px;
  padding: 0 4px;
  font-size: 10px;
  font-weight: 700;
  color: #fff48f;
}

/* Responsive 4:3 Aspect Ratio Viewport Scaler */
#viewport-scaler {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 800px;
  height: 600px;
  flex-shrink: 0;
  transform-origin: center center;
}

/* 800x600 Original Stage Frame */
#stage-container {
  width: 800px;
  height: 600px;
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  border: 2px solid #4da6ff;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.7);
  background: #081e3f;
}

.stage-screen {
  position: absolute;
  inset: 0;
  width: 800px;
  height: 600px;
  display: none;
}

.stage-screen.active {
  display: block;
}

/* =========================================================
   1. AUTHENTIC LOGIN SCREEN (LoginStage/CAStage)
   ========================================================= */
#screen-login {
  background: url('/assets/ui/login_bg.jpg?_v3') no-repeat 0 0 / 800px 600px;
}

/* Center Login Table (LO_LogTable00: 456x157, LO_LogTable01: 516x157) */
.login-table-box {
  position: absolute;
  left: 50%;
  top: 382px;
  transform: translateX(-50%);
  height: 157px;
  background-repeat: no-repeat;
  background-position: 0 0;
  z-index: 5;
}

.login-table-box.mode-1p {
  width: 456px;
  background-image: url('/assets/ui/login_table_1p.png?_v3');
}

.login-table-box.mode-2p {
  width: 516px;
  background-image: url('/assets/ui/login_table_2p.png?_v3');
}

/* 1P / 2P Wing Buttons inside the left/right gray wings of LO_LogTable (84x103 per frame) */
.login-wing-btn {
  position: absolute;
  top: 27px;
  width: 84px;
  height: 103px;
  border: none;
  background-color: transparent;
  background-repeat: no-repeat;
  cursor: pointer;
  z-index: 6;
}

.login-wing-btn.wing-1p {
  left: 6px;
  background-image: url('/assets/ui/login_bt_1p.png?_v3');
  background-position: 0 0;
}

.login-wing-btn.wing-2p {
  right: 6px;
  background-image: url('/assets/ui/login_bt_2p.png?_v3');
  background-position: 0 0;
}

.login-wing-btn:hover {
  background-position: -84px 0;
}

.login-wing-btn.active {
  background-position: -168px 0;
}

/* Server Selection Buttons inside the top '서버 선택' slot of LO_LogTable */
.login-ser-btn {
  position: absolute;
  top: 30px;
  height: 24px;
  border: none;
  background-color: transparent;
  background-repeat: no-repeat;
  background-position: 0 0;
  cursor: pointer;
  z-index: 6;
}

.login-table-box.mode-1p .login-ser-btn {
  width: 95px;
}

.login-table-box.mode-1p .login-ser-btn.ser-ha {
  left: 130px;
  background-image: url('/assets/ui/login_ser_ha.png?_v3');
}

.login-table-box.mode-1p .login-ser-btn.ser-dre {
  left: 231px;
  background-image: url('/assets/ui/login_ser_dre.png?_v3');
}

.login-table-box.mode-1p .login-ser-btn:hover {
  background-position: -95px 0;
}

/* Frame 2 (-190px): Pressed down effect; Frame 3 (-285px): Selected with blue V-checkmark! (Requirement #11) */
.login-table-box.mode-1p .login-ser-btn:active {
  background-position: -190px 0;
}

.login-table-box.mode-1p .login-ser-btn.active {
  background-position: -285px 0;
}

.login-table-box.mode-2p .login-ser-btn {
  width: 138px;
}

.login-table-box.mode-2p .login-ser-btn.ser-ha {
  left: 118px;
  background-image: url('/assets/ui/login_ser_ha_2p.png?_v3');
}

.login-table-box.mode-2p .login-ser-btn.ser-dre {
  left: 260px;
  background-image: url('/assets/ui/login_ser_dre_2p.png?_v3');
}

.login-table-box.mode-2p .login-ser-btn:hover {
  background-position: -138px 0;
}

.login-table-box.mode-2p .login-ser-btn:active {
  background-position: -276px 0;
}

.login-table-box.mode-2p .login-ser-btn.active {
  background-position: -414px 0;
}

/* Inline Login Notice Banner (No alert() popups - Requirement #10) */
.login-notice-bar {
  position: absolute;
  left: 50%;
  top: 346px;
  transform: translateX(-50%);
  padding: 4px 14px;
  border-radius: 6px;
  background: rgba(8, 22, 48, 0.92);
  border: 1px solid #ff6b6b;
  color: #ff6b6b;
  font-family: 'Dotum', 'Gulim', 'Malgun Gothic', sans-serif;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  z-index: 15;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.65);
}

.login-notice-bar.ok {
  border-color: #63ff8f;
  color: #63ff8f;
}

.login-notice-bar.hidden {
  display: none;
}

/* Authentic Login Loading Popup (LoginStage/Dlg_LO-Wait: 245x246 - Requirement #2) */
.login-wait-dlg {
  position: relative;
  width: 245px;
  height: 246px;
  background: url('/assets/ui/login_dlg_wait.png?_v3') no-repeat 0 0 / 245px 246px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.78);
}

#login-wait-canvas {
  position: absolute;
  left: 80px;
  top: 82px;
  width: 84px;
  height: 84px;
  image-rendering: pixelated;
}

.login-wait-cancel-btn {
  left: 71px;
  top: 204px;
}

/* Direct Frameless Inputs inside the exact white slots of login_table_1p.png / login_table_2p.png */
.login-slot-input {
  position: absolute;
  height: 19px;
  padding: 0 4px;
  border: none;
  background: transparent;
  color: #111111;
  font-family: 'Dotum', 'Gulim', 'Malgun Gothic', sans-serif;
  font-size: 12px;
  font-weight: 700;
  line-height: 19px;
  outline: none;
  user-select: text;
  z-index: 7;
}

/* 1P Table (456x157): white slots at x=232..323 (w=91), y=95..114 & y=120..139 */
.login-table-box.mode-1p .slot-1p-id {
  left: 232px;
  top: 95px;
  width: 91px;
}

.login-table-box.mode-1p .slot-1p-pw {
  left: 232px;
  top: 120px;
  width: 91px;
}

.login-table-box.mode-1p .slot-2p-id,
.login-table-box.mode-1p .slot-2p-pw {
  display: none;
}

/* 2P Table (516x157): 1P white slots at x=207..299 (w=92), 2P white slots at x=304..396 (w=92) */
.login-table-box.mode-2p .slot-1p-id {
  left: 207px;
  top: 95px;
  width: 92px;
}

.login-table-box.mode-2p .slot-1p-pw {
  left: 207px;
  top: 120px;
  width: 92px;
}

.login-table-box.mode-2p .slot-2p-id {
  display: block;
  left: 304px;
  top: 95px;
  width: 92px;
}

.login-table-box.mode-2p .slot-2p-pw {
  display: block;
  left: 304px;
  top: 120px;
  width: 92px;
}

/* Bottom 3 Buttons placed directly in the 3 blue slots at y=556..589 of login_bg.jpg */
.login-bottom-bar {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 6;
}

.login-img-btn {
  position: absolute;
  top: 558px;
  width: 99px;
  height: 30px;
  border: none;
  background-color: transparent;
  background-repeat: no-repeat;
  background-position: 0 0;
  cursor: pointer;
  pointer-events: auto;
}

.login-img-btn.btn-ok {
  left: 242px;
  background-image: url('/assets/ui/login_bt_ok.png?_v3');
}

.login-img-btn.btn-newid {
  left: 351px;
  background-image: url('/assets/ui/login_bt_newid.png?_v3');
}

.login-img-btn.btn-exit {
  left: 460px;
  background-image: url('/assets/ui/login_bt_exit.png?_v3');
}

.login-img-btn:hover {
  background-position: -99px 0;
}

.login-img-btn:active {
  background-position: -198px 0;
}

/* Sign-Up Modal (Original Dlg_LO-NewID: 374x294 with direct slot inputs) */
.signup-dlg-box {
  position: relative;
  width: 374px;
  height: 294px;
  background: url('/assets/ui/login_dlg_newid.png?_v3') no-repeat 0 0 / 374px 294px;
  border: none;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.75);
}

.dlg-slot-label {
  position: absolute;
  left: 24px;
  width: 104px;
  height: 21px;
  line-height: 21px;
  text-align: center;
  font-family: 'Dotum', 'Gulim', 'Malgun Gothic', sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 1px 1px #003a75;
  pointer-events: none;
}

.dlg-slot-input {
  position: absolute;
  padding: 0 5px;
  border: none;
  background: transparent;
  color: #111111;
  font-family: 'Dotum', 'Gulim', 'Malgun Gothic', sans-serif;
  font-size: 12px;
  font-weight: 700;
  line-height: 21px;
  outline: none;
  user-select: text;
}

.dlg-slot-input-solid {
  background: #ffffff;
  border: 1px solid #09529c;
  border-radius: 2px;
}

.dlg-idcheck-btn {
  position: absolute;
  left: 268px;
  top: 71px;
  width: 81px;
  height: 21px;
  border: none;
  background: url('/assets/ui/login_bt_idcheck.png?_v3') no-repeat 0 0;
  cursor: pointer;
}

.dlg-idcheck-btn:hover {
  background-position: -81px 0;
}

.dlg-idcheck-btn:active {
  background-position: -162px 0;
}

.dlg-slot-status {
  position: absolute;
  left: 133px;
  top: 98px;
  width: 216px;
  height: 21px;
  line-height: 19px;
  padding: 0 6px;
  background: #ffffff;
  border: 1px solid #09529c;
  border-radius: 2px;
  font-family: 'Dotum', 'Gulim', 'Malgun Gothic', sans-serif;
  font-size: 11px;
  font-weight: 800;
  color: #1c3a6e;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dlg-slot-status.ok {
  color: #0b7a2a;
}

.dlg-slot-status.err {
  color: #d91c1c;
}

.dlg-slot-bonus {
  position: absolute;
  left: 133px;
  top: 206px;
  width: 216px;
  height: 21px;
  line-height: 19px;
  padding: 0 6px;
  background: #0c5bb5;
  border: 1px solid #073d7d;
  border-radius: 2px;
  font-family: 'Dotum', 'Gulim', 'Malgun Gothic', sans-serif;
  font-size: 11px;
  font-weight: 800;
  color: #fffb96;
  text-shadow: 0 1px 1px #002855;
  pointer-events: none;
}

.dlg-bottom-btn {
  position: absolute;
  top: 250px;
  width: 102px;
  height: 30px;
  border: none;
  background-color: transparent;
  background-repeat: no-repeat;
  background-position: 0 0;
  cursor: pointer;
}

.dlg-bottom-btn.btn-agree {
  left: 78px;
  background-image: url('/assets/ui/login_bt_agree.png?_v3');
}

.dlg-bottom-btn.btn-oppo {
  left: 194px;
  background-image: url('/assets/ui/login_bt_oppo.png?_v3');
}

.dlg-bottom-btn:hover {
  background-position: -102px 0;
}

.dlg-bottom-btn:active {
  background-position: -204px 0;
}

/* =========================================================
   2. AUTHENTIC LOBBY SCREEN (Lobby/CAStageRenew)
   ========================================================= */
#screen-lobby {
  background: url('/assets/ui/lobby_bg.jpg?_v3') no-repeat 0 0 / 800px 600px;
}

/* GlobalUI Top Bar inside the dark top bar of Lobby/CAStageRenew (x=218..767, y=5..35) */
.lobby-global-bar {
  position: absolute;
  left: 222px;
  top: 6px;
  width: 554px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
  z-index: 6;
}

.lobby-notice-text {
  font-family: 'Dotum', 'Gulim', 'Malgun Gothic', sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: #fff699;
  text-shadow: 0 1px 1px #000;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 245px;
}

.lobby-global-btns {
  display: flex;
  align-items: center;
  gap: 3px;
}

.ca-pill-2p {
  height: 22px;
  padding: 0 7px;
  border-radius: 11px;
  border: 1px solid #80d4ff;
  background: linear-gradient(180deg, #1e7be0 0%, #0d438a 100%);
  color: #ffffff;
  font-family: 'Dotum', 'Malgun Gothic', sans-serif;
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.ca-pill-2p.active {
  background: linear-gradient(180deg, #32c759 0%, #147a2f 100%);
  border-color: #a3ffbc;
}

/* Authentic GlobalUI Sprite Buttons (Shop, MyItem, CreateMap, Exit, Back, Lobby) */
.g-img-btn {
  height: 24px;
  border: none;
  background-color: transparent;
  background-repeat: no-repeat;
  background-position: 0 0;
  cursor: pointer;
  flex-shrink: 0;
}

.g-img-btn.g-bt-shop {
  width: 63px;
  background-image: url('/assets/ui/g_bt_shop.png?_v3');
}
.g-img-btn.g-bt-shop:hover { background-position: -63px 0; }
.g-img-btn.g-bt-shop:active { background-position: -126px 0; }

.g-img-btn.g-bt-myitem {
  width: 67px;
  background-image: url('/assets/ui/g_bt_myitem.png?_v3');
}
.g-img-btn.g-bt-myitem:hover { background-position: -67px 0; }
.g-img-btn.g-bt-myitem:active { background-position: -134px 0; }

.g-img-btn.g-bt-createmap {
  width: 63px;
  background-image: url('/assets/ui/g_bt_createmap.png?_v3');
}
.g-img-btn.g-bt-createmap:hover { background-position: -63px 0; }
.g-img-btn.g-bt-createmap:active { background-position: -126px 0; }

.g-img-btn.g-bt-exit {
  width: 31px;
  background-image: url('/assets/ui/g_bt_exit.png?_v3');
}
.g-img-btn.g-bt-exit:hover { background-position: -31px 0; }
.g-img-btn.g-bt-exit:active { background-position: -62px 0; }

.g-img-btn.g-bt-lobby {
  width: 63px;
  background-image: url('/assets/ui/g_bt_lobby.png?_v3');
}
.g-img-btn.g-bt-lobby:hover { background-position: -63px 0; }
.g-img-btn.g-bt-lobby:active { background-position: -126px 0; }

/* Left Channel Slot (x=29, y=148, w=144, h=22) */
.lobby-channel-slot {
  position: absolute;
  left: 29px;
  top: 148px;
  width: 144px;
  height: 22px;
  line-height: 22px;
  text-align: center;
  font-family: 'Dotum', 'Gulim', 'Malgun Gothic', sans-serif;
  font-size: 11px;
  font-weight: 800;
  color: #fff8a6;
  text-shadow: 0 1px 2px #001f4d;
  pointer-events: none;
}

/* Left User Profile Box inside Lobby/CAStageRenew (x=31, y=195, w=140, h=48) */
.lobby-level-icon-slot {
  position: absolute;
  left: 41px;
  top: 199px;
  width: 16px;
  height: 14px;
  background-image: url('/assets/ui/level_icons.png?_v3');
  background-repeat: no-repeat;
  background-position: 0 0;
  image-rendering: pixelated;
  z-index: 6;
}

.lobby-name-slot {
  position: absolute;
  left: 61px;
  top: 196px;
  width: 106px;
  height: 21px;
  line-height: 21px;
  padding: 0 3px;
  font-family: 'Dotum', 'Gulim', 'Malgun Gothic', sans-serif;
  font-size: 12px;
  font-weight: 800;
  color: #ffffff;
  text-shadow: 0 1px 2px #000;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lobby-title-slot {
  position: absolute;
  left: 35px;
  top: 220px;
  width: 132px;
  height: 20px;
  line-height: 20px;
  padding: 0 3px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: 'Dotum', 'Gulim', 'Malgun Gothic', sans-serif;
  font-size: 11px;
  font-weight: 800;
  color: #ffe866;
  text-shadow: 0 1px 2px #000;
  cursor: pointer;
  z-index: 15;
}

.lobby-title-spr {
  display: inline-block;
  width: 44px;
  height: 16px;
  background-repeat: no-repeat;
  background-position: 0 0;
  flex-shrink: 0;
  image-rendering: pixelated;
}

#lobby-my-title-text {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lobby-level-tooltip {
  display: none;
  position: absolute;
  left: 2px;
  bottom: 22px;
  padding: 3px 8px;
  border-radius: 5px;
  background: rgba(4, 18, 46, 0.96);
  border: 1px solid #75c8ff;
  font-family: 'Dotum', 'Gulim', 'Malgun Gothic', sans-serif;
  font-size: 11px;
  font-weight: 900;
  color: #ffe866;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.85);
  pointer-events: none;
  z-index: 30;
}

.lobby-title-slot:hover .lobby-level-tooltip {
  display: block;
}

.lobby-lucci-slot {
  position: absolute;
  left: 31px;
  top: 245px;
  width: 140px;
  height: 16px;
  line-height: 16px;
  text-align: right;
  padding: 0 4px;
  font-family: 'Dotum', 'Malgun Gothic', sans-serif;
  font-size: 10px;
  font-weight: 800;
  color: #9be4ff;
  text-shadow: 0 1px 2px #000;
}

/* Left Connected Users List (10 rows at x=38, y=279, w=125, h=242, 24px per slot) */
.lobby-users-slot {
  position: absolute;
  left: 34px;
  top: 279px;
  width: 133px;
  height: 242px;
  overflow-y: auto;
  overflow-x: hidden;
}

.lobby-users-slot::-webkit-scrollbar {
  width: 4px;
}
.lobby-users-slot::-webkit-scrollbar-thumb {
  background: rgba(110, 190, 255, 0.5);
  border-radius: 2px;
}

.lobby-user-row {
  height: 24px;
  line-height: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
  font-family: 'Dotum', 'Gulim', 'Malgun Gothic', sans-serif;
  font-size: 11px;
  color: #ffffff;
  text-shadow: 0 1px 1px #001a40;
}

.lobby-user-row .u-left {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.lobby-user-row .u-lv-icon {
  width: 16px;
  height: 14px;
  background-image: url('/assets/ui/level_icons.png?_v3');
  background-repeat: no-repeat;
  background-position: 0 0;
  flex-shrink: 0;
  image-rendering: pixelated;
}

.lobby-user-row .u-name {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 72px;
}

.lobby-user-row .u-status {
  font-size: 10px;
  font-weight: 800;
  color: #ffe970;
}

/* Authentic Lobby Top Action Sprite Buttons */
.lb-sprite-btn {
  position: absolute;
  border: none;
  background-color: transparent;
  background-repeat: no-repeat;
  background-position: 0 0;
  cursor: pointer;
  z-index: 5;
}

.lb-bt-create {
  left: 222px;
  top: 49px;
  width: 136px;
  height: 63px;
  background-image: url('/assets/ui/lb_bt_create.png?_v3');
}
.lb-bt-create:hover { background-position: -136px 0; }
.lb-bt-create:active { background-position: -680px 0; }

.lb-bt-quick {
  left: 362px;
  top: 49px;
  width: 124px;
  height: 63px;
  background-image: url('/assets/ui/lb_bt_quick.png?_v3');
}
.lb-bt-quick:hover { background-position: -124px 0; }
.lb-bt-quick:active { background-position: -620px 0; }

.lb-bt-wait {
  left: 489px;
  top: 57px;
  width: 99px;
  height: 47px;
  background-image: url('/assets/ui/lb_bt_wait.png?_v3');
}
.lb-bt-wait:hover, .lb-bt-wait.active { background-position: -99px 0; }
.lb-bt-wait:active { background-position: -495px 0; }

.lb-bt-all {
  left: 589px;
  top: 57px;
  width: 99px;
  height: 47px;
  background-image: url('/assets/ui/lb_bt_all.png?_v3');
}
.lb-bt-all:hover, .lb-bt-all.active { background-position: -99px 0; }
.lb-bt-all:active { background-position: -495px 0; }

.lb-bt-practice {
  left: 690px;
  top: 57px;
  width: 97px;
  height: 47px;
  background-image: url('/assets/ui/lb_bt_practice.png?_v3');
}
.lb-bt-practice:hover { background-position: -97px 0; }
.lb-bt-practice:active { background-position: -485px 0; }

/* 6 Room Slots (2 cols x 3 rows of 279x89 LB_Bt_SessionSlot at x=218,503 y=124,216,308) */
.lobby-rooms-grid {
  position: absolute;
  left: 218px;
  top: 124px;
  width: 564px;
  height: 273px;
  display: grid;
  grid-template-columns: 279px 279px;
  grid-template-rows: repeat(3, 89px);
  column-gap: 6px;
  row-gap: 3px;
  z-index: 5;
}

.room-card {
  position: relative;
  width: 279px;
  height: 89px;
  background: url('/assets/ui/lb_room_slot.png?_v3') no-repeat 0 0;
  cursor: pointer;
  overflow: hidden;
}

.room-card.state-waiting {
  background-position: 0 0;
}
.room-card.state-waiting:hover {
  background-position: -279px 0;
}

.room-card.state-playing {
  background-position: -558px 0;
}

.room-card.empty-room {
  background-position: -837px 0;
}
.room-card.empty-room:hover {
  filter: brightness(1.06);
}

/* Exact internal slots of LB_Bt_SessionSlot (279x89) */
.room-slot-preview {
  position: absolute;
  left: 8px;
  top: 10px;
  width: 66px;
  height: 69px;
  border-radius: 5px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.room-slot-preview img {
  width: 64px;
  height: 56px;
  object-fit: cover;
  border-radius: 3px;
  image-rendering: pixelated;
}

.room-slot-num {
  position: absolute;
  left: 84px;
  top: 20px;
  width: 46px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  font-family: 'Dotum', 'Gulim', 'Malgun Gothic', sans-serif;
  font-size: 12px;
  font-weight: 900;
  color: #ffffff;
  text-shadow: 0 1px 2px #0a356e;
}

.room-slot-title {
  position: absolute;
  left: 136px;
  top: 18px;
  width: 128px;
  height: 22px;
  line-height: 22px;
  padding: 0 4px;
  font-family: 'Dotum', 'Gulim', 'Malgun Gothic', sans-serif;
  font-size: 12px;
  font-weight: 800;
  color: #0b264f;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-slot-subinfo {
  position: absolute;
  left: 84px;
  top: 48px;
  width: 125px;
  height: 30px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 4px;
  font-family: 'Dotum', 'Gulim', 'Malgun Gothic', sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: #e8f5ff;
  text-shadow: 0 1px 2px #05204a;
  line-height: 1.25;
}

.room-slot-status {
  position: absolute;
  left: 214px;
  top: 49px;
  width: 57px;
  height: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: 'Dotum', 'Gulim', 'Malgun Gothic', sans-serif;
  line-height: 1.15;
}

.room-slot-status .r-state {
  font-size: 11px;
  font-weight: 900;
  color: #fff36b;
  text-shadow: 0 1px 2px #000;
}

.room-card.state-playing .room-slot-status .r-state {
  color: #ffb3b3;
}

.room-slot-status .r-cnt {
  font-size: 11px;
  font-weight: 900;
  color: #ffffff;
  text-shadow: 0 1px 2px #000;
}

/* Page Left/Right Arrows (59x23 at x=425,498 y=396) */
.lb-page-btn {
  position: absolute;
  top: 396px;
  width: 59px;
  height: 23px;
  border: none;
  background-color: transparent;
  background-repeat: no-repeat;
  background-position: 0 0;
  cursor: pointer;
  z-index: 5;
}

.lb-bt-left {
  left: 425px;
  background-image: url('/assets/ui/lb_bt_left.png?_v3');
}
.lb-bt-left:hover { background-position: -59px 0; }
.lb-bt-left:active { background-position: -118px 0; }

.lb-bt-right {
  left: 498px;
  background-image: url('/assets/ui/lb_bt_right.png?_v3');
}
.lb-bt-right:hover { background-position: -59px 0; }
.lb-bt-right:active { background-position: -118px 0; }

/* Chat Boxes (Direct frameless fit inside original stage slots) */
.chat-log {
  overflow-y: auto;
  padding: 4px 6px;
  background: transparent;
  border: none;
  font-family: 'Dotum', 'Gulim', 'Malgun Gothic', sans-serif;
  font-size: 12px;
  line-height: 1.42;
  color: #ffffff;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.85);
}

.chat-log::-webkit-scrollbar {
  width: 5px;
}
.chat-log::-webkit-scrollbar-thumb {
  background: rgba(120, 195, 255, 0.55);
  border-radius: 3px;
}

.chat-log .chat-msg {
  margin-bottom: 2px;
  word-break: break-all;
}

.chat-log .chat-sender {
  color: #ffe866;
  font-weight: 800;
  margin-right: 5px;
}

.chat-log .chat-sys {
  color: #82ecff;
  font-weight: 700;
}

.chat-log .chat-err {
  color: #ff4d4d;
  font-weight: 800;
  text-shadow: 0 1px 2px #000000;
}

.chat-input {
  background: transparent;
  border: none;
  color: #111111;
  padding: 0 6px;
  font-family: 'Dotum', 'Gulim', 'Malgun Gothic', sans-serif;
  font-size: 12px;
  font-weight: 700;
  outline: none;
  user-select: text;
}

.lobby-chat-log {
  position: absolute;
  left: 214px;
  top: 426px;
  width: 532px;
  height: 86px;
}

.lobby-chat-target {
  position: absolute;
  left: 309px;
  top: 518px;
  width: 90px;
  height: 22px;
  line-height: 22px;
  padding: 0 8px;
  font-family: 'Dotum', 'Gulim', 'Malgun Gothic', sans-serif;
  font-size: 11px;
  font-weight: 800;
  color: #103263;
  pointer-events: none;
}

.lobby-chat-input {
  position: absolute;
  left: 420px;
  top: 518px;
  width: 348px;
  height: 22px;
  line-height: 22px;
  color: #ffffff;
}

/* =========================================================
   AUTHENTIC CREATE ROOM DIALOG (Lobby/Dlg_Creat: 574x430)
   ========================================================= */
.ca-modal {
  position: absolute;
  inset: 0;
  background: rgba(0, 10, 28, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
}

.ca-modal.hidden {
  display: none;
}

.create-room-dlg {
  position: relative;
  width: 574px;
  height: 430px;
  background: url('/assets/ui/dlg_create.png?_v3') no-repeat 0 0 / 574px 430px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.8);
}

.create-mode-card {
  position: absolute;
  top: 52px;
  width: 130px;
  height: 186px;
  border: none;
  background-color: transparent;
  background-repeat: no-repeat;
  background-position: 0 0;
  cursor: pointer;
}

.create-mode-card.mode-normal {
  left: 25px;
  background-image: url('/assets/ui/mode_normal.png?_v3');
}
.create-mode-card.mode-battle {
  left: 156px;
  background-image: url('/assets/ui/mode_battle.png?_v3');
}
.create-mode-card.mode-monster {
  left: 287px;
  background-image: url('/assets/ui/mode_monster.png?_v3');
}
.create-mode-card.mode-super {
  left: 418px;
  background-image: url('/assets/ui/mode_super.png?_v3');
}

.create-mode-card:hover {
  background-position: -130px 0;
}
.create-mode-card.active {
  background-position: -390px 0;
  filter: brightness(1.06);
}

.create-dlg-label {
  position: absolute;
  left: 37px;
  width: 88px;
  height: 24px;
  line-height: 24px;
  text-align: center;
  font-family: 'Dotum', 'Gulim', 'Malgun Gothic', sans-serif;
  font-size: 12px;
  font-weight: 800;
  color: #ffffff;
  text-shadow: 0 1px 2px #08336e;
  pointer-events: none;
}

.create-dlg-input,
.create-dlg-select {
  position: absolute;
  left: 130px;
  width: 407px;
  height: 24px;
  line-height: 24px;
  padding: 0 8px;
  border: none;
  background: transparent;
  color: #0e2447;
  font-family: 'Dotum', 'Gulim', 'Malgun Gothic', sans-serif;
  font-size: 12px;
  font-weight: 800;
  outline: none;
  user-select: text;
}

.create-dlg-select option {
  background: #ffffff;
  color: #0e2447;
}

.etc-sprite-btn {
  position: absolute;
  width: 102px;
  height: 30px;
  border: none;
  background-color: transparent;
  background-repeat: no-repeat;
  background-position: 0 0;
  cursor: pointer;
}

.etc-bt-ok {
  background-image: url('/assets/ui/etc_bt_ok.png?_v3');
}
.etc-bt-cancel {
  background-image: url('/assets/ui/etc_bt_cancel.png?_v3');
}
.etc-sprite-btn:hover {
  background-position: -102px 0;
}
.etc-sprite-btn:active {
  background-position: -204px 0;
}

/* Generic Modal Box (used by 2P Auth Modal) */
.ca-modal-box {
  width: 370px;
  background: linear-gradient(180deg, #164f9c 0%, #0b2b5c 100%);
  border: 3px solid #67bcff;
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.75);
}

.ca-modal-box h3 {
  color: #ffe563;
  font-size: 17px;
  margin-bottom: 2px;
}

.modal-desc {
  font-size: 12px;
  color: #d2ebff;
  line-height: 1.4;
}

.ca-modal-box label {
  font-size: 12px;
  font-weight: 700;
  color: #c7e6ff;
}

.ca-modal-box input,
.ca-modal-box select {
  padding: 7px 9px;
  border-radius: 6px;
  border: 1px solid #63b5ff;
  background: #071b3d;
  color: #fff;
  font-size: 13px;
  outline: none;
  user-select: text;
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.ca-action-btn {
  flex: 1;
  height: 38px;
  border-radius: 8px;
  border: 2px solid #fff;
  font-size: 12px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
  cursor: pointer;
  padding: 0 8px;
}

.ca-action-btn.gold {
  background: linear-gradient(180deg, #ffbe26 0%, #d47100 100%);
  border-color: #ffe38f;
}

.ca-action-btn.gray {
  background: linear-gradient(180deg, #6d819c 0%, #3e4e63 100%);
  border-color: #b4c3d6;
}

/* =========================================================
   3. AUTHENTIC WAITING ROOM SCREEN (Prepare/CAStage_2)
   ========================================================= */
#screen-prepare {
  background: url('/assets/ui/prepare_bg.jpg?_v3') no-repeat 0 0 / 800px 600px;
}

/* Top Dark Bar Controls (x=30..435, y=4..32) */
.prepare-top-subbar {
  position: absolute;
  left: 30px;
  top: 5px;
  width: 405px;
  height: 26px;
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 6;
}

.prep-mini-btn {
  padding: 3px 7px;
  border-radius: 5px;
  border: 1px solid #7dc6ff;
  background: linear-gradient(180deg, #2778d9 0%, #13498f 100%);
  color: #fff;
  font-family: 'Dotum', 'Malgun Gothic', sans-serif;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.prep-mini-btn:hover {
  filter: brightness(1.12);
}

.prep-mini-btn.gold-btn {
  background: linear-gradient(180deg, #ffba19 0%, #d46500 100%);
  border-color: #ffe588;
}

.prep-mini-btn.danger {
  background: linear-gradient(180deg, #e04b4b 0%, #992222 100%);
  border-color: #ff9c9c;
}

/* Room Number, Title & Room Info Button inside Prepare/CAStage_2 Title Bar (y=53..83) */
.prepare-room-num {
  position: absolute;
  left: 26px;
  top: 56px;
  width: 46px;
  height: 22px;
  line-height: 22px;
  text-align: center;
  font-family: 'Dotum', 'Gulim', 'Malgun Gothic', sans-serif;
  font-size: 13px;
  font-weight: 900;
  color: #ffe866;
  text-shadow: 0 1px 2px #000;
}

.prepare-title-bar {
  position: absolute;
  left: 78px;
  top: 56px;
  width: 264px;
  height: 22px;
  line-height: 22px;
  padding: 0 8px;
  font-family: 'Dotum', 'Gulim', 'Malgun Gothic', sans-serif;
  font-size: 12px;
  font-weight: 800;
  color: #ffffff;
  text-shadow: 0 1px 2px #001a40;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.prepare-roominfo-btn {
  position: absolute;
  left: 345px;
  top: 56px;
  width: 100px;
  height: 22px;
  border: none;
  background: url('/assets/ui/pre_bt_roominfo.png?_v3') no-repeat 0 0;
  color: transparent;
  cursor: pointer;
}
.prepare-roominfo-btn:hover {
  background-position: -100px 0;
}
.prepare-roominfo-btn:active {
  background-position: -200px 0;
}

/* 8 Player Slots Grid (4 cols x 2 rows at x=28,134,240,346 and y=94,240) */
.prepare-slots-grid {
  position: absolute;
  left: 28px;
  top: 94px;
  width: 416px;
  height: 286px;
  display: grid;
  grid-template-columns: repeat(4, 98px);
  grid-template-rows: repeat(2, 140px);
  column-gap: 8px;
  row-gap: 6px;
}

.prep-slot {
  position: relative;
  width: 98px;
  height: 140px;
  cursor: pointer;
}

/* Top 98x98 Portrait Box inside each slot */
.prep-slot-portrait {
  position: absolute;
  left: 0;
  top: 0;
  width: 98px;
  height: 98px;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Open slot = blank blue box (pre_slot_close.png); Closed slot = X blue box (pre_slot_open.png) */
.prep-slot.slot-open .prep-slot-portrait {
  background: url('/assets/ui/pre_slot_close.png?_v4') no-repeat 0 0;
}
.prep-slot.slot-open:hover .prep-slot-portrait {
  background-position: -98px 0;
}

.prep-slot.slot-closed .prep-slot-portrait {
  background: url('/assets/ui/pre_slot_open.png?_v4') no-repeat 0 0;
}
.prep-slot.slot-closed:hover .prep-slot-portrait {
  background-position: -98px 0;
}

.prep-slot-team-ribbon {
  position: absolute;
  left: 3px;
  top: 3px;
  right: 3px;
  height: 15px;
  line-height: 15px;
  font-family: 'Dotum', 'Malgun Gothic', sans-serif;
  font-size: 10px;
  font-weight: 900;
  text-align: center;
  border-radius: 3px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
  z-index: 3;
}

.prep-slot-title-tag {
  position: absolute;
  left: 3px;
  bottom: 2px;
  right: 3px;
  height: 16px;
  line-height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0 2px;
  font-family: 'Dotum', 'Malgun Gothic', sans-serif;
  font-size: 9px;
  font-weight: 800;
  color: #ffe86b;
  background: rgba(0, 12, 34, 0.78);
  border-radius: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 3;
}

.prep-slot-title-tag .mini-title-spr {
  width: 34px;
  height: 12px;
  background-repeat: no-repeat;
  background-size: auto 12px;
  flex-shrink: 0;
  image-rendering: pixelated;
}

.prep-slot-canvas {
  width: 64px;
  height: 68px;
  margin-top: 6px;
  image-rendering: pixelated;
  z-index: 2;
}

/* Middle 98x18 Name Bar inside Prepare/CAStage_2 (y+102) */
.prep-slot-name {
  position: absolute;
  left: 2px;
  top: 102px;
  width: 94px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  font-family: 'Dotum', 'Gulim', 'Malgun Gothic', sans-serif;
  font-size: 11px;
  font-weight: 800;
  color: #0e264d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Bottom 98x18 Status Bar inside Prepare/CAStage_2 (y+122) */
.prep-slot-state {
  position: absolute;
  left: 2px;
  top: 122px;
  width: 94px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  font-family: 'Dotum', 'Gulim', 'Malgun Gothic', sans-serif;
  font-size: 11px;
  font-weight: 900;
}

.prep-slot-state.host {
  color: #ffe44d;
  text-shadow: 0 1px 2px #000;
}

.prep-slot-state.ready {
  color: #5eff8b;
  text-shadow: 0 1px 2px #000;
}

.prep-slot-state.wait {
  color: #a8c7eb;
}

/* Bottom-Left Room Chat inside Prepare/CAStage_2 */
.room-chat-log {
  position: absolute;
  left: 22px;
  top: 406px;
  width: 406px;
  height: 86px;
}

.room-chat-target {
  position: absolute;
  left: 95px;
  top: 498px;
  width: 82px;
  height: 20px;
  line-height: 20px;
  padding: 0 6px;
  font-family: 'Dotum', 'Gulim', 'Malgun Gothic', sans-serif;
  font-size: 11px;
  font-weight: 800;
  color: #103263;
  pointer-events: none;
}

.room-chat-input {
  position: absolute;
  left: 186px;
  top: 498px;
  width: 224px;
  height: 20px;
  line-height: 20px;
  color: #ffffff;
}

/* Right Panel: Character Slot Page Header (Slot 1: Basic 8 + ?, Slot 2: Luxury 9) */
.prepare-char-header {
  position: absolute;
  left: 482px;
  top: 38px;
  width: 296px;
  height: 19px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  z-index: 8;
}

.char-page-label {
  font-family: 'Dotum', 'Gulim', 'Malgun Gothic', sans-serif;
  font-size: 11px;
  font-weight: 900;
  color: #ffe866;
  text-shadow: 0 1px 2px #000000;
  margin-right: 2px;
}

.char-page-btn {
  width: 41px;
  height: 19px;
  border: none;
  background-color: transparent;
  background-repeat: no-repeat;
  background-position: 0 0;
  cursor: pointer;
}

.char-page-left,
.bt-char-left {
  background-image: url('/assets/ui/bt_char_left.png?_v3');
}

.char-page-right,
.bt-char-right {
  background-image: url('/assets/ui/bt_char_right.png?_v3');
}

.char-page-btn:hover {
  background-position: -41px 0;
}

.char-page-btn:active {
  background-position: -82px 0;
}

/* Right Panel: 3x3 Character Sprite Buttons Grid (3 cols x 3 rows of 98x65 at x=483, y=60) */
.prepare-char-grid {
  position: absolute;
  left: 483px;
  top: 60px;
  width: 294px;
  height: 197px;
  display: grid;
  grid-template-columns: repeat(3, 98px);
  grid-template-rows: repeat(3, 65px);
  column-gap: 0px;
  row-gap: 1px;
  z-index: 6;
}

.char-pick-btn {
  position: relative;
  width: 98px;
  height: 65px;
  border: none;
  background-color: transparent;
  background-repeat: no-repeat;
  background-position: 0 0;
  cursor: pointer;
}

.char-pick-btn:hover {
  background-position: -196px 0;
}

.char-pick-btn:active {
  background-position: -98px 0;
}

.char-pick-btn.selected-1p,
.char-pick-btn.selected-2p {
  background-position: -294px 0;
}

/* Authentic Character Hover Stat Tooltip (PRE_Ability + ChaInfo_Char*) */
.char-stat-tooltip {
  position: absolute;
  left: 236px;
  top: 52px;
  width: 243px;
  background: rgba(4, 15, 38, 0.94);
  border: 2px solid #6ac1ff;
  border-radius: 8px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.85);
  pointer-events: none;
  z-index: 45;
}

.char-stat-tooltip.hidden {
  display: none;
}

#tooltip-chainfo-img {
  width: 231px;
  height: 70px;
  object-fit: fill;
  border-radius: 4px;
  display: block;
}

#tooltip-ability-canvas {
  width: 231px;
  height: 136px;
  display: block;
  image-rendering: pixelated;
}

/* 1P / 2P Selection Badges on Character & Team Buttons */
.pick-badge-wrap {
  position: absolute;
  right: 3px;
  top: 2px;
  display: flex;
  gap: 2px;
  pointer-events: none;
}

.pick-badge {
  padding: 0 4px;
  height: 14px;
  line-height: 14px;
  border-radius: 7px;
  font-family: 'Dotum', 'Malgun Gothic', sans-serif;
  font-size: 9px;
  font-weight: 900;
  color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
}

.pick-badge.b-1p {
  background: #ff3838;
  border: 1px solid #fff275;
}

.pick-badge.b-2p {
  background: #1e90ff;
  border: 1px solid #99f6ff;
}

/* Right Panel: 8 Team Color Flag Buttons (x=482, y=280, w=296, h=39) */
.prepare-team-bar {
  position: absolute;
  left: 482px;
  top: 280px;
  width: 296px;
  height: 39px;
  display: grid;
  grid-template-columns: repeat(8, 37px);
  gap: 0;
  z-index: 6;
}

.team-color-btn {
  position: relative;
  width: 37px;
  height: 39px;
  border: none;
  background-color: transparent;
  background-repeat: no-repeat;
  background-position: 0 0;
  cursor: pointer;
}

.team-color-btn:hover {
  background-position: -74px 0;
}

.team-color-btn.selected-1p,
.team-color-btn.selected-2p {
  background-position: -111px 0;
}

/* Right Panel: Map Preview & Select inside Prepare/CAStage Map Box (x=482, y=342, w=298, h=144) */
.prepare-map-panel {
  position: absolute;
  left: 482px;
  top: 342px;
  width: 298px;
  height: 144px;
}

#prepare-minimap-img {
  position: absolute;
  left: 5px;
  top: 6px;
  width: 153px;
  height: 132px;
  object-fit: fill;
  border-radius: 3px;
  image-rendering: pixelated;
}

.prepare-map-info {
  position: absolute;
  left: 162px;
  top: 6px;
  width: 131px;
  height: 132px;
}

.map-title {
  height: 20px;
  line-height: 20px;
  padding: 0 4px;
  font-family: 'Dotum', 'Gulim', 'Malgun Gothic', sans-serif;
  font-size: 11px;
  font-weight: 900;
  color: #ffe866;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#prepare-map-select {
  width: 129px;
  height: 22px;
  margin-top: 2px;
  padding: 0 4px;
  border-radius: 4px;
  border: 1px solid #5cb4ff;
  background: #071938;
  color: #fff;
  font-family: 'Dotum', 'Malgun Gothic', sans-serif;
  font-size: 11px;
  font-weight: 700;
}

.map-desc {
  margin-top: 4px;
  padding: 0 2px;
  font-family: 'Dotum', 'Malgun Gothic', sans-serif;
  font-size: 10px;
  font-weight: 700;
  color: #c2e4ff;
  line-height: 1.25;
}

.pre-selectmap-btn {
  position: absolute;
  left: 4px;
  bottom: 0;
  width: 123px;
  height: 48px;
  border: none;
  background: url('/assets/ui/pre_bt_selectmap.png?_v3') no-repeat 0 0;
  cursor: pointer;
}
.pre-selectmap-btn:hover {
  background-position: -123px 0;
}
.pre-selectmap-btn:active {
  background-position: -246px 0;
}

/* Original Start / Ready Sprite Button (193x57 at x=515, y=495) */
.prepare-start-btn {
  position: absolute;
  left: 515px;
  top: 495px;
  width: 193px;
  height: 57px;
  border: none;
  background-color: transparent;
  background-repeat: no-repeat;
  background-position: 0 0;
  cursor: pointer;
  z-index: 6;
}

.prepare-start-btn.is-start {
  background-image: url('/assets/ui/bt_start.png?_v3');
}

.prepare-start-btn.is-ready {
  background-image: url('/assets/ui/bt_ready.png?_v3');
}

.prepare-start-btn:hover {
  background-position: -193px 0;
}

.prepare-start-btn:active,
.prepare-start-btn.ready-active {
  background-position: -386px 0;
}

.prepare-start-btn.disabled-start {
  background-position: -579px 0;
  filter: grayscale(0.35);
}

/* Right-Click Context Menu on Waiting Room Slots (AI Add / Remove / Open-Close) */
.slot-context-menu {
  position: absolute;
  min-width: 146px;
  background: linear-gradient(180deg, #164e99 0%, #092552 100%);
  border: 2px solid #75c6ff;
  border-radius: 7px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.85);
  z-index: 60;
}

.slot-context-menu.hidden {
  display: none;
}

.slot-ctx-item {
  padding: 6px 10px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: #ffffff;
  font-family: 'Dotum', 'Gulim', 'Malgun Gothic', sans-serif;
  font-size: 11px;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.slot-ctx-item:hover {
  background: rgba(110, 190, 255, 0.28);
  color: #ffe866;
}

.slot-ctx-item.hidden {
  display: none;
}

/* =========================================================
   4. SHOP SCREEN (Shop/CAStage)
   ========================================================= */
#screen-shop {
  background:
    linear-gradient(180deg, rgba(6, 22, 54, 0.72) 0%, rgba(4, 15, 38, 0.85) 100%),
    url('/assets/ui/shop_bg.jpg?_v3') no-repeat 0 0 / 800px 600px;
  padding: 14px 18px;
  display: none;
  flex-direction: column;
  gap: 10px;
}

#screen-shop.active {
  display: flex;
}

.substage-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, rgba(18, 66, 138, 0.94) 0%, rgba(9, 36, 82, 0.96) 100%);
  border: 2px solid #5cb4ff;
  border-radius: 10px;
  padding: 8px 14px;
  gap: 10px;
}

.substage-title {
  font-size: 16px;
  font-weight: 900;
  color: #ffe866;
  text-shadow: 0 1px 3px #000;
}

.substage-buyer-toggle {
  display: flex;
  gap: 6px;
}

.buyer-pill {
  padding: 4px 10px;
  border-radius: 14px;
  border: 1px solid #69bcff;
  background: rgba(6, 24, 58, 0.85);
  color: #b8e2ff;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.buyer-pill.active {
  background: #ff9c19;
  border-color: #ffe488;
  color: #210e00;
}

.buyer-pill.hidden {
  display: none;
}

.lucci-Header-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(4, 16, 40, 0.9);
  border: 1px solid #ffcf52;
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 13px;
  color: #fff3a1;
}

.lucci-Header-badge b {
  color: #ffd700;
  font-size: 14px;
}

.lucci-bg-icon {
  height: 20px;
  width: auto;
}

.shop-category-tabs {
  display: flex;
  gap: 6px;
}

.shop-tab {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  border: 2px solid #4ca3ff;
  background: rgba(10, 40, 90, 0.88);
  color: #cbe7ff;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.shop-tab.active {
  background: linear-gradient(180deg, #ffba24 0%, #d46500 100%);
  border-color: #ffe588;
  color: #fff;
  text-shadow: 0 1px 2px #000;
}

.shop-items-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 136px;
  gap: 10px;
  overflow-y: auto;
  padding: 4px 2px;
}

.shop-item-card {
  background: linear-gradient(180deg, rgba(16, 60, 126, 0.94) 0%, rgba(8, 30, 68, 0.96) 100%);
  border: 2px solid #56adff;
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
}

.shop-item-card.owned {
  border-color: #48db74;
}

.shop-card-top {
  display: flex;
  gap: 10px;
  align-items: center;
}

.shop-icon-box {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  background: rgba(4, 16, 38, 0.85);
  border: 1px solid rgba(115, 190, 255, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.shop-icon-box canvas {
  image-rendering: pixelated;
}

.shop-card-info {
  flex: 1;
  min-width: 0;
}

.shop-item-name {
  font-size: 13px;
  font-weight: 900;
  color: #ffe973;
  margin-bottom: 3px;
}

.shop-item-desc {
  font-size: 11px;
  color: #cde8ff;
  line-height: 1.3;
}

.shop-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
}

.shop-price-tag {
  font-size: 12px;
  font-weight: 900;
  color: #ffd84d;
}

.shop-buy-btn {
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid #ffe482;
  background: linear-gradient(180deg, #ffba19 0%, #d46500 100%);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
}

.shop-buy-btn.owned-btn {
  background: linear-gradient(180deg, #27b854 0%, #147532 100%);
  border-color: #98f5b2;
}

.shop-footer-tip {
  background: rgba(6, 22, 52, 0.92);
  border: 1px solid rgba(105, 185, 255, 0.45);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 11px;
  color: #d6eeff;
}

.shop-footer-tip b {
  color: #ffe866;
}

/* =========================================================
   5. MYPAGE SCREEN (MyInfo/MP_Stage + Titles)
   ========================================================= */
#screen-mypage {
  background:
    linear-gradient(180deg, rgba(7, 26, 62, 0.78) 0%, rgba(4, 16, 40, 0.88) 100%),
    url('/assets/ui/mypage_stage.png?_v3') no-repeat 0 0 / 800px 600px;
  padding: 14px 18px;
  display: none;
  flex-direction: column;
  gap: 12px;
}

#screen-mypage.active {
  display: flex;
}

.mypage-layout {
  flex: 1;
  display: flex;
  gap: 12px;
  min-height: 0;
}

.mypage-profile-card {
  width: 230px;
  background: linear-gradient(180deg, rgba(14, 52, 112, 0.94) 0%, rgba(7, 26, 60, 0.96) 100%);
  border: 2px solid #5bb4ff;
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.mp-avatar-box {
  background: rgba(4, 16, 38, 0.85);
  border: 2px solid #4ca2f5;
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.mp-preview-title {
  min-width: 123px;
  min-height: 22px;
  background: url('/assets/ui/mp_title_bar.png?_v3') no-repeat center center / 100% 100%,
              linear-gradient(180deg, #246fd4 0%, #103b7a 100%);
  border: 1px solid #8ad0ff;
  border-radius: 12px;
  padding: 3px 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 900;
  color: #ffe866;
  text-shadow: 0 1px 2px #000;
}

.mp-preview-title .mp-title-spr {
  display: inline-block;
  width: 44px;
  height: 16px;
  background-repeat: no-repeat;
  background-position: 0 0;
  flex-shrink: 0;
  image-rendering: pixelated;
}

#mp-char-canvas {
  width: 96px;
  height: 106px;
  image-rendering: pixelated;
}

.mp-preview-name {
  font-size: 15px;
  font-weight: 900;
  color: #ffffff;
}

.mp-stats-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(5, 19, 44, 0.82);
  border-radius: 8px;
  padding: 10px;
  font-size: 12px;
}

.mp-stat-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 6px;
}

.mp-stat-row span {
  font-size: 11px;
  color: #9fd0ff;
}

.mp-stat-row b {
  color: #ffe875;
  font-size: 12px;
}

.mypage-right-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mp-section-box {
  flex: 1;
  background: linear-gradient(180deg, rgba(14, 52, 112, 0.94) 0%, rgba(7, 26, 60, 0.96) 100%);
  border: 2px solid #5bb4ff;
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.mp-section-box h4 {
  font-size: 14px;
  color: #ffe866;
  margin-bottom: 8px;
}

.mp-equip-grid,
.mp-title-builder {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.mp-equip-col {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.mp-equip-col label {
  font-size: 11px;
  font-weight: 800;
  color: #bfe3ff;
}

.mp-equip-col select {
  padding: 7px 8px;
  border-radius: 6px;
  border: 1px solid #63b5ff;
  background: #061838;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.mp-owned-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.owned-pill {
  font-size: 11px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 12px;
  background: rgba(25, 115, 210, 0.55);
  border: 1px solid #74c2ff;
  color: #e8f6ff;
}

.mp-custom-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.mp-custom-title-row label {
  font-size: 11px;
  font-weight: 800;
  color: #c8e7ff;
  white-space: nowrap;
}

.mp-custom-title-row input {
  flex: 1;
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid #63b5ff;
  background: #061838;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  user-select: text;
}

.mp-save-btn {
  flex: 0 0 120px;
  height: 36px;
}

/* =========================================================
   6. MAP EDITOR SCREEN (15x13 Grid & Item Probabilities)
   ========================================================= */
#screen-editor {
  background: radial-gradient(circle at center, #123873 0%, #071938 100%);
  padding: 10px 14px;
  display: none;
  flex-direction: column;
  gap: 8px;
}

#screen-editor.active {
  display: flex;
}

.editor-top-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.editor-top-controls input,
.editor-top-controls select {
  padding: 4px 7px;
  border-radius: 5px;
  border: 1px solid #65b8ff;
  background: #061838;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  user-select: text;
}

#editor-map-name {
  width: 130px;
}

.editor-main-layout {
  flex: 1;
  display: flex;
  gap: 10px;
  min-height: 0;
}

.editor-canvas-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  justify-content: center;
  background: rgba(5, 18, 42, 0.9);
  border: 2px solid #56adff;
  border-radius: 10px;
  padding: 8px;
}

#editor-canvas {
  width: 480px;
  height: 416px;
  border: 2px solid #85cbff;
  border-radius: 4px;
  cursor: crosshair;
  background: #1d4d2b;
  image-rendering: pixelated;
}

.editor-canvas-hint {
  font-size: 10px;
  color: #bfe3ff;
  text-align: center;
}

.editor-side-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.editor-panel-box {
  background: rgba(8, 30, 68, 0.92);
  border: 1px solid #52a8ff;
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.editor-panel-box h4 {
  font-size: 12px;
  color: #ffe76b;
}

.editor-brush-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.editor-brush-btn {
  padding: 5px 4px;
  border-radius: 5px;
  border: 1px solid #4d9ef0;
  background: #09234f;
  color: #d9efff;
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
  text-align: center;
}

.editor-brush-btn.active {
  background: #ff9d1c;
  border-color: #ffe48a;
  color: #1f0d00;
}

#editor-fixed-item-select {
  padding: 5px 6px;
  border-radius: 5px;
  border: 1px solid #5cb2ff;
  background: #061838;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.editor-prob-box {
  flex: 1;
  min-height: 0;
}

.prob-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#editor-droprate-label {
  font-size: 12px;
  font-weight: 900;
  color: #67ff90;
}

#editor-droprate-slider {
  width: 100%;
}

.prob-sub {
  font-size: 10px;
  color: #abd8ff;
}

.editor-weights-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 4px;
}

.weight-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  background: rgba(4, 15, 36, 0.7);
  padding: 3px 6px;
  border-radius: 4px;
}

.weight-row span.w-name {
  width: 78px;
  font-weight: 800;
  color: #e3f3ff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.weight-row input[type="range"] {
  flex: 1;
}

.weight-row span.w-val {
  width: 48px;
  text-align: right;
  font-size: 10px;
  font-weight: 800;
  color: #ffe66d;
}

/* =========================================================
   7. IN-GAME SCREEN & BOTTOM-LEFT CHAT OVERLAY
   ========================================================= */
#screen-game {
  background: #000;
}

#game-canvas {
  width: 800px;
  height: 600px;
  display: block;
}

/* Bottom-Left In-Game Chat Overlay (Requirement #13) */
.game-chat-overlay {
  position: absolute;
  left: 24px;
  bottom: 44px;
  width: 390px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
  z-index: 15;
}

.game-chat-log {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 135px;
  overflow: hidden;
  padding: 4px 6px;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.35;
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000,
     0px  2px 4px rgba(0, 0, 0, 0.95);
}

/* My chat = Yellow (#ffe84d), Opponent/Other chat = White (#ffffff) */
.game-chat-line.mine {
  color: #ffe84d;
}

.game-chat-line.other {
  color: #ffffff;
}

.game-chat-input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(5, 20, 48, 0.88);
  border: 2px solid #ffe45e;
  border-radius: 6px;
  padding: 4px 8px;
  pointer-events: auto;
}

.game-chat-input-wrap.hidden {
  display: none;
}

.chat-prompt-tag {
  font-size: 11px;
  font-weight: 900;
  color: #ffe84d;
  white-space: nowrap;
}

#game-chat-input {
  flex: 1;
  background: transparent;
  border: none;
  color: #ffe84d;
  font-size: 12px;
  font-weight: 800;
  outline: none;
  user-select: text;
}

.game-exit-btn {
  position: absolute;
  left: 642px;
  top: 560px;
  width: 150px;
  height: 34px;
  background: rgba(210, 50, 50, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 6px;
  color: transparent;
  cursor: pointer;
}

.game-exit-btn:hover {
  background: rgba(255, 80, 80, 0.28);
  border-color: #ff9e9e;
}

/* Controls Bar */
.controls-bar {
  width: min(96vw, 800px);
  background: rgba(8, 28, 62, 0.9);
  border: 1px solid #3c8be0;
  border-radius: 8px;
  padding: 4px 12px;
  font-size: 11px;
  color: #d6ecff;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

.controls-bar kbd {
  background: #184a8c;
  border: 1px solid #6cb8ff;
  border-radius: 4px;
  padding: 0 5px;
  font-size: 10px;
  font-weight: 700;
  color: #fff48f;
}
