* {
  box-sizing: border-box;
}

html,
body,
#app {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  color: #18221d;
  font-family: Arial, Helvetica, sans-serif;
  background: #8ccf69;
  overflow: hidden;
}

button,
input {
  font: inherit;
}

.panel {
  position: fixed;
  inset: 0;
  display: grid;
  align-content: center;
  gap: 18px;
  width: min(480px, calc(100vw - 28px));
  margin: auto;
  height: max-content;
  padding: 22px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(24, 34, 29, 0.14);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(24, 34, 29, 0.28);
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.mark {
  width: 46px;
  height: 46px;
  border-radius: 50% 50% 44% 44%;
  background: #f4d35e;
  border: 3px solid #d9480f;
  box-shadow: inset 0 -8px 0 rgba(0, 0, 0, 0.08);
}

h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1;
}

p {
  margin: 6px 0 0;
  color: #526052;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  font-size: 13px;
  font-weight: 700;
  color: #526052;
}

.field input {
  width: 100%;
  height: 46px;
  padding: 0 12px;
  border: 1px solid rgba(24, 34, 29, 0.18);
  border-radius: 6px;
  background: #fff;
  color: #18221d;
}

.field.compact {
  width: 86px;
}

.field.compact input {
  padding: 4px;
}

.row {
  display: flex;
  align-items: end;
  gap: 12px;
}

button {
  flex: 1;
  height: 46px;
  border: 0;
  border-radius: 6px;
  background: #247a3b;
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.room {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(36, 122, 59, 0.08);
}

.room-head,
.player-row,
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.room-head span {
  font-family: Consolas, monospace;
  font-weight: 800;
}

#playerList {
  display: grid;
  gap: 8px;
  min-height: 108px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.player-row {
  min-height: 30px;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.72);
}

.dot {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(24, 34, 29, 0.25);
  border-radius: 50%;
  flex: 0 0 auto;
}

.player-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ping {
  color: #526052;
  font-size: 13px;
}

.hint {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hint span {
  padding: 6px 9px;
  border-radius: 999px;
  background: #eef5e9;
  color: #526052;
  font-size: 13px;
  font-weight: 700;
}

.game {
  position: fixed;
  inset: 0;
}

#world {
  display: block;
  width: 100%;
  height: 100%;
}

.hud {
  position: fixed;
  top: 14px;
  left: 14px;
  right: 14px;
  min-height: 54px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(10px);
  pointer-events: none;
}

.hud div {
  display: grid;
  gap: 4px;
}

.hud span,
#hudPlayers {
  color: #526052;
  font-size: 13px;
}

.hidden {
  display: none;
}

@media (max-width: 560px) {
  .row {
    align-items: stretch;
    flex-direction: column;
  }

  .field.compact {
    width: 100%;
  }
}

.touch-controls {
  position: fixed;
  inset: auto 0 0 0;
  display: none;
  justify-content: space-between;
  align-items: end;
  padding: 0 max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  pointer-events: none;
  z-index: 3;
}

.stick {
  position: relative;
  width: 138px;
  height: 138px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 50%;
  background: rgba(24, 34, 29, 0.18);
  box-shadow: inset 0 0 0 18px rgba(255, 255, 255, 0.09), 0 12px 34px rgba(24, 34, 29, 0.22);
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.stick::before,
.stick::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  background: rgba(255, 255, 255, 0.34);
  transform: translate(-50%, -50%);
}

.stick::before {
  width: 62%;
  height: 2px;
}

.stick::after {
  width: 2px;
  height: 62%;
}

.stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 58px;
  height: 58px;
  border: 2px solid rgba(255, 255, 255, 0.56);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.42);
  box-shadow: 0 10px 24px rgba(24, 34, 29, 0.24);
  transform: translate(-50%, -50%);
  will-change: transform;
}

.look-stick .stick-knob {
  background: rgba(255, 232, 148, 0.52);
}

@media (hover: none), (pointer: coarse), (max-width: 920px) {
  html,
  body,
  #app,
  .game,
  #world {
    touch-action: none;
    overscroll-behavior: none;
    -webkit-user-select: none;
    user-select: none;
  }

  .touch-controls {
    display: flex;
  }

  .hud {
    top: max(10px, env(safe-area-inset-top));
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
  }
}

@media (orientation: portrait) and (hover: none) {
  .panel {
    width: min(440px, calc(100vw - 22px));
    max-height: calc(100dvh - 22px);
    overflow: auto;
  }

  .touch-controls {
    transform: scale(0.86);
    transform-origin: bottom center;
  }
}

@media (max-height: 480px) and (orientation: landscape) {
  .panel {
    width: min(680px, calc(100vw - 24px));
    grid-template-columns: 1fr 1fr;
    align-items: start;
    gap: 12px 18px;
    padding: 16px;
  }

  .brand,
  .hint {
    grid-column: 1 / -1;
  }

  #playerList {
    min-height: 74px;
  }

  .stick {
    width: 124px;
    height: 124px;
  }
}

.player-status {
  min-width: 58px;
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(36, 122, 59, 0.12);
  color: #247a3b;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
}
