:root {
  --chat-width: 400px;
  --chat-width-collapsed: 400px;
  --bars-height: 80px;
  --height-excluding-bars: calc(100vh - var(--bars-height));
  --info-bar-height: 38px;
}

body {
  background: #111111;
  margin: 0;
  padding: 0;
  font-family: "Roboto", sans-serif;
  color: #fff;
  min-height: 100vh;
}

a {
  color: gold;
  text-decoration: none;
}

#app {
  display: none;
}

.connection-screen h1 {
  margin-bottom: 0;
}

.connection-screen {
  background: url('/static/img/bg.jpg')  center 30%/cover no-repeat;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.connect-container {
  background: rgba(0, 0, 0, 0.7);
  padding: 1rem 3rem;
  border-radius: 12px;
  text-align: center;
}

.connect-input {
  padding: 0.5rem;
  margin-top: 1rem;
  font-size: 1rem;
  width: 100%;
  border-radius: 8px;
  border: none;
}

.connect-button {
  margin-top: 1rem;
  padding: 0.6rem 1.2rem;
  font-size: 1rem;
  background-color: gold;
  color: black;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.view-header {
  height: 40px;
  display: flex;
  position: fixed;
  align-items: center;
  border-bottom: 2px solid #00000066;
  background: #141414cc;
  backdrop-filter: blur(10px);
  top: var(--info-bar-height);
  left: 0;
  right: 0;
  z-index: 1f;
}

.view-header .title {
  margin-left: 2rem;
}

.view-header .action {
  margin-left: 2rem;
}

[data-view="game"] {
  background: url('/static/img/lobby.jpg')  top left / cover no-repeat;
  /*backdrop-filter: blur(4px);*/
}
[data-view="game/deep-space"] {
  background: url('/static/img/games/deep-space-bg.jpg')  top left / cover no-repeat;
  /*backdrop-filter: blur(4px);*/
}

.view-main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.main-panel h2 {
  text-shadow:
    0 0 4px black,
    0 0 6px black,
    1px 1px 4px black;
}

.main-panel {
  flex: 1;
  /*padding: var(--bars-height) 0 1rem 2rem;*/
  overflow-y: auto;
  transition: flex-basis 0.2s ease;
  margin-right: var(--chat-width);
}

[data-view-type="game"] .main-panel {
  margin-right: 0;
}

.chat-panel {
  display: flex;
  transition: flex-basis 0.2s ease, width 0.2s ease;
  flex-direction: column;
  position: fixed;
  right: 0;
  width: var(--chat-width);
  background: #141414cc;
  backdrop-filter: blur(10px);
  color: white;
  overflow-y: auto;
  padding: 1rem;
  box-shadow: -2px 0 6px rgba(0,0,0,0.4);
  top: var(--info-bar-height);
  bottom: 0;
  z-index: 1;
}
.chat-collapsed {
  --chat-width: 30px;
}
.chat-collapsed .chat-panel h2, .chat-collapsed .chat-panel .chat-messages, .chat-collapsed #chat-form {
  display: none;
}

#chat-toggle-icon {
  transition: transform 0.3s ease;
}
.chat-collapsed #chat-toggle-icon {
  transform: rotate(180deg);
}

.chat-messages {
  flex: 1;
  background: #00000077;
  padding: 1rem;
  margin-bottom: 0.5rem;
  border-radius: 8px;
  overflow-y: auto;
}

.chat-messages p {
  padding: 0;
  margin: 0;
}

.chat-panel form {
  display: flex;
}

.chat-panel h2 {
  margin: 0 0 1rem 0;
}

.chat-input {
  padding: 0.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  flex: 1;
  min-width: 0;
  max-width: 100%;
}

.reconnect-indicator {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6); /* semi-transparent black */
  color: #fff;
  z-index: 1000;
  backdrop-filter: blur(6px); /* blurred background */
  -webkit-backdrop-filter: blur(6px); /* for Safari */
  align-items: center;
  justify-content: center;
  font-size: 24px;
  text-align: center;
}

.game-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, 200px);
  gap: 16px;
}
.game-list div {
  position: relative;
  display: inline-block;
  width: 200px;
  height: 200px;
}
.game-list img {
  border-radius: 32px;
  width: 100%;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  box-shadow: 0 5px 5px 1px rgb(35 19 31 / 70%);
}
.game-list .live img:hover {
  transform: scale(1.03) rotate(-1deg);
  box-shadow:
    0 0 10px 10px rgba(255, 20, 147, 0.5),
    0 0 15px 10px rgba(55, 12, 44, 0.6);
}
.game-list .coming_soon {
  filter: grayscale(100%);
}
.game-list .coming_soon::after {
  content: "COMING SOON";
  position: absolute;
  text-align: center;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 8px 16px;
  font-weight: bold;
  font-size: 1.2rem;
  border-radius: 4px;
  pointer-events: none;
}

[view] {
  cursor: pointer;
}

.toggle-icon {
  font-size: 18px;
  user-select: none;
  float: right;
  margin-right: 0.5rem;
  margin-top:0.25rem;
  cursor: pointer;
}

.content {
  padding-top: var(--bars-height);
  padding-left: 2rem;
}

/* Player */
.info-bar .item {
  flex: 0 0 auto;
}
.info-bar {
  height: 20px;
  background: #222;
  padding: 0.5rem 2rem;
  font-size: 0.9rem;
  border-bottom: 2px solid #111;
  background: #222222cc;
  backdrop-filter: blur(10px);
  text-align: right;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
}
.info-bar > * {
  transition: opacity 1s ease;
  opacity: 1;
  visibility: visible;
}
.info-bar.loading > * {
  visibility: hidden;
  opacity: 0;
}

#username {
  cursor: pointer;
  text-decoration: underline;
}

