:root {
  color-scheme: light;
  font-family: "Nunito", "Avenir Next", system-ui, sans-serif;
  background: #183b34;
  color: #fff5dd;
  --top: max(env(safe-area-inset-top), 10px);
  --bottom: max(
    env(safe-area-inset-bottom),
    12px
  );
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
  font: inherit;
  touch-action: manipulation;
  cursor: pointer;
}

button:focus-visible {
  outline: 3px solid #ffda8e;
  outline-offset: 4px;
}

button:disabled {
  cursor: default;
}

#game {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 260px;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 0%, #618c69, #183b34 76%);
}

#river,
#faces,
.topbar {
  position: absolute;
  width: 100%;
}

#river,
#faces {
  inset: 0;
  height: 100%;
}

#river {
  visibility: hidden;
  touch-action: none;
}

#river.rendered {
  visibility: visible;
}

#faces {
  pointer-events: none;
}

.topbar {
  top: var(--top);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-inline: max(env(safe-area-inset-left), 15px) max(env(safe-area-inset-right), 15px);
  pointer-events: none;
}

.brand,
.sound,
.control-label,
#notice {
  background: #214b50;
  box-shadow: 0 3px 0 #142c2873;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 14px 5px 6px;
  border: 1px solid #c0e8c42b;
  border-radius: 24px;
}

