html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: #1f2b1f;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-text-size-adjust: 100%;
}

#game {
  display: block;
  margin: 0 auto;
  background: #8fcf78;
  cursor: crosshair;
  touch-action: none;
}

#hint {
  position: fixed;
  left: 16px;
  top: 12px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.45);
  color: white;
  font-size: 13px;
  line-height: 1.55;
  border-radius: 8px;
  pointer-events: none;
  display: none;
}

#chat-panel {
  position: fixed;
  left: 12px;
  bottom: 22px;
  width: 310px;
  height: 150px;
  overflow: hidden;
  background: rgba(18, 14, 8, 0.58);
  border: 1px solid rgba(236, 202, 126, 0.36);
  border-radius: 8px;
  color: #fff1c6;
  font-size: 12px;
  pointer-events: none;
  z-index: 2;
}

#chat-tabs {
  display: flex;
  height: 28px;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  background: rgba(31, 23, 12, 0.72);
  border-bottom: 1px solid rgba(236, 202, 126, 0.24);
  color: #e5c889;
  font-weight: 700;
}

#log {
  height: 88px;
  padding: 8px 10px;
  overflow: hidden;
  color: #fff1c6;
  line-height: 1.45;
}

#log div::before {
  content: "[系统] ";
  color: #f6dc72;
  font-weight: 700;
}

#chat-input {
  height: 24px;
  margin: 0 8px 8px;
  padding: 3px 10px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.46);
  color: rgba(255, 241, 198, 0.68);
  line-height: 18px;
}

#character-open {
  position: fixed;
  right: 18px;
  bottom: 162px;
  width: 48px;
  height: 48px;
  border: 2px solid rgba(238, 203, 132, 0.78);
  border-radius: 50%;
  background: rgba(52, 35, 18, 0.82);
  color: #fff2c7;
  font-weight: 700;
  cursor: pointer;
  z-index: 4;
}

#character-panel {
  position: fixed;
  right: 18px;
  top: 88px;
  width: 250px;
  padding: 12px;
  border: 1px solid rgba(236, 202, 126, 0.48);
  border-radius: 8px;
  background: rgba(20, 14, 8, 0.82);
  color: #fff2c7;
  font-size: 13px;
  z-index: 5;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

#character-panel[hidden] {
  display: none;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  color: #f5d47b;
}

#character-close,
.point-row button,
#reset-progress {
  border: 1px solid rgba(236, 202, 126, 0.55);
  border-radius: 6px;
  background: rgba(63, 42, 19, 0.82);
  color: #fff2c7;
  cursor: pointer;
}

#character-close {
  width: 26px;
  height: 24px;
  font-size: 16px;
  line-height: 18px;
}

#character-stats {
  display: grid;
  gap: 4px;
  margin-bottom: 10px;
}

#character-stats div,
.point-row,
.point-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 24px;
  border-bottom: 1px solid rgba(236, 202, 126, 0.12);
}

#character-stats span {
  color: rgba(255, 242, 199, 0.72);
}

.point-summary {
  margin-top: 8px;
  color: #f5d47b;
  font-weight: 700;
}

.point-row {
  gap: 8px;
  padding: 5px 0;
}

.point-row span {
  flex: 1;
}

.point-row button {
  width: 28px;
  height: 24px;
  font-size: 16px;
}

#reset-progress {
  width: 100%;
  height: 30px;
  margin-top: 10px;
  color: #ffdca5;
}

@media (max-width: 700px), (pointer: coarse) {
  #hint {
    display: none;
  }

  #chat-panel {
    left: max(10px, env(safe-area-inset-left));
    right: auto;
    bottom: max(74px, calc(env(safe-area-inset-bottom) + 74px));
    width: min(190px, calc(100vw - 170px));
    height: 78px;
    font-size: 10px;
    background: rgba(18, 14, 8, 0.38);
  }

  #chat-tabs {
    height: 20px;
    gap: 5px;
    padding: 0 6px;
    font-size: 9px;
  }

  #log {
    height: 44px;
    padding: 4px 6px;
    line-height: 1.3;
  }

  #chat-input {
    display: none;
    height: 18px;
    margin: 0 6px 6px;
    padding: 2px 8px;
    line-height: 16px;
  }

  #character-open {
    right: max(14px, env(safe-area-inset-right));
    bottom: auto;
    top: max(260px, calc(env(safe-area-inset-top) + 260px));
    width: 36px;
    height: 36px;
    font-size: 11px;
  }

  #character-panel {
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
    top: max(150px, calc(env(safe-area-inset-top) + 150px));
    width: auto;
    max-height: calc(100vh - 210px);
    overflow: auto;
    font-size: 12px;
  }
}