.avatar {
  --avatar-size: 128px;
  width: var(--avatar-size);
  height: var(--avatar-size);
  background-size: 640px 384px; /* 5 cols x 128 = 640, 3 rows x 128 = 384 */
  background-repeat: no-repeat;
  background-size: calc(640px / 4) calc(384px / 4);
  image-rendering: auto;
  filter: drop-shadow(0px 0px 1px #dbd5d2);
  flex-shrink: 0;
}
.avatar.md {
  --avatar-size: calc(128px / 2);
}
.avatar.sm {
  --avatar-size: calc(128px / 4);
}

.avatar.female {
    background-image: url('/static/img/avatars/female.png');
}
.avatar.male {
    background-image: url('/static/img/avatars/male.png');
}

.avatar[avatar-index="1"]  { background-position: 0px 0px; }
.avatar[avatar-index="2"]  { background-position: calc(var(--avatar-size) * -1) 0px; }
.avatar[avatar-index="3"]  { background-position: calc(var(--avatar-size) * -2) 0px; }
.avatar[avatar-index="4"]  { background-position: calc(var(--avatar-size) * -3) 0px; }
.avatar[avatar-index="5"]  { background-position: calc(var(--avatar-size) * -4) 0px; }

.avatar[avatar-index="6"]  { background-position: 0px calc(var(--avatar-size) * -1); }
.avatar[avatar-index="7"]  { background-position: calc(var(--avatar-size) * -1) calc(var(--avatar-size) * -1); }
.avatar[avatar-index="8"]  { background-position: calc(var(--avatar-size) * -2) calc(var(--avatar-size) * -1); }
.avatar[avatar-index="9"]  { background-position: calc(var(--avatar-size) * -3) calc(var(--avatar-size) * -1); }
.avatar[avatar-index="10"] { background-position: calc(var(--avatar-size) * -4) calc(var(--avatar-size) * -1); }

.avatar[avatar-index="11"] { background-position: 0px -calc(var(--avatar-size) * -2); }
.avatar[avatar-index="12"] { background-position: calc(var(--avatar-size) * -1) -calc(var(--avatar-size) * -2); }
.avatar[avatar-index="13"] { background-position: calc(var(--avatar-size) * -2) -calc(var(--avatar-size) * -2); }
.avatar[avatar-index="14"] { background-position: calc(var(--avatar-size) * -3) -calc(var(--avatar-size) * -2); }
.avatar[avatar-index="15"] { background-position: calc(var(--avatar-size) * -4) -calc(var(--avatar-size) * -2); }

.level-pill {
  position: absolute;
  bottom: -5px;
  left: 0;
  background: gold;
  color: #000;
  font-size: 10px;
  font-weight: bold;
  line-height: 1;
  padding: 1px;
  border-radius: 8px;
  min-width: 14px;
  text-align: center;
  box-shadow: 0 0 0 1px #efdf85;
  pointer-events: none;
}
@keyframes blip {
  0%   { transform: scale(1); }
  20%  { transform: scale(1.6); }
  40%  { transform: scale(0.85); }
  60%  { transform: scale(1.3); }
  80%  { transform: scale(0.95); }
  100% { transform: scale(1); }
}

.blip {
  animation: blip 700ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Chat */
.chat, .notice {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin-bottom: 0.5rem;
  background-color: #00000033;
  border-radius: 0.25rem;
}
.notice {
  color: gold;
}

/* Tooltip styling (applied inline via JS) */
.tooltip {
  visibility: hidden;
  position: absolute;
  background: #442255cc;
  backdrop-filter: blur(10px);
  color: #fff;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 1000;
  box-shadow: 10px 10px 20px rgba(0, 0, 0, 0.8);
  opacity: 0;
  transition: opacity 0.2s ease;
  display: flex;
  flex-direction: column;
  gap:8px;
  padding-top: 1rem;
}
.tooltip.show {
  opacity: 1;
  visibility: visible;
}

.logout {
  padding-top: 0px;
  margin-top: 8px;
  border-top: 1px solid #000000aa;
  box-shadow: inset 0em 0.1em 0rem #00000033;
  flex-grow: 1;
}
.logout button {
  padding: 8px 0px;
  background: transparent;
  border: none;
  color: gold;
  cursor: pointer;
  font-weight: bold;
}
.logout button:hover {
  text-decoration: underline;
}

/* Game specific */

.game-container {
  width: calc(100vw - 47px);
  height: var(--height-excluding-bars);
  overflow: hidden;
}

.game-inner {
  position: relative;
  width: 1280px;
  height: 720px;
  transform-origin: top left;
}

.game-canvas,
.game-ui {
  position: absolute;
  width: 1280px;
  height: 720px;
  aspect-ratio: 16 / 9;
  top: 0;
  left: 0;
  transform-origin: top left;
  visibility: hidden;
}

.game-canvas {
  box-shadow:
    0 0 10px rgba(0, 0, 0, 0.6),   /* inner soft border */
    0 0 25px rgba(0, 0, 0, 0.4),   /* middle glow */
    0 0 60px rgba(0, 0, 0, 0.3);   /* deep ambient glow */
}

.game-ui {
  flex-direction: row;
  align-items: flex-start;
  display: flex;
  pointer-events: none; /* let canvas handle input by default */
}

.game-ui > * {
  pointer-events: auto;
}

.game-loading {
  position: relative;
  width: 800px;
  height: 450px;
}
.game-loading::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10;
  pointer-events: all;
}

.game-loading::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -40px 0 0 -20px;
  border: 4px solid white;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  z-index: 11;
}

.game-loading span.loading-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, 60px);
  color: white;
  font-weight: bold;
  font-size: 1.2rem;
  z-index: 11;
  pointer-events: none;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