.brand-icon {
  width: 29px;
  height: 29px;
  border: 1px solid #fce8bd;
  border-radius: 50%;
  background: radial-gradient(circle, #224c51 0 31%, transparent 34%),
    repeating-conic-gradient(from 25deg, #ffa16a 0 49deg, #ffedbc 50deg 89deg);
  box-shadow: inset 0 -2px 0 #935c3e70;
}


h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 14px;
  letter-spacing: .015em;
  font-weight: 850;
}

.sound {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid #c0e8c42b;
  border-radius: 50%;
  color: #fff5dd;
  font-size: 24px;
  font-weight: 800;
  pointer-events: auto;
}

.sound[aria-pressed="false"] {
  color: #c1d1c3;
}

.sound[aria-pressed="false"] span {
  text-decoration: line-through;
}

.panel {
  position: absolute;
  inset: auto 12px calc(var(--bottom) + 4px);
  width: calc(100% - 24px);
  max-width: 440px;
  max-height: calc(100% - var(--top) - var(--bottom) - 58px);
  margin-inline: auto;
  padding: clamp(16px, 5vw, 24px);
  overflow-y: auto;
  border: 1px solid #fff9e7;
  border-radius: 25px;
  background: linear-gradient(155deg, #fff9e8, #ffedce);
  box-shadow: 0 4px 0 #ad855b, 0 10px 30px #123f4852;
  color: #21372c;
}

.room-count {
  display: inline-block;
  margin-bottom: 9px;
  color: #426446;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .105em;
  text-transform: uppercase;
}

h2 {
  font-size: clamp(27px, 8vw, 39px);
  line-height: .98;
  letter-spacing: -.045em;
  font-weight: 900;
}

.panel-text {
  margin-top: 9px;
  color: #3f594c;
  font-size: 14px;
  line-height: 1.42;
}

.roster {
  display: flex;
  gap: 9px;
  margin: 13px 0 0;
  padding: 0;
  list-style: none;
}

.roster li {
  display: grid;
  min-width: 0;
  max-width: 78px;
  flex: 1 1 0;
  justify-items: start;
  gap: 3px;
  color: #254534;
  font-size: 11px;
  font-weight: 800;
}

.roster li > span:last-child {
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  border: 2px solid #fff8e6;
  background: var(--seat, #99c9ae);
  color: #213429;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.avatar img {
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar [aria-hidden] {
  grid-area: 1 / 1;
}

.face {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--face-size);
  height: var(--face-size);
  font-size: calc(var(--face-size) * .37);
  border-color: var(--seat, #f4f1da);
  box-shadow: inset 0 0 0 1px #6a544b33;
  border-width: max(1px, calc(var(--face-size) * .033));
}

.face.self {
  border-color: #ffedb8;
}

.offline {
  opacity: .55;
}

.start {
  width: 100%;
  min-height: 48px;
  margin-top: 13px;
  padding: 10px 15px;
  border-radius: 14px;
  background: #28635a;
  box-shadow: inset 0 -4px 0 #1a4845;
  color: #fff9e7;
  font-size: 17px;
  font-weight: 900;
}

.start:active {
  background: #204c35;
}

.start:disabled {
  opacity: .55;
}

#notice {
  position: absolute;
  top: calc(var(--top) + 59px);
  left: 50%;
  max-width: calc(100% - 32px);
  width: max-content;
  padding: 7px 13px;
  border-radius: 18px;
  transform: translateX(-50%);
  color: #fff3dc;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.controls {
  position: absolute;
  bottom: calc(var(--bottom) + 7px);
  left: 50%;
  display: flex;
  width: min(100%, 760px);
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding-inline: max(env(safe-area-inset-left), 20px) max(env(safe-area-inset-right), 20px);
  transform: translateX(-50%);
  pointer-events: none;
}

.steer {
  display: grid;
  justify-items: center;
  gap: 5px;
}

.joystick,
.push {
  width: clamp(74px, 26vmin, 112px);
  aspect-ratio: 1;
  border-radius: 50%;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.joystick {
  display: grid;
  position: relative;
  place-items: center;
  border: 2px solid #f8fbdaaf;
  background: #285969b8;
  box-shadow: inset 0 0 0 5px #16382f5c, 0 3px 0 #10352e70;
}

.joystick::before {
  content: "";
  position: absolute;
  inset: 18%;
  border: 1px dashed #d3efb76f;
  border-radius: 50%;
}

.stick {
  width: 48%;
  aspect-ratio: 1;
  border: 2px solid #f7f9ca;
  border-radius: 50%;
  background: #a8e4b1;
  box-shadow: 0 4px 0 #456c45;
  transform: translate(var(--stick-x, 0px), var(--stick-y, 0px));
}

.control-label {
  padding: 3px 12px;
  border-radius: 13px;
  color: #fff7de;
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  font-weight: 900;
}

.push {
  --charge: 100%;
  display: grid;
  position: relative;
  place-items: center;
  padding: 8px;
  background: conic-gradient(#fff5c5 var(--charge), #92543b 0);
  box-shadow: 0 5px 0 #733c2b, 0 9px 18px #15312780;
  color: #41241a;
  font-size: clamp(19px, 6vmin, 30px);
  font-weight: 950;
}

.push span {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  border-radius: 50%;
  background: #ffab77;
  box-shadow: inset 0 -4px 0 #e98155;
}

.push:active:not(:disabled) {
  transform: translateY(3px);
}

.push[aria-disabled="true"] span {
  background: #e79470;
}

@media (orientation: landscape) and (max-height: 520px) {
  .panel {
    width: min(46%, 390px);
    margin-right: 0;
  }

  .controls {
    width: 100%;
  }

  .panel-text {
    font-size: 13px;
  }
}

#faces { z-index: 1; }
.topbar, .controls, #notice, .panel { z-index: 2; }
#notice { pointer-events: none; }
.brand { flex-shrink: 0; }
.route {
  --progress: 0%;
  display: flex;
  align-items: center;
  position: relative;
  width: clamp(54px, 20vw, 165px);
  height: 13px;
  margin: 0 12px 0 auto;
  border: 2px solid #fff2d1;
  border-radius: 12px;
  background: #255558c9;
  box-shadow: 0 2px 0 #34555863;
}
.route span {
  width: var(--progress);
  height: 100%;
  border-radius: inherit;
  background: #ffd27c;
}
.route i {
  position: absolute;
  right: -3px;
  top: -8px;
  width: 13px;
  height: 13px;
  border-left: 2px solid #3b5556;
  background: conic-gradient(#fff4d3 25%, #45656a 0 50%, #fff4d3 0 75%, #45656a 0) 0 0 / 7px 7px;
}
.species { display: inline-flex; gap: 3px; margin-top: 11px; padding: 3px; border-radius: 13px; background: #e8dcc6; }
.species button {
  min-height: 35px;
  padding: 5px 11px;
  border-radius: 10px;
  background: transparent;
  color: #4d5a50;
  font-size: 13px;
  font-weight: 800;
}
.species button::before {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 6px;
  border-radius: 50%;
  background: #9986ab;
  content: "";
}
.species button[data-animal="capybara"]::before { background: #ba8657; }
.species button[aria-pressed="true"] { color: #263d3d; background: #fffaf0; box-shadow: 0 1px 3px #50443144; }
.mouse-help {
  align-self: flex-end;
  margin: 0 auto;
  padding: 8px 15px;
  border: 1px solid #fff4d66b;
  border-radius: 22px;
  color: #fff3d6;
  background: #244b52ec;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}
#game[data-input="touch"] .mouse-help { display: none; }
#game:not([data-input="touch"]) .controls { justify-content: center; }
#game:not([data-input="touch"]) .steer,
#game:not([data-input="touch"]) .push { display: none; }
#game[data-racing="true"]:not([data-input="touch"]) #river { cursor: crosshair; }
.push[data-held="true"] { transform: translateY(3px); }
#game[data-input="touch"] .controls { width: 100%; }
@media (min-width: 780px) and (min-height: 521px) {
  .panel { max-width: 345px; margin-left: max(20px, 3vw); bottom: max(24px, 4vh); }
}
@media (max-height: 620px) and (orientation: portrait) {
  .panel { padding: 12px 16px; border-radius: 19px; bottom: var(--bottom); }
  .room-count { margin-bottom: 5px; }
  .panel-text, .roster, .start, .species { margin-top: 7px; }
  .roster .avatar { width: 28px; height: 28px; }
  .start { min-height: 42px; }
}
@media (orientation: landscape) and (max-height: 520px) {
  .panel { padding: 12px 15px; }
  .room-count { margin-bottom: 4px; }
  h2 { font-size: 27px; }
  .species { margin-top: 6px; }
  .roster { margin: 6px 0 0; }
  .roster .avatar { width: 26px; height: 26px; }
}
